typescript 4.7.0-dev.20220405 → 4.7.0-dev.20220406
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/lib.dom.d.ts +404 -31
- package/lib/lib.dom.iterable.d.ts +16 -3
- package/lib/lib.es2020.intl.d.ts +15 -13
- package/lib/lib.es2021.intl.d.ts +102 -0
- package/lib/lib.es5.d.ts +1 -1
- package/lib/lib.webworker.d.ts +110 -25
- package/lib/lib.webworker.iterable.d.ts +3 -3
- package/lib/protocol.d.ts +5 -2
- package/lib/tsc.js +436 -228
- package/lib/tsserver.js +677 -296
- package/lib/tsserverlibrary.d.ts +21 -13
- package/lib/tsserverlibrary.js +677 -296
- package/lib/typescript.d.ts +16 -11
- package/lib/typescript.js +673 -296
- package/lib/typescriptServices.d.ts +16 -11
- package/lib/typescriptServices.js +673 -296
- package/lib/typingsInstaller.js +581 -264
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220406";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -4415,10 +4415,11 @@ var ts;
|
|
|
4415
4415
|
NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext";
|
|
4416
4416
|
NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext";
|
|
4417
4417
|
NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext";
|
|
4418
|
-
NodeFlags[NodeFlags["
|
|
4419
|
-
NodeFlags[NodeFlags["
|
|
4420
|
-
NodeFlags[NodeFlags["
|
|
4421
|
-
NodeFlags[NodeFlags["
|
|
4418
|
+
NodeFlags[NodeFlags["DisallowConditionalTypesContext"] = 65536] = "DisallowConditionalTypesContext";
|
|
4419
|
+
NodeFlags[NodeFlags["ThisNodeHasError"] = 131072] = "ThisNodeHasError";
|
|
4420
|
+
NodeFlags[NodeFlags["JavaScriptFile"] = 262144] = "JavaScriptFile";
|
|
4421
|
+
NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 524288] = "ThisNodeOrAnySubNodesHasError";
|
|
4422
|
+
NodeFlags[NodeFlags["HasAggregatedChildData"] = 1048576] = "HasAggregatedChildData";
|
|
4422
4423
|
// These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid
|
|
4423
4424
|
// walking the tree if the flags are not set. However, these flags are just a approximation
|
|
4424
4425
|
// (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared.
|
|
@@ -4428,25 +4429,25 @@ var ts;
|
|
|
4428
4429
|
// removal, it is likely that users will add the import anyway.
|
|
4429
4430
|
// The advantage of this approach is its simplicity. For the case of batch compilation,
|
|
4430
4431
|
// we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used.
|
|
4431
|
-
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] =
|
|
4432
|
-
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] =
|
|
4433
|
-
NodeFlags[NodeFlags["JSDoc"] =
|
|
4434
|
-
/* @internal */ NodeFlags[NodeFlags["Ambient"] =
|
|
4435
|
-
/* @internal */ NodeFlags[NodeFlags["InWithStatement"] =
|
|
4436
|
-
NodeFlags[NodeFlags["JsonFile"] =
|
|
4437
|
-
/* @internal */ NodeFlags[NodeFlags["TypeCached"] =
|
|
4438
|
-
/* @internal */ NodeFlags[NodeFlags["Deprecated"] =
|
|
4432
|
+
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 2097152] = "PossiblyContainsDynamicImport";
|
|
4433
|
+
/* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 4194304] = "PossiblyContainsImportMeta";
|
|
4434
|
+
NodeFlags[NodeFlags["JSDoc"] = 8388608] = "JSDoc";
|
|
4435
|
+
/* @internal */ NodeFlags[NodeFlags["Ambient"] = 16777216] = "Ambient";
|
|
4436
|
+
/* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 33554432] = "InWithStatement";
|
|
4437
|
+
NodeFlags[NodeFlags["JsonFile"] = 67108864] = "JsonFile";
|
|
4438
|
+
/* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached";
|
|
4439
|
+
/* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated";
|
|
4439
4440
|
NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped";
|
|
4440
4441
|
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
|
|
4441
4442
|
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags";
|
|
4442
4443
|
// Parsing context flags
|
|
4443
|
-
NodeFlags[NodeFlags["ContextFlags"] =
|
|
4444
|
+
NodeFlags[NodeFlags["ContextFlags"] = 50720768] = "ContextFlags";
|
|
4444
4445
|
// Exclude these flags when parsing a Type
|
|
4445
4446
|
NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags";
|
|
4446
4447
|
// Represents all flags that are potentially set once and
|
|
4447
4448
|
// never cleared on SourceFiles which get re-used in between incremental parses.
|
|
4448
4449
|
// See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`.
|
|
4449
|
-
/* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] =
|
|
4450
|
+
/* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 6291456] = "PermanentlySetIncrementalFlags";
|
|
4450
4451
|
})(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {}));
|
|
4451
4452
|
var ModifierFlags;
|
|
4452
4453
|
(function (ModifierFlags) {
|
|
@@ -8888,6 +8889,7 @@ var ts;
|
|
|
8888
8889
|
Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
|
|
8889
8890
|
Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls: diag(2836, ts.DiagnosticCategory.Error, "Import_assertions_are_not_allowed_on_statements_that_transpile_to_commonjs_require_calls_2836", "Import assertions are not allowed on statements that transpile to commonjs 'require' calls."),
|
|
8890
8891
|
Import_assertion_values_must_be_string_literal_expressions: diag(2837, ts.DiagnosticCategory.Error, "Import_assertion_values_must_be_string_literal_expressions_2837", "Import assertion values must be string literal expressions."),
|
|
8892
|
+
All_declarations_of_0_must_have_identical_constraints: diag(2838, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_constraints_2838", "All declarations of '{0}' must have identical constraints."),
|
|
8891
8893
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
8892
8894
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
8893
8895
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -14302,24 +14304,24 @@ var ts;
|
|
|
14302
14304
|
// Returns true if this node contains a parse error anywhere underneath it.
|
|
14303
14305
|
function containsParseError(node) {
|
|
14304
14306
|
aggregateChildData(node);
|
|
14305
|
-
return (node.flags &
|
|
14307
|
+
return (node.flags & 524288 /* ThisNodeOrAnySubNodesHasError */) !== 0;
|
|
14306
14308
|
}
|
|
14307
14309
|
ts.containsParseError = containsParseError;
|
|
14308
14310
|
function aggregateChildData(node) {
|
|
14309
|
-
if (!(node.flags &
|
|
14311
|
+
if (!(node.flags & 1048576 /* HasAggregatedChildData */)) {
|
|
14310
14312
|
// A node is considered to contain a parse error if:
|
|
14311
14313
|
// a) the parser explicitly marked that it had an error
|
|
14312
14314
|
// b) any of it's children reported that it had an error.
|
|
14313
|
-
var thisNodeOrAnySubNodesHasError = ((node.flags &
|
|
14315
|
+
var thisNodeOrAnySubNodesHasError = ((node.flags & 131072 /* ThisNodeHasError */) !== 0) ||
|
|
14314
14316
|
ts.forEachChild(node, containsParseError);
|
|
14315
14317
|
// If so, mark ourselves accordingly.
|
|
14316
14318
|
if (thisNodeOrAnySubNodesHasError) {
|
|
14317
|
-
node.flags |=
|
|
14319
|
+
node.flags |= 524288 /* ThisNodeOrAnySubNodesHasError */;
|
|
14318
14320
|
}
|
|
14319
14321
|
// Also mark that we've propagated the child information to this node. This way we can
|
|
14320
14322
|
// always consult the bit directly on this node without needing to check its children
|
|
14321
14323
|
// again.
|
|
14322
|
-
node.flags |=
|
|
14324
|
+
node.flags |= 1048576 /* HasAggregatedChildData */;
|
|
14323
14325
|
}
|
|
14324
14326
|
}
|
|
14325
14327
|
function getSourceFileOfNode(node) {
|
|
@@ -16126,11 +16128,11 @@ var ts;
|
|
|
16126
16128
|
}
|
|
16127
16129
|
ts.isSourceFileNotJS = isSourceFileNotJS;
|
|
16128
16130
|
function isInJSFile(node) {
|
|
16129
|
-
return !!node && !!(node.flags &
|
|
16131
|
+
return !!node && !!(node.flags & 262144 /* JavaScriptFile */);
|
|
16130
16132
|
}
|
|
16131
16133
|
ts.isInJSFile = isInJSFile;
|
|
16132
16134
|
function isInJsonFile(node) {
|
|
16133
|
-
return !!node && !!(node.flags &
|
|
16135
|
+
return !!node && !!(node.flags & 67108864 /* JsonFile */);
|
|
16134
16136
|
}
|
|
16135
16137
|
ts.isInJsonFile = isInJsonFile;
|
|
16136
16138
|
function isSourceFileNotJson(file) {
|
|
@@ -16138,7 +16140,7 @@ var ts;
|
|
|
16138
16140
|
}
|
|
16139
16141
|
ts.isSourceFileNotJson = isSourceFileNotJson;
|
|
16140
16142
|
function isInJSDoc(node) {
|
|
16141
|
-
return !!node && !!(node.flags &
|
|
16143
|
+
return !!node && !!(node.flags & 8388608 /* JSDoc */);
|
|
16142
16144
|
}
|
|
16143
16145
|
ts.isInJSDoc = isInJSDoc;
|
|
16144
16146
|
function isJSDocIndexSignature(node) {
|
|
@@ -16524,7 +16526,7 @@ var ts;
|
|
|
16524
16526
|
function setValueDeclaration(symbol, node) {
|
|
16525
16527
|
var valueDeclaration = symbol.valueDeclaration;
|
|
16526
16528
|
if (!valueDeclaration ||
|
|
16527
|
-
!(node.flags &
|
|
16529
|
+
!(node.flags & 16777216 /* Ambient */ && !(valueDeclaration.flags & 16777216 /* Ambient */)) &&
|
|
16528
16530
|
(isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
|
|
16529
16531
|
(valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
|
|
16530
16532
|
// other kinds of value declarations take precedence over modules and assignment declarations
|
|
@@ -20826,7 +20828,7 @@ var ts;
|
|
|
20826
20828
|
}
|
|
20827
20829
|
ts.pseudoBigIntToString = pseudoBigIntToString;
|
|
20828
20830
|
function isValidTypeOnlyAliasUseSite(useSite) {
|
|
20829
|
-
return !!(useSite.flags &
|
|
20831
|
+
return !!(useSite.flags & 16777216 /* Ambient */)
|
|
20830
20832
|
|| isPartOfTypeQuery(useSite)
|
|
20831
20833
|
|| isIdentifierInNonEmittingHeritageClause(useSite)
|
|
20832
20834
|
|| isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
|
|
@@ -21279,11 +21281,20 @@ var ts;
|
|
|
21279
21281
|
parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
|
|
21280
21282
|
parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
|
|
21281
21283
|
parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
|
|
21282
|
-
|
|
21283
|
-
|
|
21284
|
-
|
|
21285
|
-
|
|
21284
|
+
parenthesizeCheckTypeOfConditionalType: parenthesizeCheckTypeOfConditionalType,
|
|
21285
|
+
parenthesizeExtendsTypeOfConditionalType: parenthesizeExtendsTypeOfConditionalType,
|
|
21286
|
+
parenthesizeConstituentTypesOfUnionType: parenthesizeConstituentTypesOfUnionType,
|
|
21287
|
+
parenthesizeConstituentTypeOfUnionType: parenthesizeConstituentTypeOfUnionType,
|
|
21288
|
+
parenthesizeConstituentTypesOfIntersectionType: parenthesizeConstituentTypesOfIntersectionType,
|
|
21289
|
+
parenthesizeConstituentTypeOfIntersectionType: parenthesizeConstituentTypeOfIntersectionType,
|
|
21290
|
+
parenthesizeOperandOfTypeOperator: parenthesizeOperandOfTypeOperator,
|
|
21291
|
+
parenthesizeOperandOfReadonlyTypeOperator: parenthesizeOperandOfReadonlyTypeOperator,
|
|
21292
|
+
parenthesizeNonArrayTypeOfPostfixType: parenthesizeNonArrayTypeOfPostfixType,
|
|
21293
|
+
parenthesizeElementTypesOfTupleType: parenthesizeElementTypesOfTupleType,
|
|
21294
|
+
parenthesizeElementTypeOfTupleType: parenthesizeElementTypeOfTupleType,
|
|
21295
|
+
parenthesizeTypeOfOptionalType: parenthesizeTypeOfOptionalType,
|
|
21286
21296
|
parenthesizeTypeArguments: parenthesizeTypeArguments,
|
|
21297
|
+
parenthesizeLeadingTypeArgument: parenthesizeLeadingTypeArgument,
|
|
21287
21298
|
};
|
|
21288
21299
|
function getParenthesizeLeftSideOfBinaryForOperator(operatorKind) {
|
|
21289
21300
|
binaryLeftOperandParenthesizerCache || (binaryLeftOperandParenthesizerCache = new ts.Map());
|
|
@@ -21595,33 +21606,191 @@ var ts;
|
|
|
21595
21606
|
}
|
|
21596
21607
|
return body;
|
|
21597
21608
|
}
|
|
21598
|
-
|
|
21599
|
-
|
|
21609
|
+
// Type[Extends] :
|
|
21610
|
+
// FunctionOrConstructorType
|
|
21611
|
+
// ConditionalType[?Extends]
|
|
21612
|
+
// ConditionalType[Extends] :
|
|
21613
|
+
// UnionType[?Extends]
|
|
21614
|
+
// [~Extends] UnionType[~Extends] `extends` Type[+Extends] `?` Type[~Extends] `:` Type[~Extends]
|
|
21615
|
+
//
|
|
21616
|
+
// - The check type (the `UnionType`, above) does not allow function, constructor, or conditional types (they must be parenthesized)
|
|
21617
|
+
// - The extends type (the first `Type`, above) does not allow conditional types (they must be parenthesized). Function and constructor types are fine.
|
|
21618
|
+
// - The true and false branch types (the second and third `Type` non-terminals, above) allow any type
|
|
21619
|
+
function parenthesizeCheckTypeOfConditionalType(checkType) {
|
|
21620
|
+
switch (checkType.kind) {
|
|
21621
|
+
case 179 /* FunctionType */:
|
|
21622
|
+
case 180 /* ConstructorType */:
|
|
21623
|
+
case 189 /* ConditionalType */:
|
|
21624
|
+
return factory.createParenthesizedType(checkType);
|
|
21625
|
+
}
|
|
21626
|
+
return checkType;
|
|
21600
21627
|
}
|
|
21601
|
-
function
|
|
21602
|
-
switch (
|
|
21628
|
+
function parenthesizeExtendsTypeOfConditionalType(extendsType) {
|
|
21629
|
+
switch (extendsType.kind) {
|
|
21630
|
+
case 189 /* ConditionalType */:
|
|
21631
|
+
return factory.createParenthesizedType(extendsType);
|
|
21632
|
+
}
|
|
21633
|
+
return extendsType;
|
|
21634
|
+
}
|
|
21635
|
+
// UnionType[Extends] :
|
|
21636
|
+
// `|`? IntersectionType[?Extends]
|
|
21637
|
+
// UnionType[?Extends] `|` IntersectionType[?Extends]
|
|
21638
|
+
//
|
|
21639
|
+
// - A union type constituent has the same precedence as the check type of a conditional type
|
|
21640
|
+
function parenthesizeConstituentTypeOfUnionType(type) {
|
|
21641
|
+
switch (type.kind) {
|
|
21642
|
+
case 187 /* UnionType */: // Not strictly necessary, but a union containing a union should have been flattened
|
|
21643
|
+
case 188 /* IntersectionType */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
|
|
21644
|
+
return factory.createParenthesizedType(type);
|
|
21645
|
+
}
|
|
21646
|
+
return parenthesizeCheckTypeOfConditionalType(type);
|
|
21647
|
+
}
|
|
21648
|
+
function parenthesizeConstituentTypesOfUnionType(members) {
|
|
21649
|
+
return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfUnionType));
|
|
21650
|
+
}
|
|
21651
|
+
// IntersectionType[Extends] :
|
|
21652
|
+
// `&`? TypeOperator[?Extends]
|
|
21653
|
+
// IntersectionType[?Extends] `&` TypeOperator[?Extends]
|
|
21654
|
+
//
|
|
21655
|
+
// - An intersection type constituent does not allow function, constructor, conditional, or union types (they must be parenthesized)
|
|
21656
|
+
function parenthesizeConstituentTypeOfIntersectionType(type) {
|
|
21657
|
+
switch (type.kind) {
|
|
21603
21658
|
case 187 /* UnionType */:
|
|
21659
|
+
case 188 /* IntersectionType */: // Not strictly necessary, but an intersection containing an intersection should have been flattened
|
|
21660
|
+
return factory.createParenthesizedType(type);
|
|
21661
|
+
}
|
|
21662
|
+
return parenthesizeConstituentTypeOfUnionType(type);
|
|
21663
|
+
}
|
|
21664
|
+
function parenthesizeConstituentTypesOfIntersectionType(members) {
|
|
21665
|
+
return factory.createNodeArray(ts.sameMap(members, parenthesizeConstituentTypeOfIntersectionType));
|
|
21666
|
+
}
|
|
21667
|
+
// TypeOperator[Extends] :
|
|
21668
|
+
// PostfixType
|
|
21669
|
+
// InferType[?Extends]
|
|
21670
|
+
// `keyof` TypeOperator[?Extends]
|
|
21671
|
+
// `unique` TypeOperator[?Extends]
|
|
21672
|
+
// `readonly` TypeOperator[?Extends]
|
|
21673
|
+
//
|
|
21674
|
+
function parenthesizeOperandOfTypeOperator(type) {
|
|
21675
|
+
switch (type.kind) {
|
|
21604
21676
|
case 188 /* IntersectionType */:
|
|
21605
|
-
|
|
21606
|
-
case 180 /* ConstructorType */:
|
|
21607
|
-
return factory.createParenthesizedType(member);
|
|
21677
|
+
return factory.createParenthesizedType(type);
|
|
21608
21678
|
}
|
|
21609
|
-
return
|
|
21679
|
+
return parenthesizeConstituentTypeOfIntersectionType(type);
|
|
21610
21680
|
}
|
|
21611
|
-
function
|
|
21612
|
-
switch (
|
|
21613
|
-
case 181 /* TypeQuery */:
|
|
21681
|
+
function parenthesizeOperandOfReadonlyTypeOperator(type) {
|
|
21682
|
+
switch (type.kind) {
|
|
21614
21683
|
case 193 /* TypeOperator */:
|
|
21684
|
+
return factory.createParenthesizedType(type);
|
|
21685
|
+
}
|
|
21686
|
+
return parenthesizeOperandOfTypeOperator(type);
|
|
21687
|
+
}
|
|
21688
|
+
// PostfixType :
|
|
21689
|
+
// NonArrayType
|
|
21690
|
+
// NonArrayType [no LineTerminator here] `!` // JSDoc
|
|
21691
|
+
// NonArrayType [no LineTerminator here] `?` // JSDoc
|
|
21692
|
+
// IndexedAccessType
|
|
21693
|
+
// ArrayType
|
|
21694
|
+
//
|
|
21695
|
+
// IndexedAccessType :
|
|
21696
|
+
// NonArrayType `[` Type[~Extends] `]`
|
|
21697
|
+
//
|
|
21698
|
+
// ArrayType :
|
|
21699
|
+
// NonArrayType `[` `]`
|
|
21700
|
+
//
|
|
21701
|
+
function parenthesizeNonArrayTypeOfPostfixType(type) {
|
|
21702
|
+
switch (type.kind) {
|
|
21615
21703
|
case 190 /* InferType */:
|
|
21616
|
-
|
|
21704
|
+
case 193 /* TypeOperator */:
|
|
21705
|
+
case 181 /* TypeQuery */: // Not strictly necessary, but makes generated output more readable and avoids breaks in DT tests
|
|
21706
|
+
return factory.createParenthesizedType(type);
|
|
21617
21707
|
}
|
|
21618
|
-
return
|
|
21708
|
+
return parenthesizeOperandOfTypeOperator(type);
|
|
21709
|
+
}
|
|
21710
|
+
// TupleType :
|
|
21711
|
+
// `[` Elision? `]`
|
|
21712
|
+
// `[` NamedTupleElementTypes `]`
|
|
21713
|
+
// `[` NamedTupleElementTypes `,` Elision? `]`
|
|
21714
|
+
// `[` TupleElementTypes `]`
|
|
21715
|
+
// `[` TupleElementTypes `,` Elision? `]`
|
|
21716
|
+
//
|
|
21717
|
+
// NamedTupleElementTypes :
|
|
21718
|
+
// Elision? NamedTupleMember
|
|
21719
|
+
// NamedTupleElementTypes `,` Elision? NamedTupleMember
|
|
21720
|
+
//
|
|
21721
|
+
// NamedTupleMember :
|
|
21722
|
+
// Identifier `?`? `:` Type[~Extends]
|
|
21723
|
+
// `...` Identifier `:` Type[~Extends]
|
|
21724
|
+
//
|
|
21725
|
+
// TupleElementTypes :
|
|
21726
|
+
// Elision? TupleElementType
|
|
21727
|
+
// TupleElementTypes `,` Elision? TupleElementType
|
|
21728
|
+
//
|
|
21729
|
+
// TupleElementType :
|
|
21730
|
+
// Type[~Extends] // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
|
|
21731
|
+
// OptionalType
|
|
21732
|
+
// RestType
|
|
21733
|
+
//
|
|
21734
|
+
// OptionalType :
|
|
21735
|
+
// Type[~Extends] `?` // NOTE: Needs cover grammar to disallow JSDoc postfix-optional
|
|
21736
|
+
//
|
|
21737
|
+
// RestType :
|
|
21738
|
+
// `...` Type[~Extends]
|
|
21739
|
+
//
|
|
21740
|
+
function parenthesizeElementTypesOfTupleType(types) {
|
|
21741
|
+
return factory.createNodeArray(ts.sameMap(types, parenthesizeElementTypeOfTupleType));
|
|
21619
21742
|
}
|
|
21620
|
-
function
|
|
21621
|
-
|
|
21743
|
+
function parenthesizeElementTypeOfTupleType(type) {
|
|
21744
|
+
if (hasJSDocPostfixQuestion(type))
|
|
21745
|
+
return factory.createParenthesizedType(type);
|
|
21746
|
+
return type;
|
|
21747
|
+
}
|
|
21748
|
+
function hasJSDocPostfixQuestion(type) {
|
|
21749
|
+
if (ts.isJSDocNullableType(type))
|
|
21750
|
+
return type.postfix;
|
|
21751
|
+
if (ts.isNamedTupleMember(type))
|
|
21752
|
+
return hasJSDocPostfixQuestion(type.type);
|
|
21753
|
+
if (ts.isFunctionTypeNode(type) || ts.isConstructorTypeNode(type) || ts.isTypeOperatorNode(type))
|
|
21754
|
+
return hasJSDocPostfixQuestion(type.type);
|
|
21755
|
+
if (ts.isConditionalTypeNode(type))
|
|
21756
|
+
return hasJSDocPostfixQuestion(type.falseType);
|
|
21757
|
+
if (ts.isUnionTypeNode(type))
|
|
21758
|
+
return hasJSDocPostfixQuestion(ts.last(type.types));
|
|
21759
|
+
if (ts.isIntersectionTypeNode(type))
|
|
21760
|
+
return hasJSDocPostfixQuestion(ts.last(type.types));
|
|
21761
|
+
if (ts.isInferTypeNode(type))
|
|
21762
|
+
return !!type.typeParameter.constraint && hasJSDocPostfixQuestion(type.typeParameter.constraint);
|
|
21763
|
+
return false;
|
|
21764
|
+
}
|
|
21765
|
+
function parenthesizeTypeOfOptionalType(type) {
|
|
21766
|
+
if (hasJSDocPostfixQuestion(type))
|
|
21767
|
+
return factory.createParenthesizedType(type);
|
|
21768
|
+
return parenthesizeNonArrayTypeOfPostfixType(type);
|
|
21769
|
+
}
|
|
21770
|
+
// function parenthesizeMemberOfElementType(member: TypeNode): TypeNode {
|
|
21771
|
+
// switch (member.kind) {
|
|
21772
|
+
// case SyntaxKind.UnionType:
|
|
21773
|
+
// case SyntaxKind.IntersectionType:
|
|
21774
|
+
// case SyntaxKind.FunctionType:
|
|
21775
|
+
// case SyntaxKind.ConstructorType:
|
|
21776
|
+
// return factory.createParenthesizedType(member);
|
|
21777
|
+
// }
|
|
21778
|
+
// return parenthesizeMemberOfConditionalType(member);
|
|
21779
|
+
// }
|
|
21780
|
+
// function parenthesizeElementTypeOfArrayType(member: TypeNode): TypeNode {
|
|
21781
|
+
// switch (member.kind) {
|
|
21782
|
+
// case SyntaxKind.TypeQuery:
|
|
21783
|
+
// case SyntaxKind.TypeOperator:
|
|
21784
|
+
// case SyntaxKind.InferType:
|
|
21785
|
+
// return factory.createParenthesizedType(member);
|
|
21786
|
+
// }
|
|
21787
|
+
// return parenthesizeMemberOfElementType(member);
|
|
21788
|
+
// }
|
|
21789
|
+
function parenthesizeLeadingTypeArgument(node) {
|
|
21790
|
+
return ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
|
|
21622
21791
|
}
|
|
21623
21792
|
function parenthesizeOrdinalTypeArgument(node, i) {
|
|
21624
|
-
return i === 0
|
|
21793
|
+
return i === 0 ? parenthesizeLeadingTypeArgument(node) : node;
|
|
21625
21794
|
}
|
|
21626
21795
|
function parenthesizeTypeArguments(typeArguments) {
|
|
21627
21796
|
if (ts.some(typeArguments)) {
|
|
@@ -21647,11 +21816,20 @@ var ts;
|
|
|
21647
21816
|
parenthesizeExpressionForDisallowedComma: ts.identity,
|
|
21648
21817
|
parenthesizeExpressionOfExpressionStatement: ts.identity,
|
|
21649
21818
|
parenthesizeConciseBodyOfArrowFunction: ts.identity,
|
|
21650
|
-
|
|
21651
|
-
|
|
21652
|
-
|
|
21653
|
-
|
|
21819
|
+
parenthesizeCheckTypeOfConditionalType: ts.identity,
|
|
21820
|
+
parenthesizeExtendsTypeOfConditionalType: ts.identity,
|
|
21821
|
+
parenthesizeConstituentTypesOfUnionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
21822
|
+
parenthesizeConstituentTypeOfUnionType: ts.identity,
|
|
21823
|
+
parenthesizeConstituentTypesOfIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
21824
|
+
parenthesizeConstituentTypeOfIntersectionType: ts.identity,
|
|
21825
|
+
parenthesizeOperandOfTypeOperator: ts.identity,
|
|
21826
|
+
parenthesizeOperandOfReadonlyTypeOperator: ts.identity,
|
|
21827
|
+
parenthesizeNonArrayTypeOfPostfixType: ts.identity,
|
|
21828
|
+
parenthesizeElementTypesOfTupleType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
|
|
21829
|
+
parenthesizeElementTypeOfTupleType: ts.identity,
|
|
21830
|
+
parenthesizeTypeOfOptionalType: ts.identity,
|
|
21654
21831
|
parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
|
|
21832
|
+
parenthesizeLeadingTypeArgument: ts.identity,
|
|
21655
21833
|
};
|
|
21656
21834
|
})(ts || (ts = {}));
|
|
21657
21835
|
/* @internal */
|
|
@@ -21791,6 +21969,8 @@ var ts;
|
|
|
21791
21969
|
var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
|
|
21792
21970
|
var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
|
|
21793
21971
|
var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
|
|
21972
|
+
var getJSDocPrePostfixUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type, postfix) { return createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix); }; });
|
|
21973
|
+
var getJSDocPrePostfixUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocPrePostfixUnaryTypeWorker(kind, node, type); }; });
|
|
21794
21974
|
var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
|
|
21795
21975
|
var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
|
|
21796
21976
|
var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
|
|
@@ -21798,6 +21978,8 @@ var ts;
|
|
|
21798
21978
|
var factory = {
|
|
21799
21979
|
get parenthesizer() { return parenthesizerRules(); },
|
|
21800
21980
|
get converters() { return converters(); },
|
|
21981
|
+
baseFactory: baseFactory,
|
|
21982
|
+
flags: flags,
|
|
21801
21983
|
createNodeArray: createNodeArray,
|
|
21802
21984
|
createNumericLiteral: createNumericLiteral,
|
|
21803
21985
|
createBigIntLiteral: createBigIntLiteral,
|
|
@@ -22073,10 +22255,10 @@ var ts;
|
|
|
22073
22255
|
// lazily load factory members for JSDoc types with similar structure
|
|
22074
22256
|
get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(312 /* JSDocAllType */); },
|
|
22075
22257
|
get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(313 /* JSDocUnknownType */); },
|
|
22076
|
-
get createJSDocNonNullableType() { return
|
|
22077
|
-
get updateJSDocNonNullableType() { return
|
|
22078
|
-
get createJSDocNullableType() { return
|
|
22079
|
-
get updateJSDocNullableType() { return
|
|
22258
|
+
get createJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(315 /* JSDocNonNullableType */); },
|
|
22259
|
+
get updateJSDocNonNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(315 /* JSDocNonNullableType */); },
|
|
22260
|
+
get createJSDocNullableType() { return getJSDocPrePostfixUnaryTypeCreateFunction(314 /* JSDocNullableType */); },
|
|
22261
|
+
get updateJSDocNullableType() { return getJSDocPrePostfixUnaryTypeUpdateFunction(314 /* JSDocNullableType */); },
|
|
22080
22262
|
get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(316 /* JSDocOptionalType */); },
|
|
22081
22263
|
get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(316 /* JSDocOptionalType */); },
|
|
22082
22264
|
get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(318 /* JSDocVariadicType */); },
|
|
@@ -23192,7 +23374,7 @@ var ts;
|
|
|
23192
23374
|
// @api
|
|
23193
23375
|
function createArrayTypeNode(elementType) {
|
|
23194
23376
|
var node = createBaseNode(183 /* ArrayType */);
|
|
23195
|
-
node.elementType = parenthesizerRules().
|
|
23377
|
+
node.elementType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(elementType);
|
|
23196
23378
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23197
23379
|
return node;
|
|
23198
23380
|
}
|
|
@@ -23205,7 +23387,7 @@ var ts;
|
|
|
23205
23387
|
// @api
|
|
23206
23388
|
function createTupleTypeNode(elements) {
|
|
23207
23389
|
var node = createBaseNode(184 /* TupleType */);
|
|
23208
|
-
node.elements = createNodeArray(elements);
|
|
23390
|
+
node.elements = createNodeArray(parenthesizerRules().parenthesizeElementTypesOfTupleType(elements));
|
|
23209
23391
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23210
23392
|
return node;
|
|
23211
23393
|
}
|
|
@@ -23237,7 +23419,7 @@ var ts;
|
|
|
23237
23419
|
// @api
|
|
23238
23420
|
function createOptionalTypeNode(type) {
|
|
23239
23421
|
var node = createBaseNode(185 /* OptionalType */);
|
|
23240
|
-
node.type = parenthesizerRules().
|
|
23422
|
+
node.type = parenthesizerRules().parenthesizeTypeOfOptionalType(type);
|
|
23241
23423
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23242
23424
|
return node;
|
|
23243
23425
|
}
|
|
@@ -23260,38 +23442,38 @@ var ts;
|
|
|
23260
23442
|
? update(createRestTypeNode(type), node)
|
|
23261
23443
|
: node;
|
|
23262
23444
|
}
|
|
23263
|
-
function createUnionOrIntersectionTypeNode(kind, types) {
|
|
23445
|
+
function createUnionOrIntersectionTypeNode(kind, types, parenthesize) {
|
|
23264
23446
|
var node = createBaseNode(kind);
|
|
23265
|
-
node.types =
|
|
23447
|
+
node.types = factory.createNodeArray(parenthesize(types));
|
|
23266
23448
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23267
23449
|
return node;
|
|
23268
23450
|
}
|
|
23269
|
-
function updateUnionOrIntersectionTypeNode(node, types) {
|
|
23451
|
+
function updateUnionOrIntersectionTypeNode(node, types, parenthesize) {
|
|
23270
23452
|
return node.types !== types
|
|
23271
|
-
? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
|
|
23453
|
+
? update(createUnionOrIntersectionTypeNode(node.kind, types, parenthesize), node)
|
|
23272
23454
|
: node;
|
|
23273
23455
|
}
|
|
23274
23456
|
// @api
|
|
23275
23457
|
function createUnionTypeNode(types) {
|
|
23276
|
-
return createUnionOrIntersectionTypeNode(187 /* UnionType */, types);
|
|
23458
|
+
return createUnionOrIntersectionTypeNode(187 /* UnionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
|
|
23277
23459
|
}
|
|
23278
23460
|
// @api
|
|
23279
23461
|
function updateUnionTypeNode(node, types) {
|
|
23280
|
-
return updateUnionOrIntersectionTypeNode(node, types);
|
|
23462
|
+
return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfUnionType);
|
|
23281
23463
|
}
|
|
23282
23464
|
// @api
|
|
23283
23465
|
function createIntersectionTypeNode(types) {
|
|
23284
|
-
return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types);
|
|
23466
|
+
return createUnionOrIntersectionTypeNode(188 /* IntersectionType */, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
|
|
23285
23467
|
}
|
|
23286
23468
|
// @api
|
|
23287
23469
|
function updateIntersectionTypeNode(node, types) {
|
|
23288
|
-
return updateUnionOrIntersectionTypeNode(node, types);
|
|
23470
|
+
return updateUnionOrIntersectionTypeNode(node, types, parenthesizerRules().parenthesizeConstituentTypesOfIntersectionType);
|
|
23289
23471
|
}
|
|
23290
23472
|
// @api
|
|
23291
23473
|
function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
|
|
23292
23474
|
var node = createBaseNode(189 /* ConditionalType */);
|
|
23293
|
-
node.checkType = parenthesizerRules().
|
|
23294
|
-
node.extendsType = parenthesizerRules().
|
|
23475
|
+
node.checkType = parenthesizerRules().parenthesizeCheckTypeOfConditionalType(checkType);
|
|
23476
|
+
node.extendsType = parenthesizerRules().parenthesizeExtendsTypeOfConditionalType(extendsType);
|
|
23295
23477
|
node.trueType = trueType;
|
|
23296
23478
|
node.falseType = falseType;
|
|
23297
23479
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
@@ -23386,7 +23568,9 @@ var ts;
|
|
|
23386
23568
|
function createTypeOperatorNode(operator, type) {
|
|
23387
23569
|
var node = createBaseNode(193 /* TypeOperator */);
|
|
23388
23570
|
node.operator = operator;
|
|
23389
|
-
node.type =
|
|
23571
|
+
node.type = operator === 145 /* ReadonlyKeyword */ ?
|
|
23572
|
+
parenthesizerRules().parenthesizeOperandOfReadonlyTypeOperator(type) :
|
|
23573
|
+
parenthesizerRules().parenthesizeOperandOfTypeOperator(type);
|
|
23390
23574
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23391
23575
|
return node;
|
|
23392
23576
|
}
|
|
@@ -23399,7 +23583,7 @@ var ts;
|
|
|
23399
23583
|
// @api
|
|
23400
23584
|
function createIndexedAccessTypeNode(objectType, indexType) {
|
|
23401
23585
|
var node = createBaseNode(194 /* IndexedAccessType */);
|
|
23402
|
-
node.objectType = parenthesizerRules().
|
|
23586
|
+
node.objectType = parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(objectType);
|
|
23403
23587
|
node.indexType = indexType;
|
|
23404
23588
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
23405
23589
|
return node;
|
|
@@ -25135,8 +25319,15 @@ var ts;
|
|
|
25135
25319
|
return createBaseNode(kind);
|
|
25136
25320
|
}
|
|
25137
25321
|
// @api
|
|
25138
|
-
// createJSDocNonNullableType
|
|
25139
25322
|
// createJSDocNullableType
|
|
25323
|
+
// createJSDocNonNullableType
|
|
25324
|
+
function createJSDocPrePostfixUnaryTypeWorker(kind, type, postfix) {
|
|
25325
|
+
if (postfix === void 0) { postfix = false; }
|
|
25326
|
+
var node = createJSDocUnaryTypeWorker(kind, postfix ? type && parenthesizerRules().parenthesizeNonArrayTypeOfPostfixType(type) : type);
|
|
25327
|
+
node.postfix = postfix;
|
|
25328
|
+
return node;
|
|
25329
|
+
}
|
|
25330
|
+
// @api
|
|
25140
25331
|
// createJSDocOptionalType
|
|
25141
25332
|
// createJSDocVariadicType
|
|
25142
25333
|
// createJSDocNamepathType
|
|
@@ -25148,6 +25339,12 @@ var ts;
|
|
|
25148
25339
|
// @api
|
|
25149
25340
|
// updateJSDocNonNullableType
|
|
25150
25341
|
// updateJSDocNullableType
|
|
25342
|
+
function updateJSDocPrePostfixUnaryTypeWorker(kind, node, type) {
|
|
25343
|
+
return node.type !== type
|
|
25344
|
+
? update(createJSDocPrePostfixUnaryTypeWorker(kind, type, node.postfix), node)
|
|
25345
|
+
: node;
|
|
25346
|
+
}
|
|
25347
|
+
// @api
|
|
25151
25348
|
// updateJSDocOptionalType
|
|
25152
25349
|
// updateJSDocVariadicType
|
|
25153
25350
|
// updateJSDocNamepathType
|
|
@@ -30228,7 +30425,7 @@ var ts;
|
|
|
30228
30425
|
|| ts.isExportDeclaration(node) ? node : undefined;
|
|
30229
30426
|
}
|
|
30230
30427
|
function getImportMetaIfNecessary(sourceFile) {
|
|
30231
|
-
return sourceFile.flags &
|
|
30428
|
+
return sourceFile.flags & 4194304 /* PossiblyContainsImportMeta */ ?
|
|
30232
30429
|
walkTreeForImportMeta(sourceFile) :
|
|
30233
30430
|
undefined;
|
|
30234
30431
|
}
|
|
@@ -30883,7 +31080,7 @@ var ts;
|
|
|
30883
31080
|
var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
|
|
30884
31081
|
// Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import.
|
|
30885
31082
|
// We will manually port the flag to the new source file.
|
|
30886
|
-
newSourceFile.flags |= (sourceFile.flags &
|
|
31083
|
+
newSourceFile.flags |= (sourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */);
|
|
30887
31084
|
return newSourceFile;
|
|
30888
31085
|
}
|
|
30889
31086
|
ts.updateSourceFile = updateSourceFile;
|
|
@@ -31167,10 +31364,10 @@ var ts;
|
|
|
31167
31364
|
switch (scriptKind) {
|
|
31168
31365
|
case 1 /* JS */:
|
|
31169
31366
|
case 2 /* JSX */:
|
|
31170
|
-
contextFlags =
|
|
31367
|
+
contextFlags = 262144 /* JavaScriptFile */;
|
|
31171
31368
|
break;
|
|
31172
31369
|
case 6 /* JSON */:
|
|
31173
|
-
contextFlags =
|
|
31370
|
+
contextFlags = 262144 /* JavaScriptFile */ | 67108864 /* JsonFile */;
|
|
31174
31371
|
break;
|
|
31175
31372
|
default:
|
|
31176
31373
|
contextFlags = 0 /* None */;
|
|
@@ -31205,7 +31402,7 @@ var ts;
|
|
|
31205
31402
|
function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
|
|
31206
31403
|
var isDeclarationFile = isDeclarationFileName(fileName);
|
|
31207
31404
|
if (isDeclarationFile) {
|
|
31208
|
-
contextFlags |=
|
|
31405
|
+
contextFlags |= 16777216 /* Ambient */;
|
|
31209
31406
|
}
|
|
31210
31407
|
sourceFlags = contextFlags;
|
|
31211
31408
|
// Prime the scanner.
|
|
@@ -31244,7 +31441,7 @@ var ts;
|
|
|
31244
31441
|
node.jsDoc = jsDoc;
|
|
31245
31442
|
if (hasDeprecatedTag) {
|
|
31246
31443
|
hasDeprecatedTag = false;
|
|
31247
|
-
node.flags |=
|
|
31444
|
+
node.flags |= 268435456 /* Deprecated */;
|
|
31248
31445
|
}
|
|
31249
31446
|
return node;
|
|
31250
31447
|
}
|
|
@@ -31439,6 +31636,12 @@ var ts;
|
|
|
31439
31636
|
function disallowInAnd(func) {
|
|
31440
31637
|
return doInsideOfContext(4096 /* DisallowInContext */, func);
|
|
31441
31638
|
}
|
|
31639
|
+
function allowConditionalTypesAnd(func) {
|
|
31640
|
+
return doOutsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
|
|
31641
|
+
}
|
|
31642
|
+
function disallowConditionalTypesAnd(func) {
|
|
31643
|
+
return doInsideOfContext(65536 /* DisallowConditionalTypesContext */, func);
|
|
31644
|
+
}
|
|
31442
31645
|
function doInYieldContext(func) {
|
|
31443
31646
|
return doInsideOfContext(8192 /* YieldContext */, func);
|
|
31444
31647
|
}
|
|
@@ -31466,6 +31669,9 @@ var ts;
|
|
|
31466
31669
|
function inDisallowInContext() {
|
|
31467
31670
|
return inContext(4096 /* DisallowInContext */);
|
|
31468
31671
|
}
|
|
31672
|
+
function inDisallowConditionalTypesContext() {
|
|
31673
|
+
return inContext(65536 /* DisallowConditionalTypesContext */);
|
|
31674
|
+
}
|
|
31469
31675
|
function inDecoratorContext() {
|
|
31470
31676
|
return inContext(16384 /* DecoratorContext */);
|
|
31471
31677
|
}
|
|
@@ -31850,7 +32056,7 @@ var ts;
|
|
|
31850
32056
|
// flag so that we don't mark any subsequent nodes.
|
|
31851
32057
|
if (parseErrorBeforeNextFinishedNode) {
|
|
31852
32058
|
parseErrorBeforeNextFinishedNode = false;
|
|
31853
|
-
node.flags |=
|
|
32059
|
+
node.flags |= 131072 /* ThisNodeHasError */;
|
|
31854
32060
|
}
|
|
31855
32061
|
return node;
|
|
31856
32062
|
}
|
|
@@ -32308,7 +32514,7 @@ var ts;
|
|
|
32308
32514
|
// differently depending on what mode it is in.
|
|
32309
32515
|
//
|
|
32310
32516
|
// This also applies to all our other context flags as well.
|
|
32311
|
-
var nodeContextFlags = node.flags &
|
|
32517
|
+
var nodeContextFlags = node.flags & 50720768 /* ContextFlags */;
|
|
32312
32518
|
if (nodeContextFlags !== contextFlags) {
|
|
32313
32519
|
return undefined;
|
|
32314
32520
|
}
|
|
@@ -32833,7 +33039,7 @@ var ts;
|
|
|
32833
33039
|
function parseJSDocNonNullableType() {
|
|
32834
33040
|
var pos = getNodePos();
|
|
32835
33041
|
nextToken();
|
|
32836
|
-
return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
|
|
33042
|
+
return finishNode(factory.createJSDocNonNullableType(parseNonArrayType(), /*postfix*/ false), pos);
|
|
32837
33043
|
}
|
|
32838
33044
|
function parseJSDocUnknownOrNullableType() {
|
|
32839
33045
|
var pos = getNodePos();
|
|
@@ -32857,7 +33063,7 @@ var ts;
|
|
|
32857
33063
|
return finishNode(factory.createJSDocUnknownType(), pos);
|
|
32858
33064
|
}
|
|
32859
33065
|
else {
|
|
32860
|
-
return finishNode(factory.createJSDocNullableType(parseType()), pos);
|
|
33066
|
+
return finishNode(factory.createJSDocNullableType(parseType(), /*postfix*/ false), pos);
|
|
32861
33067
|
}
|
|
32862
33068
|
}
|
|
32863
33069
|
function parseJSDocFunctionType() {
|
|
@@ -33029,7 +33235,7 @@ var ts;
|
|
|
33029
33235
|
}
|
|
33030
33236
|
function parseReturnType(returnToken, isType) {
|
|
33031
33237
|
if (shouldParseReturnType(returnToken, isType)) {
|
|
33032
|
-
return parseTypeOrTypePredicate
|
|
33238
|
+
return allowConditionalTypesAnd(parseTypeOrTypePredicate);
|
|
33033
33239
|
}
|
|
33034
33240
|
}
|
|
33035
33241
|
function shouldParseReturnType(returnToken, isType) {
|
|
@@ -33444,7 +33650,7 @@ var ts;
|
|
|
33444
33650
|
return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
|
|
33445
33651
|
}
|
|
33446
33652
|
function parseImportType() {
|
|
33447
|
-
sourceFlags |=
|
|
33653
|
+
sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
|
|
33448
33654
|
var pos = getNodePos();
|
|
33449
33655
|
var isTypeOf = parseOptional(112 /* TypeOfKeyword */);
|
|
33450
33656
|
parseExpected(100 /* ImportKeyword */);
|
|
@@ -33594,7 +33800,7 @@ var ts;
|
|
|
33594
33800
|
switch (token()) {
|
|
33595
33801
|
case 53 /* ExclamationToken */:
|
|
33596
33802
|
nextToken();
|
|
33597
|
-
type = finishNode(factory.createJSDocNonNullableType(type), pos);
|
|
33803
|
+
type = finishNode(factory.createJSDocNonNullableType(type, /*postfix*/ true), pos);
|
|
33598
33804
|
break;
|
|
33599
33805
|
case 57 /* QuestionToken */:
|
|
33600
33806
|
// If next token is start of a type we have a conditional type
|
|
@@ -33602,7 +33808,7 @@ var ts;
|
|
|
33602
33808
|
return type;
|
|
33603
33809
|
}
|
|
33604
33810
|
nextToken();
|
|
33605
|
-
type = finishNode(factory.createJSDocNullableType(type), pos);
|
|
33811
|
+
type = finishNode(factory.createJSDocNullableType(type, /*postfix*/ true), pos);
|
|
33606
33812
|
break;
|
|
33607
33813
|
case 22 /* OpenBracketToken */:
|
|
33608
33814
|
parseExpected(22 /* OpenBracketToken */);
|
|
@@ -33627,12 +33833,20 @@ var ts;
|
|
|
33627
33833
|
parseExpected(operator);
|
|
33628
33834
|
return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
|
|
33629
33835
|
}
|
|
33836
|
+
function tryParseConstraintOfInferType() {
|
|
33837
|
+
if (parseOptional(94 /* ExtendsKeyword */)) {
|
|
33838
|
+
var constraint = disallowConditionalTypesAnd(parseType);
|
|
33839
|
+
if (inDisallowConditionalTypesContext() || token() !== 57 /* QuestionToken */) {
|
|
33840
|
+
return constraint;
|
|
33841
|
+
}
|
|
33842
|
+
}
|
|
33843
|
+
}
|
|
33630
33844
|
function parseTypeParameterOfInferType() {
|
|
33631
33845
|
var pos = getNodePos();
|
|
33632
|
-
|
|
33633
|
-
|
|
33634
|
-
/*
|
|
33635
|
-
|
|
33846
|
+
var name = parseIdentifier();
|
|
33847
|
+
var constraint = tryParse(tryParseConstraintOfInferType);
|
|
33848
|
+
var node = factory.createTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint);
|
|
33849
|
+
return finishNode(node, pos);
|
|
33636
33850
|
}
|
|
33637
33851
|
function parseInferType() {
|
|
33638
33852
|
var pos = getNodePos();
|
|
@@ -33649,7 +33863,7 @@ var ts;
|
|
|
33649
33863
|
case 137 /* InferKeyword */:
|
|
33650
33864
|
return parseInferType();
|
|
33651
33865
|
}
|
|
33652
|
-
return parsePostfixTypeOrHigher
|
|
33866
|
+
return allowConditionalTypesAnd(parsePostfixTypeOrHigher);
|
|
33653
33867
|
}
|
|
33654
33868
|
function parseFunctionOrConstructorTypeToError(isInUnionType) {
|
|
33655
33869
|
// the function type and constructor type shorthand notation
|
|
@@ -33779,23 +33993,21 @@ var ts;
|
|
|
33779
33993
|
return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
|
|
33780
33994
|
}
|
|
33781
33995
|
function parseType() {
|
|
33782
|
-
|
|
33783
|
-
|
|
33784
|
-
|
|
33785
|
-
}
|
|
33786
|
-
function parseTypeWorker(noConditionalTypes) {
|
|
33996
|
+
if (contextFlags & 40960 /* TypeExcludesFlags */) {
|
|
33997
|
+
return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseType);
|
|
33998
|
+
}
|
|
33787
33999
|
if (isStartOfFunctionTypeOrConstructorType()) {
|
|
33788
34000
|
return parseFunctionOrConstructorType();
|
|
33789
34001
|
}
|
|
33790
34002
|
var pos = getNodePos();
|
|
33791
34003
|
var type = parseUnionTypeOrHigher();
|
|
33792
|
-
if (!
|
|
34004
|
+
if (!inDisallowConditionalTypesContext() && !scanner.hasPrecedingLineBreak() && parseOptional(94 /* ExtendsKeyword */)) {
|
|
33793
34005
|
// The type following 'extends' is not permitted to be another conditional type
|
|
33794
|
-
var extendsType =
|
|
34006
|
+
var extendsType = disallowConditionalTypesAnd(parseType);
|
|
33795
34007
|
parseExpected(57 /* QuestionToken */);
|
|
33796
|
-
var trueType =
|
|
34008
|
+
var trueType = allowConditionalTypesAnd(parseType);
|
|
33797
34009
|
parseExpected(58 /* ColonToken */);
|
|
33798
|
-
var falseType =
|
|
34010
|
+
var falseType = allowConditionalTypesAnd(parseType);
|
|
33799
34011
|
return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
|
|
33800
34012
|
}
|
|
33801
34013
|
return type;
|
|
@@ -34632,7 +34844,7 @@ var ts;
|
|
|
34632
34844
|
// var foo3 = require("subfolder
|
|
34633
34845
|
// import * as foo1 from "module-from-node
|
|
34634
34846
|
// We want this import to be a statement rather than import call expression
|
|
34635
|
-
sourceFlags |=
|
|
34847
|
+
sourceFlags |= 2097152 /* PossiblyContainsDynamicImport */;
|
|
34636
34848
|
expression = parseTokenNode();
|
|
34637
34849
|
}
|
|
34638
34850
|
else if (lookAhead(nextTokenIsDot)) {
|
|
@@ -34640,7 +34852,7 @@ var ts;
|
|
|
34640
34852
|
nextToken(); // advance past the 'import'
|
|
34641
34853
|
nextToken(); // advance past the dot
|
|
34642
34854
|
expression = finishNode(factory.createMetaProperty(100 /* ImportKeyword */, parseIdentifierName()), pos);
|
|
34643
|
-
sourceFlags |=
|
|
34855
|
+
sourceFlags |= 4194304 /* PossiblyContainsImportMeta */;
|
|
34644
34856
|
}
|
|
34645
34857
|
else {
|
|
34646
34858
|
expression = parseMemberExpressionOrHigher();
|
|
@@ -34856,7 +35068,7 @@ var ts;
|
|
|
34856
35068
|
return finishNode(factory.createJsxOpeningFragment(), pos);
|
|
34857
35069
|
}
|
|
34858
35070
|
var tagName = parseJsxElementName();
|
|
34859
|
-
var typeArguments = (contextFlags &
|
|
35071
|
+
var typeArguments = (contextFlags & 262144 /* JavaScriptFile */) === 0 ? tryParseTypeArguments() : undefined;
|
|
34860
35072
|
var attributes = parseJsxAttributes();
|
|
34861
35073
|
var node;
|
|
34862
35074
|
if (token() === 31 /* GreaterThanToken */) {
|
|
@@ -35134,7 +35346,7 @@ var ts;
|
|
|
35134
35346
|
return result;
|
|
35135
35347
|
}
|
|
35136
35348
|
function parseTypeArgumentsInExpression() {
|
|
35137
|
-
if ((contextFlags &
|
|
35349
|
+
if ((contextFlags & 262144 /* JavaScriptFile */) !== 0) {
|
|
35138
35350
|
// TypeArguments must not be parsed in JavaScript files to avoid ambiguity with binary operators.
|
|
35139
35351
|
return undefined;
|
|
35140
35352
|
}
|
|
@@ -35530,7 +35742,7 @@ var ts;
|
|
|
35530
35742
|
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35531
35743
|
var expression = allowInAnd(parseExpression);
|
|
35532
35744
|
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35533
|
-
var statement = doInsideOfContext(
|
|
35745
|
+
var statement = doInsideOfContext(33554432 /* InWithStatement */, parseStatement);
|
|
35534
35746
|
return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
|
|
35535
35747
|
}
|
|
35536
35748
|
function parseCaseClause() {
|
|
@@ -35905,16 +36117,16 @@ var ts;
|
|
|
35905
36117
|
if (isAmbient) {
|
|
35906
36118
|
for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
|
|
35907
36119
|
var m = _a[_i];
|
|
35908
|
-
m.flags |=
|
|
36120
|
+
m.flags |= 16777216 /* Ambient */;
|
|
35909
36121
|
}
|
|
35910
|
-
return doInsideOfContext(
|
|
36122
|
+
return doInsideOfContext(16777216 /* Ambient */, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
|
|
35911
36123
|
}
|
|
35912
36124
|
else {
|
|
35913
36125
|
return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
|
|
35914
36126
|
}
|
|
35915
36127
|
}
|
|
35916
36128
|
function tryReuseAmbientDeclaration() {
|
|
35917
|
-
return doInsideOfContext(
|
|
36129
|
+
return doInsideOfContext(16777216 /* Ambient */, function () {
|
|
35918
36130
|
var node = currentNode(parsingContext);
|
|
35919
36131
|
if (node) {
|
|
35920
36132
|
return consumeNode(node);
|
|
@@ -36381,9 +36593,9 @@ var ts;
|
|
|
36381
36593
|
if (isAmbient) {
|
|
36382
36594
|
for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
|
|
36383
36595
|
var m = _a[_i];
|
|
36384
|
-
m.flags |=
|
|
36596
|
+
m.flags |= 16777216 /* Ambient */;
|
|
36385
36597
|
}
|
|
36386
|
-
return doInsideOfContext(
|
|
36598
|
+
return doInsideOfContext(16777216 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
|
|
36387
36599
|
}
|
|
36388
36600
|
else {
|
|
36389
36601
|
return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
|
|
@@ -36948,7 +37160,7 @@ var ts;
|
|
|
36948
37160
|
function parseJSDocTypeExpression(mayOmitBraces) {
|
|
36949
37161
|
var pos = getNodePos();
|
|
36950
37162
|
var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */);
|
|
36951
|
-
var type = doInsideOfContext(
|
|
37163
|
+
var type = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
|
|
36952
37164
|
if (!mayOmitBraces || hasBrace) {
|
|
36953
37165
|
parseExpectedJSDoc(19 /* CloseBraceToken */);
|
|
36954
37166
|
}
|
|
@@ -36977,7 +37189,7 @@ var ts;
|
|
|
36977
37189
|
JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
|
|
36978
37190
|
function parseIsolatedJSDocComment(content, start, length) {
|
|
36979
37191
|
initializeState("", content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */);
|
|
36980
|
-
var jsDoc = doInsideOfContext(
|
|
37192
|
+
var jsDoc = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
|
|
36981
37193
|
var sourceFile = { languageVariant: 0 /* Standard */, text: content };
|
|
36982
37194
|
var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
|
|
36983
37195
|
clearState();
|
|
@@ -36988,9 +37200,9 @@ var ts;
|
|
|
36988
37200
|
var saveToken = currentToken;
|
|
36989
37201
|
var saveParseDiagnosticsLength = parseDiagnostics.length;
|
|
36990
37202
|
var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
|
|
36991
|
-
var comment = doInsideOfContext(
|
|
37203
|
+
var comment = doInsideOfContext(8388608 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); });
|
|
36992
37204
|
ts.setParent(comment, parent);
|
|
36993
|
-
if (contextFlags &
|
|
37205
|
+
if (contextFlags & 262144 /* JavaScriptFile */) {
|
|
36994
37206
|
if (!jsDocDiagnostics) {
|
|
36995
37207
|
jsDocDiagnostics = [];
|
|
36996
37208
|
}
|
|
@@ -37806,7 +38018,7 @@ var ts;
|
|
|
37806
38018
|
if (isBracketed) {
|
|
37807
38019
|
skipWhitespace();
|
|
37808
38020
|
parseExpected(63 /* EqualsToken */);
|
|
37809
|
-
defaultType = doInsideOfContext(
|
|
38021
|
+
defaultType = doInsideOfContext(8388608 /* JSDoc */, parseJSDocType);
|
|
37810
38022
|
parseExpected(23 /* CloseBracketToken */);
|
|
37811
38023
|
}
|
|
37812
38024
|
if (ts.nodeIsMissing(name)) {
|
|
@@ -45694,7 +45906,7 @@ var ts;
|
|
|
45694
45906
|
function setExportContextFlag(node) {
|
|
45695
45907
|
// A declaration source file or ambient module declaration that contains no export declarations (but possibly regular
|
|
45696
45908
|
// declarations with export modifiers) is an export context in which declarations are implicitly exported.
|
|
45697
|
-
if (node.flags &
|
|
45909
|
+
if (node.flags & 16777216 /* Ambient */ && !hasExportDeclarations(node)) {
|
|
45698
45910
|
node.flags |= 64 /* ExportContext */;
|
|
45699
45911
|
}
|
|
45700
45912
|
else {
|
|
@@ -45897,8 +46109,8 @@ var ts;
|
|
|
45897
46109
|
function checkContextualIdentifier(node) {
|
|
45898
46110
|
// Report error only if there are no parse errors in file
|
|
45899
46111
|
if (!file.parseDiagnostics.length &&
|
|
45900
|
-
!(node.flags &
|
|
45901
|
-
!(node.flags &
|
|
46112
|
+
!(node.flags & 16777216 /* Ambient */) &&
|
|
46113
|
+
!(node.flags & 8388608 /* JSDoc */) &&
|
|
45902
46114
|
!ts.isIdentifierName(node)) {
|
|
45903
46115
|
// strict mode identifiers
|
|
45904
46116
|
if (inStrictMode &&
|
|
@@ -46927,7 +47139,7 @@ var ts;
|
|
|
46927
47139
|
if (node.kind === 340 /* JSDocParameterTag */ && container.kind !== 323 /* JSDocSignature */) {
|
|
46928
47140
|
return;
|
|
46929
47141
|
}
|
|
46930
|
-
if (inStrictMode && !(node.flags &
|
|
47142
|
+
if (inStrictMode && !(node.flags & 16777216 /* Ambient */)) {
|
|
46931
47143
|
// It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a
|
|
46932
47144
|
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
|
|
46933
47145
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
@@ -46946,7 +47158,7 @@ var ts;
|
|
|
46946
47158
|
}
|
|
46947
47159
|
}
|
|
46948
47160
|
function bindFunctionDeclaration(node) {
|
|
46949
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47161
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
|
|
46950
47162
|
if (ts.isAsyncFunction(node)) {
|
|
46951
47163
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
46952
47164
|
}
|
|
@@ -46961,7 +47173,7 @@ var ts;
|
|
|
46961
47173
|
}
|
|
46962
47174
|
}
|
|
46963
47175
|
function bindFunctionExpression(node) {
|
|
46964
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47176
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */)) {
|
|
46965
47177
|
if (ts.isAsyncFunction(node)) {
|
|
46966
47178
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
46967
47179
|
}
|
|
@@ -46974,7 +47186,7 @@ var ts;
|
|
|
46974
47186
|
return bindAnonymousDeclaration(node, 16 /* Function */, bindingName);
|
|
46975
47187
|
}
|
|
46976
47188
|
function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
|
|
46977
|
-
if (!file.isDeclarationFile && !(node.flags &
|
|
47189
|
+
if (!file.isDeclarationFile && !(node.flags & 16777216 /* Ambient */) && ts.isAsyncFunction(node)) {
|
|
46978
47190
|
emitFlags |= 2048 /* HasAsyncFunctions */;
|
|
46979
47191
|
}
|
|
46980
47192
|
if (currentFlow && ts.isObjectLiteralOrClassExpressionMethodOrAccessor(node)) {
|
|
@@ -47047,7 +47259,7 @@ var ts;
|
|
|
47047
47259
|
// Rationale: we don't want to report errors on non-initialized var's since they are hoisted
|
|
47048
47260
|
// On the other side we do want to report errors on non-initialized 'lets' because of TDZ
|
|
47049
47261
|
var isError_1 = ts.unreachableCodeIsError(options) &&
|
|
47050
|
-
!(node.flags &
|
|
47262
|
+
!(node.flags & 16777216 /* Ambient */) &&
|
|
47051
47263
|
(!ts.isVariableStatement(node) ||
|
|
47052
47264
|
!!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) ||
|
|
47053
47265
|
node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
|
|
@@ -47947,7 +48159,7 @@ var ts;
|
|
|
47947
48159
|
ts.Debug.assert(!!(getNodeLinks(file).flags & 1 /* TypeChecked */));
|
|
47948
48160
|
diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
|
|
47949
48161
|
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
|
|
47950
|
-
if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags &
|
|
48162
|
+
if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
|
|
47951
48163
|
(diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
|
|
47952
48164
|
}
|
|
47953
48165
|
});
|
|
@@ -48398,7 +48610,7 @@ var ts;
|
|
|
48398
48610
|
return diagnostic;
|
|
48399
48611
|
}
|
|
48400
48612
|
function isDeprecatedSymbol(symbol) {
|
|
48401
|
-
return !!(getDeclarationNodeFlagsFromSymbol(symbol) &
|
|
48613
|
+
return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 268435456 /* Deprecated */);
|
|
48402
48614
|
}
|
|
48403
48615
|
function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
|
|
48404
48616
|
var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
|
|
@@ -48626,7 +48838,7 @@ var ts;
|
|
|
48626
48838
|
else {
|
|
48627
48839
|
// find a module that about to be augmented
|
|
48628
48840
|
// do not validate names of augmentations that are defined in ambient context
|
|
48629
|
-
var moduleNotFoundError = !(moduleName.parent.parent.flags &
|
|
48841
|
+
var moduleNotFoundError = !(moduleName.parent.parent.flags & 16777216 /* Ambient */)
|
|
48630
48842
|
? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
|
|
48631
48843
|
: undefined;
|
|
48632
48844
|
var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true);
|
|
@@ -48740,7 +48952,7 @@ var ts;
|
|
|
48740
48952
|
if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
|
|
48741
48953
|
(!ts.outFile(compilerOptions)) ||
|
|
48742
48954
|
isInTypeQuery(usage) ||
|
|
48743
|
-
declaration.flags &
|
|
48955
|
+
declaration.flags & 16777216 /* Ambient */) {
|
|
48744
48956
|
// nodes are in different files and order cannot be determined
|
|
48745
48957
|
return true;
|
|
48746
48958
|
}
|
|
@@ -48802,7 +49014,7 @@ var ts;
|
|
|
48802
49014
|
if (usage.kind === 271 /* ExportAssignment */ && usage.isExportEquals) {
|
|
48803
49015
|
return true;
|
|
48804
49016
|
}
|
|
48805
|
-
if (!!(usage.flags &
|
|
49017
|
+
if (!!(usage.flags & 8388608 /* JSDoc */) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
|
|
48806
49018
|
return true;
|
|
48807
49019
|
}
|
|
48808
49020
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
@@ -49067,7 +49279,7 @@ var ts;
|
|
|
49067
49279
|
// falls through
|
|
49068
49280
|
case 261 /* ModuleDeclaration */:
|
|
49069
49281
|
var moduleExports = ((_a = getSymbolOfNode(location)) === null || _a === void 0 ? void 0 : _a.exports) || emptySymbols;
|
|
49070
|
-
if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags &
|
|
49282
|
+
if (location.kind === 305 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 16777216 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) {
|
|
49071
49283
|
// It's an external module. First see if the module has an export default and if the local
|
|
49072
49284
|
// name of that export default matches.
|
|
49073
49285
|
if (result = moduleExports.get("default" /* Default */)) {
|
|
@@ -49390,7 +49602,7 @@ var ts;
|
|
|
49390
49602
|
}
|
|
49391
49603
|
}
|
|
49392
49604
|
// If we're in an external module, we can't reference value symbols created from UMD export declarations
|
|
49393
|
-
if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags &
|
|
49605
|
+
if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 8388608 /* JSDoc */)) {
|
|
49394
49606
|
var merged = getMergedSymbol(result);
|
|
49395
49607
|
if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
|
|
49396
49608
|
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));
|
|
@@ -49645,7 +49857,7 @@ var ts;
|
|
|
49645
49857
|
var declaration = (_a = result.declarations) === null || _a === void 0 ? void 0 : _a.find(function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 260 /* EnumDeclaration */); });
|
|
49646
49858
|
if (declaration === undefined)
|
|
49647
49859
|
return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
|
|
49648
|
-
if (!(declaration.flags &
|
|
49860
|
+
if (!(declaration.flags & 16777216 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
|
|
49649
49861
|
var diagnosticMessage = void 0;
|
|
49650
49862
|
var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
|
|
49651
49863
|
if (result.flags & 2 /* BlockScopedVariable */) {
|
|
@@ -50418,7 +50630,7 @@ var ts;
|
|
|
50418
50630
|
}
|
|
50419
50631
|
}
|
|
50420
50632
|
function getAssignmentDeclarationLocation(node) {
|
|
50421
|
-
var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags &
|
|
50633
|
+
var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 8388608 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); });
|
|
50422
50634
|
if (typeAlias) {
|
|
50423
50635
|
return;
|
|
50424
50636
|
}
|
|
@@ -51886,7 +52098,20 @@ var ts;
|
|
|
51886
52098
|
if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
|
|
51887
52099
|
if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) {
|
|
51888
52100
|
context.approximateLength += (ts.symbolName(type.symbol).length + 6);
|
|
51889
|
-
|
|
52101
|
+
var constraintNode = void 0;
|
|
52102
|
+
var constraint = getConstraintOfTypeParameter(type);
|
|
52103
|
+
if (constraint) {
|
|
52104
|
+
// If the infer type has a constraint that is not the same as the constraint
|
|
52105
|
+
// we would have normally inferred based on context, we emit the constraint
|
|
52106
|
+
// using `infer T extends ?`. We omit inferred constraints from type references
|
|
52107
|
+
// as they may be elided.
|
|
52108
|
+
var inferredConstraint = getInferredTypeParameterConstraint(type, /*omitTypeReferences*/ true);
|
|
52109
|
+
if (!(inferredConstraint && isTypeIdenticalTo(constraint, inferredConstraint))) {
|
|
52110
|
+
context.approximateLength += 9;
|
|
52111
|
+
constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
|
|
52112
|
+
}
|
|
52113
|
+
}
|
|
52114
|
+
return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, constraintNode));
|
|
51890
52115
|
}
|
|
51891
52116
|
if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ &&
|
|
51892
52117
|
type.flags & 262144 /* TypeParameter */ &&
|
|
@@ -53842,7 +54067,7 @@ var ts;
|
|
|
53842
54067
|
newModifierFlags |= 1 /* Export */;
|
|
53843
54068
|
}
|
|
53844
54069
|
if (addingDeclare && !(newModifierFlags & 1 /* Export */) &&
|
|
53845
|
-
(!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags &
|
|
54070
|
+
(!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 16777216 /* Ambient */)) &&
|
|
53846
54071
|
(ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
|
|
53847
54072
|
// Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope
|
|
53848
54073
|
newModifierFlags |= 2 /* Ambient */;
|
|
@@ -54812,7 +55037,7 @@ var ts;
|
|
|
54812
55037
|
var parent = getDeclarationContainer(node);
|
|
54813
55038
|
// If the node is not exported or it is not ambient module element (except import declaration)
|
|
54814
55039
|
if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) &&
|
|
54815
|
-
!(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags &
|
|
55040
|
+
!(node.kind !== 265 /* ImportEqualsDeclaration */ && parent.kind !== 305 /* SourceFile */ && parent.flags & 16777216 /* Ambient */)) {
|
|
54816
55041
|
return isGlobalSourceFile(parent);
|
|
54817
55042
|
}
|
|
54818
55043
|
// Exported members/ambient module elements (exception import declaration) are visible if parent is visible
|
|
@@ -55152,7 +55377,7 @@ var ts;
|
|
|
55152
55377
|
}
|
|
55153
55378
|
var pattern = declaration.parent;
|
|
55154
55379
|
// Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation
|
|
55155
|
-
if (strictNullChecks && declaration.flags &
|
|
55380
|
+
if (strictNullChecks && declaration.flags & 16777216 /* Ambient */ && ts.isParameterDeclaration(declaration)) {
|
|
55156
55381
|
parentType = getNonNullableType(parentType);
|
|
55157
55382
|
}
|
|
55158
55383
|
// Filter `undefined` from the type we check against if the parent has an initializer and that initializer is not possibly `undefined`
|
|
@@ -55268,7 +55493,7 @@ var ts;
|
|
|
55268
55493
|
}
|
|
55269
55494
|
if ((noImplicitAny || ts.isInJSFile(declaration)) &&
|
|
55270
55495
|
ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
|
|
55271
|
-
!(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags &
|
|
55496
|
+
!(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 16777216 /* Ambient */)) {
|
|
55272
55497
|
// If --noImplicitAny is on or the declaration is in a Javascript file,
|
|
55273
55498
|
// use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no
|
|
55274
55499
|
// initializer or a 'null' or 'undefined' initializer.
|
|
@@ -56724,7 +56949,7 @@ var ts;
|
|
|
56724
56949
|
function isLiteralEnumMember(member) {
|
|
56725
56950
|
var expr = member.initializer;
|
|
56726
56951
|
if (!expr) {
|
|
56727
|
-
return !(member.flags &
|
|
56952
|
+
return !(member.flags & 16777216 /* Ambient */);
|
|
56728
56953
|
}
|
|
56729
56954
|
switch (expr.kind) {
|
|
56730
56955
|
case 10 /* StringLiteral */:
|
|
@@ -59357,7 +59582,7 @@ var ts;
|
|
|
59357
59582
|
function getConstraintDeclaration(type) {
|
|
59358
59583
|
return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
|
|
59359
59584
|
}
|
|
59360
|
-
function getInferredTypeParameterConstraint(typeParameter) {
|
|
59585
|
+
function getInferredTypeParameterConstraint(typeParameter, omitTypeReferences) {
|
|
59361
59586
|
var _a;
|
|
59362
59587
|
var inferences;
|
|
59363
59588
|
if ((_a = typeParameter.symbol) === null || _a === void 0 ? void 0 : _a.declarations) {
|
|
@@ -59369,7 +59594,7 @@ var ts;
|
|
|
59369
59594
|
// corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are
|
|
59370
59595
|
// present, we form an intersection of the inferred constraint types.
|
|
59371
59596
|
var _c = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _d = _c[0], childTypeParameter = _d === void 0 ? declaration.parent : _d, grandParent = _c[1];
|
|
59372
|
-
if (grandParent.kind === 178 /* TypeReference */) {
|
|
59597
|
+
if (grandParent.kind === 178 /* TypeReference */ && !omitTypeReferences) {
|
|
59373
59598
|
var typeReference = grandParent;
|
|
59374
59599
|
var typeParameters = getTypeParametersForTypeReference(typeReference);
|
|
59375
59600
|
if (typeParameters) {
|
|
@@ -59791,7 +60016,7 @@ var ts;
|
|
|
59791
60016
|
return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
|
|
59792
60017
|
}
|
|
59793
60018
|
function isJSDocTypeReference(node) {
|
|
59794
|
-
return !!(node.flags &
|
|
60019
|
+
return !!(node.flags & 8388608 /* JSDoc */) && (node.kind === 178 /* TypeReference */ || node.kind === 200 /* ImportType */);
|
|
59795
60020
|
}
|
|
59796
60021
|
function checkNoTypeArguments(node, symbol) {
|
|
59797
60022
|
if (node.typeArguments) {
|
|
@@ -61350,7 +61575,7 @@ var ts;
|
|
|
61350
61575
|
if (ts.isCallLikeExpression(parent)) {
|
|
61351
61576
|
return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node);
|
|
61352
61577
|
}
|
|
61353
|
-
return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) &
|
|
61578
|
+
return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
|
|
61354
61579
|
}
|
|
61355
61580
|
return true;
|
|
61356
61581
|
}
|
|
@@ -62043,7 +62268,7 @@ var ts;
|
|
|
62043
62268
|
links.resolvedSymbol = unknownSymbol;
|
|
62044
62269
|
return links.resolvedType = errorType;
|
|
62045
62270
|
}
|
|
62046
|
-
var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags &
|
|
62271
|
+
var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 8388608 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */;
|
|
62047
62272
|
// TODO: Future work: support unions/generics/whatever via a deferred import-type
|
|
62048
62273
|
var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
|
|
62049
62274
|
if (!innerModuleSymbol) {
|
|
@@ -62379,7 +62604,7 @@ var ts;
|
|
|
62379
62604
|
}
|
|
62380
62605
|
// /** @return {this} */
|
|
62381
62606
|
// x.prototype.m = function() { ... }
|
|
62382
|
-
var host = node.flags &
|
|
62607
|
+
var host = node.flags & 8388608 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined;
|
|
62383
62608
|
if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) {
|
|
62384
62609
|
return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
|
|
62385
62610
|
}
|
|
@@ -62454,7 +62679,7 @@ var ts;
|
|
|
62454
62679
|
case 143 /* NeverKeyword */:
|
|
62455
62680
|
return neverType;
|
|
62456
62681
|
case 148 /* ObjectKeyword */:
|
|
62457
|
-
return node.flags &
|
|
62682
|
+
return node.flags & 262144 /* JavaScriptFile */ && !noImplicitAny ? anyType : nonPrimitiveType;
|
|
62458
62683
|
case 138 /* IntrinsicKeyword */:
|
|
62459
62684
|
return intrinsicMarkerType;
|
|
62460
62685
|
case 192 /* ThisType */:
|
|
@@ -67331,6 +67556,9 @@ var ts;
|
|
|
67331
67556
|
var inference = inferences[i];
|
|
67332
67557
|
if (t === inference.typeParameter) {
|
|
67333
67558
|
if (fix && !inference.isFixed) {
|
|
67559
|
+
// Before we commit to a particular inference (and thus lock out any further inferences),
|
|
67560
|
+
// we infer from any intra-expression inference sites we have collected.
|
|
67561
|
+
inferFromIntraExpressionSites(context);
|
|
67334
67562
|
clearCachedInferences(inferences);
|
|
67335
67563
|
inference.isFixed = true;
|
|
67336
67564
|
}
|
|
@@ -67347,6 +67575,37 @@ var ts;
|
|
|
67347
67575
|
}
|
|
67348
67576
|
}
|
|
67349
67577
|
}
|
|
67578
|
+
function addIntraExpressionInferenceSite(context, node, type) {
|
|
67579
|
+
var _a;
|
|
67580
|
+
((_a = context.intraExpressionInferenceSites) !== null && _a !== void 0 ? _a : (context.intraExpressionInferenceSites = [])).push({ node: node, type: type });
|
|
67581
|
+
}
|
|
67582
|
+
// We collect intra-expression inference sites within object and array literals to handle cases where
|
|
67583
|
+
// inferred types flow between context sensitive element expressions. For example:
|
|
67584
|
+
//
|
|
67585
|
+
// declare function foo<T>(arg: [(n: number) => T, (x: T) => void]): void;
|
|
67586
|
+
// foo([_a => 0, n => n.toFixed()]);
|
|
67587
|
+
//
|
|
67588
|
+
// Above, both arrow functions in the tuple argument are context sensitive, thus both are omitted from the
|
|
67589
|
+
// pass that collects inferences from the non-context sensitive parts of the arguments. In the subsequent
|
|
67590
|
+
// pass where nothing is omitted, we need to commit to an inference for T in order to contextually type the
|
|
67591
|
+
// parameter in the second arrow function, but we want to first infer from the return type of the first
|
|
67592
|
+
// arrow function. This happens automatically when the arrow functions are discrete arguments (because we
|
|
67593
|
+
// infer from each argument before processing the next), but when the arrow functions are elements of an
|
|
67594
|
+
// object or array literal, we need to perform intra-expression inferences early.
|
|
67595
|
+
function inferFromIntraExpressionSites(context) {
|
|
67596
|
+
if (context.intraExpressionInferenceSites) {
|
|
67597
|
+
for (var _i = 0, _a = context.intraExpressionInferenceSites; _i < _a.length; _i++) {
|
|
67598
|
+
var _b = _a[_i], node = _b.node, type = _b.type;
|
|
67599
|
+
var contextualType = node.kind === 169 /* MethodDeclaration */ ?
|
|
67600
|
+
getContextualTypeForObjectLiteralMethod(node, 2 /* NoConstraints */) :
|
|
67601
|
+
getContextualType(node, 2 /* NoConstraints */);
|
|
67602
|
+
if (contextualType) {
|
|
67603
|
+
inferTypes(context.inferences, type, contextualType);
|
|
67604
|
+
}
|
|
67605
|
+
}
|
|
67606
|
+
context.intraExpressionInferenceSites = undefined;
|
|
67607
|
+
}
|
|
67608
|
+
}
|
|
67350
67609
|
function createInferenceInfo(typeParameter) {
|
|
67351
67610
|
return {
|
|
67352
67611
|
typeParameter: typeParameter,
|
|
@@ -69329,7 +69588,7 @@ var ts;
|
|
|
69329
69588
|
// parameter symbols with declarations that have explicit type annotations. Such references are
|
|
69330
69589
|
// resolvable with no possibility of triggering circularities in control flow analysis.
|
|
69331
69590
|
function getTypeOfDottedName(node, diagnostic) {
|
|
69332
|
-
if (!(node.flags &
|
|
69591
|
+
if (!(node.flags & 33554432 /* InWithStatement */)) {
|
|
69333
69592
|
switch (node.kind) {
|
|
69334
69593
|
case 79 /* Identifier */:
|
|
69335
69594
|
var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
|
|
@@ -70733,6 +70992,7 @@ var ts;
|
|
|
70733
70992
|
// a generic type without a nullable constraint and x is a generic type. This is because when both obj
|
|
70734
70993
|
// and x are of generic types T and K, we want the resulting type to be T[K].
|
|
70735
70994
|
return parent.kind === 206 /* PropertyAccessExpression */ ||
|
|
70995
|
+
parent.kind === 161 /* QualifiedName */ ||
|
|
70736
70996
|
parent.kind === 208 /* CallExpression */ && parent.expression === node ||
|
|
70737
70997
|
parent.kind === 207 /* ElementAccessExpression */ && parent.expression === node &&
|
|
70738
70998
|
!(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
|
|
@@ -71026,7 +71286,7 @@ var ts;
|
|
|
71026
71286
|
isInTypeQuery(node) || node.parent.kind === 275 /* ExportSpecifier */) ||
|
|
71027
71287
|
node.parent.kind === 230 /* NonNullExpression */ ||
|
|
71028
71288
|
declaration.kind === 254 /* VariableDeclaration */ && declaration.exclamationToken ||
|
|
71029
|
-
declaration.flags &
|
|
71289
|
+
declaration.flags & 16777216 /* Ambient */;
|
|
71030
71290
|
var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
|
|
71031
71291
|
type === autoType || type === autoArrayType ? undefinedType :
|
|
71032
71292
|
getOptionalType(type);
|
|
@@ -72034,7 +72294,7 @@ var ts;
|
|
|
72034
72294
|
// exists. Otherwise, it is the type of the string index signature in T, if one exists.
|
|
72035
72295
|
function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
|
|
72036
72296
|
ts.Debug.assert(ts.isObjectLiteralMethod(node));
|
|
72037
|
-
if (node.flags &
|
|
72297
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
72038
72298
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
72039
72299
|
return undefined;
|
|
72040
72300
|
}
|
|
@@ -72222,7 +72482,7 @@ var ts;
|
|
|
72222
72482
|
* @returns the contextual type of an expression.
|
|
72223
72483
|
*/
|
|
72224
72484
|
function getContextualType(node, contextFlags) {
|
|
72225
|
-
if (node.flags &
|
|
72485
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
72226
72486
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
72227
72487
|
return undefined;
|
|
72228
72488
|
}
|
|
@@ -72640,6 +72900,11 @@ var ts;
|
|
|
72640
72900
|
var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
|
|
72641
72901
|
elementTypes.push(addOptionality(type, /*isProperty*/ true, hasOmittedExpression));
|
|
72642
72902
|
elementFlags.push(hasOmittedExpression ? 2 /* Optional */ : 1 /* Required */);
|
|
72903
|
+
if (contextualType && someType(contextualType, isTupleLikeType) && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) && isContextSensitive(e)) {
|
|
72904
|
+
var inferenceContext = getInferenceContext(node);
|
|
72905
|
+
ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
|
|
72906
|
+
addIntraExpressionInferenceSite(inferenceContext, e, type);
|
|
72907
|
+
}
|
|
72643
72908
|
}
|
|
72644
72909
|
}
|
|
72645
72910
|
if (inDestructuringPattern) {
|
|
@@ -72841,6 +73106,13 @@ var ts;
|
|
|
72841
73106
|
prop.target = member;
|
|
72842
73107
|
member = prop;
|
|
72843
73108
|
allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
|
|
73109
|
+
if (contextualType && checkMode && checkMode & 2 /* Inferential */ && !(checkMode & 4 /* SkipContextSensitive */) &&
|
|
73110
|
+
(memberDecl.kind === 296 /* PropertyAssignment */ || memberDecl.kind === 169 /* MethodDeclaration */) && isContextSensitive(memberDecl)) {
|
|
73111
|
+
var inferenceContext = getInferenceContext(node);
|
|
73112
|
+
ts.Debug.assert(inferenceContext); // In CheckMode.Inferential we should always have an inference context
|
|
73113
|
+
var inferenceNode = memberDecl.kind === 296 /* PropertyAssignment */ ? memberDecl.initializer : memberDecl;
|
|
73114
|
+
addIntraExpressionInferenceSite(inferenceContext, inferenceNode, type);
|
|
73115
|
+
}
|
|
72844
73116
|
}
|
|
72845
73117
|
else if (memberDecl.kind === 298 /* SpreadAssignment */) {
|
|
72846
73118
|
if (languageVersion < 2 /* ES2015 */) {
|
|
@@ -73933,7 +74205,7 @@ var ts;
|
|
|
73933
74205
|
if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
|
|
73934
74206
|
error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
|
|
73935
74207
|
}
|
|
73936
|
-
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) &
|
|
74208
|
+
if (indexInfo.declaration && ts.getCombinedNodeFlags(indexInfo.declaration) & 268435456 /* Deprecated */) {
|
|
73937
74209
|
addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText);
|
|
73938
74210
|
}
|
|
73939
74211
|
}
|
|
@@ -74001,7 +74273,7 @@ var ts;
|
|
|
74001
74273
|
if (declaration && isPropertyWithoutInitializer(declaration)) {
|
|
74002
74274
|
if (!ts.isStatic(declaration)) {
|
|
74003
74275
|
var flowContainer = getControlFlowContainer(node);
|
|
74004
|
-
if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags &
|
|
74276
|
+
if (flowContainer.kind === 171 /* Constructor */ && flowContainer.parent === declaration.parent && !(declaration.flags & 16777216 /* Ambient */)) {
|
|
74005
74277
|
assumeUninitialized = true;
|
|
74006
74278
|
}
|
|
74007
74279
|
}
|
|
@@ -74038,7 +74310,7 @@ var ts;
|
|
|
74038
74310
|
}
|
|
74039
74311
|
else if (valueDeclaration.kind === 257 /* ClassDeclaration */ &&
|
|
74040
74312
|
node.parent.kind !== 178 /* TypeReference */ &&
|
|
74041
|
-
!(valueDeclaration.flags &
|
|
74313
|
+
!(valueDeclaration.flags & 16777216 /* Ambient */) &&
|
|
74042
74314
|
!isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
|
|
74043
74315
|
diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
|
|
74044
74316
|
}
|
|
@@ -74703,34 +74975,36 @@ var ts;
|
|
|
74703
74975
|
if (node.kind !== 165 /* Decorator */) {
|
|
74704
74976
|
var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 /* SkipBindingPatterns */ : 0 /* None */);
|
|
74705
74977
|
if (contextualType) {
|
|
74706
|
-
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
74707
|
-
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
74708
|
-
// inferred for any outer call expression so far.
|
|
74709
|
-
var outerContext = getInferenceContext(node);
|
|
74710
|
-
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
74711
|
-
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
74712
|
-
// If the contextual type is a generic function type with a single call signature, we
|
|
74713
|
-
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
74714
|
-
// the type parameters are not erased to type any during type inference such that they can
|
|
74715
|
-
// be inferred as actual types from the contextual type. For example:
|
|
74716
|
-
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
74717
|
-
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
74718
|
-
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
74719
|
-
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
74720
|
-
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
74721
|
-
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
74722
|
-
instantiatedType;
|
|
74723
74978
|
var inferenceTargetType = getReturnTypeOfSignature(signature);
|
|
74724
|
-
|
|
74725
|
-
|
|
74726
|
-
|
|
74727
|
-
|
|
74728
|
-
|
|
74729
|
-
|
|
74730
|
-
|
|
74731
|
-
|
|
74732
|
-
|
|
74733
|
-
|
|
74979
|
+
if (couldContainTypeVariables(inferenceTargetType)) {
|
|
74980
|
+
// We clone the inference context to avoid disturbing a resolution in progress for an
|
|
74981
|
+
// outer call expression. Effectively we just want a snapshot of whatever has been
|
|
74982
|
+
// inferred for any outer call expression so far.
|
|
74983
|
+
var outerContext = getInferenceContext(node);
|
|
74984
|
+
var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1 /* NoDefault */));
|
|
74985
|
+
var instantiatedType = instantiateType(contextualType, outerMapper);
|
|
74986
|
+
// If the contextual type is a generic function type with a single call signature, we
|
|
74987
|
+
// instantiate the type with its own type parameters and type arguments. This ensures that
|
|
74988
|
+
// the type parameters are not erased to type any during type inference such that they can
|
|
74989
|
+
// be inferred as actual types from the contextual type. For example:
|
|
74990
|
+
// declare function arrayMap<T, U>(f: (x: T) => U): (a: T[]) => U[];
|
|
74991
|
+
// const boxElements: <A>(a: A[]) => { value: A }[] = arrayMap(value => ({ value }));
|
|
74992
|
+
// Above, the type of the 'value' parameter is inferred to be 'A'.
|
|
74993
|
+
var contextualSignature = getSingleCallSignature(instantiatedType);
|
|
74994
|
+
var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
|
|
74995
|
+
getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
|
|
74996
|
+
instantiatedType;
|
|
74997
|
+
// Inferences made from return types have lower priority than all other inferences.
|
|
74998
|
+
inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 128 /* ReturnType */);
|
|
74999
|
+
// Create a type mapper for instantiating generic contextual types using the inferences made
|
|
75000
|
+
// from the return type. We need a separate inference pass here because (a) instantiation of
|
|
75001
|
+
// the source type uses the outer context's return mapper (which excludes inferences made from
|
|
75002
|
+
// outer arguments), and (b) we don't want any further inferences going into this context.
|
|
75003
|
+
var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
|
|
75004
|
+
var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
|
|
75005
|
+
inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
|
|
75006
|
+
context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
|
|
75007
|
+
}
|
|
74734
75008
|
}
|
|
74735
75009
|
}
|
|
74736
75010
|
var restType = getNonArrayRestType(signature);
|
|
@@ -74742,7 +75016,7 @@ var ts;
|
|
|
74742
75016
|
}
|
|
74743
75017
|
}
|
|
74744
75018
|
var thisType = getThisTypeOfSignature(signature);
|
|
74745
|
-
if (thisType) {
|
|
75019
|
+
if (thisType && couldContainTypeVariables(thisType)) {
|
|
74746
75020
|
var thisArgumentNode = getThisArgumentOfCall(node);
|
|
74747
75021
|
inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
|
|
74748
75022
|
}
|
|
@@ -74750,11 +75024,13 @@ var ts;
|
|
|
74750
75024
|
var arg = args[i];
|
|
74751
75025
|
if (arg.kind !== 227 /* OmittedExpression */ && !(checkMode & 32 /* IsForStringLiteralArgumentCompletions */ && hasSkipDirectInferenceFlag(arg))) {
|
|
74752
75026
|
var paramType = getTypeAtPosition(signature, i);
|
|
74753
|
-
|
|
74754
|
-
|
|
75027
|
+
if (couldContainTypeVariables(paramType)) {
|
|
75028
|
+
var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
|
|
75029
|
+
inferTypes(context.inferences, argType, paramType);
|
|
75030
|
+
}
|
|
74755
75031
|
}
|
|
74756
75032
|
}
|
|
74757
|
-
if (restType) {
|
|
75033
|
+
if (restType && couldContainTypeVariables(restType)) {
|
|
74758
75034
|
var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
|
|
74759
75035
|
inferTypes(context.inferences, spreadType, restType);
|
|
74760
75036
|
}
|
|
@@ -76334,7 +76610,7 @@ var ts;
|
|
|
76334
76610
|
return returnType;
|
|
76335
76611
|
}
|
|
76336
76612
|
function checkDeprecatedSignature(signature, node) {
|
|
76337
|
-
if (signature.declaration && signature.declaration.flags &
|
|
76613
|
+
if (signature.declaration && signature.declaration.flags & 268435456 /* Deprecated */) {
|
|
76338
76614
|
var suggestionNode = getDeprecatedSuggestionNode(node);
|
|
76339
76615
|
var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node));
|
|
76340
76616
|
addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature));
|
|
@@ -76478,7 +76754,7 @@ var ts;
|
|
|
76478
76754
|
if (targetDeclarationKind !== 0 /* Unknown */) {
|
|
76479
76755
|
var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
|
|
76480
76756
|
// function/variable declaration should be ambient
|
|
76481
|
-
return !!decl && !!(decl.flags &
|
|
76757
|
+
return !!decl && !!(decl.flags & 16777216 /* Ambient */);
|
|
76482
76758
|
}
|
|
76483
76759
|
return false;
|
|
76484
76760
|
}
|
|
@@ -76673,7 +76949,7 @@ var ts;
|
|
|
76673
76949
|
error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_es2022_esnext_system_node12_or_nodenext);
|
|
76674
76950
|
}
|
|
76675
76951
|
var file = ts.getSourceFileOfNode(node);
|
|
76676
|
-
ts.Debug.assert(!!(file.flags &
|
|
76952
|
+
ts.Debug.assert(!!(file.flags & 4194304 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag.");
|
|
76677
76953
|
return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
|
|
76678
76954
|
}
|
|
76679
76955
|
function getTypeOfParameter(symbol) {
|
|
@@ -78687,6 +78963,11 @@ var ts;
|
|
|
78687
78963
|
context.contextualType = contextualType;
|
|
78688
78964
|
context.inferenceContext = inferenceContext;
|
|
78689
78965
|
var type = checkExpression(node, checkMode | 1 /* Contextual */ | (inferenceContext ? 2 /* Inferential */ : 0));
|
|
78966
|
+
// In CheckMode.Inferential we collect intra-expression inference sites to process before fixing any type
|
|
78967
|
+
// parameters. This information is no longer needed after the call to checkExpression.
|
|
78968
|
+
if (inferenceContext && inferenceContext.intraExpressionInferenceSites) {
|
|
78969
|
+
inferenceContext.intraExpressionInferenceSites = undefined;
|
|
78970
|
+
}
|
|
78690
78971
|
// We strip literal freshness when an appropriate contextual type is present such that contextually typed
|
|
78691
78972
|
// literals always preserve their literal types (otherwise they might widen during type inference). An alternative
|
|
78692
78973
|
// here would be to not mark contextually typed literals as fresh in the first place.
|
|
@@ -78978,7 +79259,7 @@ var ts;
|
|
|
78978
79259
|
return quickType;
|
|
78979
79260
|
}
|
|
78980
79261
|
// If a type has been cached for the node, return it.
|
|
78981
|
-
if (node.flags &
|
|
79262
|
+
if (node.flags & 134217728 /* TypeCached */ && flowTypeCache) {
|
|
78982
79263
|
var cachedType = flowTypeCache[getNodeId(node)];
|
|
78983
79264
|
if (cachedType) {
|
|
78984
79265
|
return cachedType;
|
|
@@ -78990,7 +79271,7 @@ var ts;
|
|
|
78990
79271
|
if (flowInvocationCount !== startInvocationCount) {
|
|
78991
79272
|
var cache = flowTypeCache || (flowTypeCache = []);
|
|
78992
79273
|
cache[getNodeId(node)] = type;
|
|
78993
|
-
ts.setNodeFlags(node, node.flags |
|
|
79274
|
+
ts.setNodeFlags(node, node.flags | 134217728 /* TypeCached */);
|
|
78994
79275
|
}
|
|
78995
79276
|
return type;
|
|
78996
79277
|
}
|
|
@@ -79076,7 +79357,7 @@ var ts;
|
|
|
79076
79357
|
if (compilerOptions.isolatedModules) {
|
|
79077
79358
|
ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
|
|
79078
79359
|
var constEnumDeclaration = type.symbol.valueDeclaration;
|
|
79079
|
-
if (constEnumDeclaration.flags &
|
|
79360
|
+
if (constEnumDeclaration.flags & 16777216 /* Ambient */) {
|
|
79080
79361
|
error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
|
|
79081
79362
|
}
|
|
79082
79363
|
}
|
|
@@ -79769,7 +80050,7 @@ var ts;
|
|
|
79769
80050
|
checkDecorators(node);
|
|
79770
80051
|
checkSignatureDeclaration(node);
|
|
79771
80052
|
if (node.kind === 172 /* GetAccessor */) {
|
|
79772
|
-
if (!(node.flags &
|
|
80053
|
+
if (!(node.flags & 16777216 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) {
|
|
79773
80054
|
if (!(node.flags & 512 /* HasExplicitReturn */)) {
|
|
79774
80055
|
error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
|
|
79775
80056
|
}
|
|
@@ -79864,7 +80145,7 @@ var ts;
|
|
|
79864
80145
|
}
|
|
79865
80146
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
79866
80147
|
if (symbol) {
|
|
79867
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags &
|
|
80148
|
+
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* Deprecated */); })) {
|
|
79868
80149
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
79869
80150
|
}
|
|
79870
80151
|
if (type.flags & 32 /* Enum */ && symbol.flags & 8 /* EnumMember */) {
|
|
@@ -80024,6 +80305,23 @@ var ts;
|
|
|
80024
80305
|
grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
|
|
80025
80306
|
}
|
|
80026
80307
|
checkSourceElement(node.typeParameter);
|
|
80308
|
+
var symbol = getSymbolOfNode(node.typeParameter);
|
|
80309
|
+
if (symbol.declarations && symbol.declarations.length > 1) {
|
|
80310
|
+
var links = getSymbolLinks(symbol);
|
|
80311
|
+
if (!links.typeParametersChecked) {
|
|
80312
|
+
links.typeParametersChecked = true;
|
|
80313
|
+
var typeParameter = getDeclaredTypeOfTypeParameter(symbol);
|
|
80314
|
+
var declarations = ts.getDeclarationsOfKind(symbol, 163 /* TypeParameter */);
|
|
80315
|
+
if (!areTypeParametersIdentical(declarations, [typeParameter], function (decl) { return [decl]; })) {
|
|
80316
|
+
// Report an error on every conflicting declaration.
|
|
80317
|
+
var name = symbolToString(symbol);
|
|
80318
|
+
for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
|
|
80319
|
+
var declaration = declarations_4[_i];
|
|
80320
|
+
error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_constraints, name);
|
|
80321
|
+
}
|
|
80322
|
+
}
|
|
80323
|
+
}
|
|
80324
|
+
}
|
|
80027
80325
|
registerForUnusedIdentifiersCheck(node);
|
|
80028
80326
|
}
|
|
80029
80327
|
function checkTemplateLiteralType(node) {
|
|
@@ -80061,7 +80359,7 @@ var ts;
|
|
|
80061
80359
|
getTypeFromTypeNode(node);
|
|
80062
80360
|
}
|
|
80063
80361
|
function isPrivateWithinAmbient(node) {
|
|
80064
|
-
return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags &
|
|
80362
|
+
return (ts.hasEffectiveModifier(node, 8 /* Private */) || ts.isPrivateIdentifierClassElementDeclaration(node)) && !!(node.flags & 16777216 /* Ambient */);
|
|
80065
80363
|
}
|
|
80066
80364
|
function getEffectiveDeclarationFlags(n, flagsToCheck) {
|
|
80067
80365
|
var flags = ts.getCombinedModifierFlags(n);
|
|
@@ -80070,7 +80368,7 @@ var ts;
|
|
|
80070
80368
|
if (n.parent.kind !== 258 /* InterfaceDeclaration */ &&
|
|
80071
80369
|
n.parent.kind !== 257 /* ClassDeclaration */ &&
|
|
80072
80370
|
n.parent.kind !== 226 /* ClassExpression */ &&
|
|
80073
|
-
n.flags &
|
|
80371
|
+
n.flags & 16777216 /* Ambient */) {
|
|
80074
80372
|
if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
|
|
80075
80373
|
// It is nested in an ambient context, which means it is automatically exported
|
|
80076
80374
|
flags |= 1 /* Export */;
|
|
@@ -80203,10 +80501,10 @@ var ts;
|
|
|
80203
80501
|
var hasNonAmbientClass = false;
|
|
80204
80502
|
var functionDeclarations = [];
|
|
80205
80503
|
if (declarations) {
|
|
80206
|
-
for (var _i = 0,
|
|
80207
|
-
var current =
|
|
80504
|
+
for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
|
|
80505
|
+
var current = declarations_5[_i];
|
|
80208
80506
|
var node = current;
|
|
80209
|
-
var inAmbientContext = node.flags &
|
|
80507
|
+
var inAmbientContext = node.flags & 16777216 /* Ambient */;
|
|
80210
80508
|
var inAmbientContextOrInterface = node.parent && (node.parent.kind === 258 /* InterfaceDeclaration */ || node.parent.kind === 182 /* TypeLiteral */) || inAmbientContext;
|
|
80211
80509
|
if (inAmbientContextOrInterface) {
|
|
80212
80510
|
// check if declarations are consecutive only if they are non-ambient
|
|
@@ -81058,7 +81356,7 @@ var ts;
|
|
|
81058
81356
|
// checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function.
|
|
81059
81357
|
var firstDeclaration = (_a = localSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(
|
|
81060
81358
|
// Get first non javascript function declaration
|
|
81061
|
-
function (declaration) { return declaration.kind === node.kind && !(declaration.flags &
|
|
81359
|
+
function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 262144 /* JavaScriptFile */); });
|
|
81062
81360
|
// Only type check the symbol once
|
|
81063
81361
|
if (node === firstDeclaration) {
|
|
81064
81362
|
checkFunctionOrConstructorSymbol(localSymbol);
|
|
@@ -81180,7 +81478,7 @@ var ts;
|
|
|
81180
81478
|
var symbol = getSymbolOfNode(member);
|
|
81181
81479
|
if (!symbol.isReferenced
|
|
81182
81480
|
&& (ts.hasEffectiveModifier(member, 8 /* Private */) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
|
|
81183
|
-
&& !(member.flags &
|
|
81481
|
+
&& !(member.flags & 16777216 /* Ambient */)) {
|
|
81184
81482
|
addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
|
|
81185
81483
|
}
|
|
81186
81484
|
break;
|
|
@@ -81370,8 +81668,8 @@ var ts;
|
|
|
81370
81668
|
: ts.createDiagnosticForNode(declarationList.parent.kind === 237 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
|
|
81371
81669
|
}
|
|
81372
81670
|
else {
|
|
81373
|
-
for (var _i = 0,
|
|
81374
|
-
var decl =
|
|
81671
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
81672
|
+
var decl = declarations_6[_i];
|
|
81375
81673
|
addDiagnostic(decl, 0 /* Local */, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
|
|
81376
81674
|
}
|
|
81377
81675
|
}
|
|
@@ -81413,7 +81711,7 @@ var ts;
|
|
|
81413
81711
|
}
|
|
81414
81712
|
function checkCollisionWithArgumentsInGeneratedCode(node) {
|
|
81415
81713
|
// no rest parameters \ declaration context \ overload - no codegen impact
|
|
81416
|
-
if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags &
|
|
81714
|
+
if (languageVersion >= 2 /* ES2015 */ || !ts.hasRestParameter(node) || node.flags & 16777216 /* Ambient */ || ts.nodeIsMissing(node.body)) {
|
|
81417
81715
|
return;
|
|
81418
81716
|
}
|
|
81419
81717
|
ts.forEach(node.parameters, function (p) {
|
|
@@ -81441,7 +81739,7 @@ var ts;
|
|
|
81441
81739
|
// it is ok to have member named '_super', '_this', `Promise`, etc. - member access is always qualified
|
|
81442
81740
|
return false;
|
|
81443
81741
|
}
|
|
81444
|
-
if (node.flags &
|
|
81742
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
81445
81743
|
// ambient context - no codegen impact
|
|
81446
81744
|
return false;
|
|
81447
81745
|
}
|
|
@@ -81580,7 +81878,7 @@ var ts;
|
|
|
81580
81878
|
recordPotentialCollisionWithReflectInGeneratedCode(node, name);
|
|
81581
81879
|
if (ts.isClassLike(node)) {
|
|
81582
81880
|
checkTypeNameIsReserved(name, ts.Diagnostics.Class_name_cannot_be_0);
|
|
81583
|
-
if (!(node.flags &
|
|
81881
|
+
if (!(node.flags & 16777216 /* Ambient */)) {
|
|
81584
81882
|
checkClassNameCollisionWithObject(name);
|
|
81585
81883
|
}
|
|
81586
81884
|
}
|
|
@@ -83174,23 +83472,23 @@ var ts;
|
|
|
83174
83472
|
return;
|
|
83175
83473
|
}
|
|
83176
83474
|
var type = getDeclaredTypeOfSymbol(symbol);
|
|
83177
|
-
if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
|
|
83475
|
+
if (!areTypeParametersIdentical(declarations, type.localTypeParameters, ts.getEffectiveTypeParameterDeclarations)) {
|
|
83178
83476
|
// Report an error on every conflicting declaration.
|
|
83179
83477
|
var name = symbolToString(symbol);
|
|
83180
|
-
for (var _i = 0,
|
|
83181
|
-
var declaration =
|
|
83478
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
83479
|
+
var declaration = declarations_7[_i];
|
|
83182
83480
|
error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
|
|
83183
83481
|
}
|
|
83184
83482
|
}
|
|
83185
83483
|
}
|
|
83186
83484
|
}
|
|
83187
|
-
function areTypeParametersIdentical(declarations, targetParameters) {
|
|
83485
|
+
function areTypeParametersIdentical(declarations, targetParameters, getTypeParameterDeclarations) {
|
|
83188
83486
|
var maxTypeArgumentCount = ts.length(targetParameters);
|
|
83189
83487
|
var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
|
|
83190
|
-
for (var _i = 0,
|
|
83191
|
-
var declaration =
|
|
83488
|
+
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
83489
|
+
var declaration = declarations_8[_i];
|
|
83192
83490
|
// If this declaration has too few or too many type parameters, we report an error
|
|
83193
|
-
var sourceParameters =
|
|
83491
|
+
var sourceParameters = getTypeParameterDeclarations(declaration);
|
|
83194
83492
|
var numTypeParameters = sourceParameters.length;
|
|
83195
83493
|
if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
|
|
83196
83494
|
return false;
|
|
@@ -83258,7 +83556,7 @@ var ts;
|
|
|
83258
83556
|
checkFunctionOrConstructorSymbol(symbol);
|
|
83259
83557
|
checkClassForDuplicateDeclarations(node);
|
|
83260
83558
|
// Only check for reserved static identifiers on non-ambient context.
|
|
83261
|
-
var nodeInAmbientContext = !!(node.flags &
|
|
83559
|
+
var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
|
|
83262
83560
|
if (!nodeInAmbientContext) {
|
|
83263
83561
|
checkClassForStaticPropertyNameConflicts(node);
|
|
83264
83562
|
}
|
|
@@ -83408,7 +83706,7 @@ var ts;
|
|
|
83408
83706
|
*/
|
|
83409
83707
|
function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
|
|
83410
83708
|
var isJs = ts.isInJSFile(node);
|
|
83411
|
-
var nodeInAmbientContext = !!(node.flags &
|
|
83709
|
+
var nodeInAmbientContext = !!(node.flags & 16777216 /* Ambient */);
|
|
83412
83710
|
if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
|
|
83413
83711
|
var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
|
|
83414
83712
|
var thisType = memberIsStatic ? staticType : typeWithThis;
|
|
@@ -83636,7 +83934,7 @@ var ts;
|
|
|
83636
83934
|
&& !(derived.flags & 33554432 /* Transient */)
|
|
83637
83935
|
&& !(baseDeclarationFlags & 128 /* Abstract */)
|
|
83638
83936
|
&& !(derivedDeclarationFlags & 128 /* Abstract */)
|
|
83639
|
-
&& !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags &
|
|
83937
|
+
&& !((_b = derived.declarations) === null || _b === void 0 ? void 0 : _b.some(function (d) { return !!(d.flags & 16777216 /* Ambient */); }))) {
|
|
83640
83938
|
var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
|
|
83641
83939
|
var propName = uninitialized.name;
|
|
83642
83940
|
if (uninitialized.exclamationToken
|
|
@@ -83728,7 +84026,7 @@ var ts;
|
|
|
83728
84026
|
return ok;
|
|
83729
84027
|
}
|
|
83730
84028
|
function checkPropertyInitialization(node) {
|
|
83731
|
-
if (!strictNullChecks || !strictPropertyInitialization || node.flags &
|
|
84029
|
+
if (!strictNullChecks || !strictPropertyInitialization || node.flags & 16777216 /* Ambient */) {
|
|
83732
84030
|
return;
|
|
83733
84031
|
}
|
|
83734
84032
|
var constructor = findConstructorDeclaration(node);
|
|
@@ -83865,7 +84163,7 @@ var ts;
|
|
|
83865
84163
|
}
|
|
83866
84164
|
// In ambient non-const numeric enum declarations, enum members without initializers are
|
|
83867
84165
|
// considered computed members (as opposed to having auto-incremented values).
|
|
83868
|
-
if (member.parent.flags &
|
|
84166
|
+
if (member.parent.flags & 16777216 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) {
|
|
83869
84167
|
return undefined;
|
|
83870
84168
|
}
|
|
83871
84169
|
// If the member declaration specifies no value, the member is considered a constant enum member.
|
|
@@ -83897,7 +84195,7 @@ var ts;
|
|
|
83897
84195
|
else if (isConstEnum) {
|
|
83898
84196
|
error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
|
|
83899
84197
|
}
|
|
83900
|
-
else if (member.parent.flags &
|
|
84198
|
+
else if (member.parent.flags & 16777216 /* Ambient */) {
|
|
83901
84199
|
error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
|
|
83902
84200
|
}
|
|
83903
84201
|
else {
|
|
@@ -84065,11 +84363,11 @@ var ts;
|
|
|
84065
84363
|
function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
|
|
84066
84364
|
var declarations = symbol.declarations;
|
|
84067
84365
|
if (declarations) {
|
|
84068
|
-
for (var _i = 0,
|
|
84069
|
-
var declaration =
|
|
84366
|
+
for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
|
|
84367
|
+
var declaration = declarations_9[_i];
|
|
84070
84368
|
if ((declaration.kind === 257 /* ClassDeclaration */ ||
|
|
84071
84369
|
(declaration.kind === 256 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) &&
|
|
84072
|
-
!(declaration.flags &
|
|
84370
|
+
!(declaration.flags & 16777216 /* Ambient */)) {
|
|
84073
84371
|
return declaration;
|
|
84074
84372
|
}
|
|
84075
84373
|
}
|
|
@@ -84100,7 +84398,7 @@ var ts;
|
|
|
84100
84398
|
function checkModuleDeclarationDiagnostics() {
|
|
84101
84399
|
// Grammar checking
|
|
84102
84400
|
var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
|
|
84103
|
-
var inAmbientContext = node.flags &
|
|
84401
|
+
var inAmbientContext = node.flags & 16777216 /* Ambient */;
|
|
84104
84402
|
if (isGlobalAugmentation && !inAmbientContext) {
|
|
84105
84403
|
error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
|
|
84106
84404
|
}
|
|
@@ -84318,7 +84616,7 @@ var ts;
|
|
|
84318
84616
|
}
|
|
84319
84617
|
if (compilerOptions.isolatedModules
|
|
84320
84618
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
84321
|
-
&& !(node.flags &
|
|
84619
|
+
&& !(node.flags & 16777216 /* Ambient */)) {
|
|
84322
84620
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
84323
84621
|
var isType = !(target.flags & 111551 /* Value */);
|
|
84324
84622
|
if (isType || typeOnlyAlias) {
|
|
@@ -84364,7 +84662,7 @@ var ts;
|
|
|
84364
84662
|
}
|
|
84365
84663
|
}
|
|
84366
84664
|
function isDeprecatedAliasedSymbol(symbol) {
|
|
84367
|
-
return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) &
|
|
84665
|
+
return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 268435456 /* Deprecated */); });
|
|
84368
84666
|
}
|
|
84369
84667
|
function checkDeprecatedAliasedSymbol(symbol, location) {
|
|
84370
84668
|
if (!(symbol.flags & 2097152 /* Alias */))
|
|
@@ -84493,7 +84791,7 @@ var ts;
|
|
|
84493
84791
|
}
|
|
84494
84792
|
}
|
|
84495
84793
|
else {
|
|
84496
|
-
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags &
|
|
84794
|
+
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & 16777216 /* Ambient */)) {
|
|
84497
84795
|
// Import equals declaration is deprecated in es6 or above
|
|
84498
84796
|
grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
|
|
84499
84797
|
}
|
|
@@ -84519,7 +84817,7 @@ var ts;
|
|
|
84519
84817
|
ts.forEach(node.exportClause.elements, checkExportSpecifier);
|
|
84520
84818
|
var inAmbientExternalModule = node.parent.kind === 262 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent);
|
|
84521
84819
|
var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 262 /* ModuleBlock */ &&
|
|
84522
|
-
!node.moduleSpecifier && node.flags &
|
|
84820
|
+
!node.moduleSpecifier && node.flags & 16777216 /* Ambient */;
|
|
84523
84821
|
if (node.parent.kind !== 305 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
|
|
84524
84822
|
error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
|
|
84525
84823
|
}
|
|
@@ -84684,10 +84982,10 @@ var ts;
|
|
|
84684
84982
|
checkExpressionCached(node.expression);
|
|
84685
84983
|
}
|
|
84686
84984
|
checkExternalModuleExports(container);
|
|
84687
|
-
if ((node.flags &
|
|
84985
|
+
if ((node.flags & 16777216 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) {
|
|
84688
84986
|
grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
|
|
84689
84987
|
}
|
|
84690
|
-
if (node.isExportEquals && !(node.flags &
|
|
84988
|
+
if (node.isExportEquals && !(node.flags & 16777216 /* Ambient */)) {
|
|
84691
84989
|
if (moduleKind >= ts.ModuleKind.ES2015 && ts.getSourceFileOfNode(node).impliedNodeFormat !== ts.ModuleKind.CommonJS) {
|
|
84692
84990
|
// export assignment is not supported in es6 modules
|
|
84693
84991
|
grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
|
|
@@ -85120,7 +85418,7 @@ var ts;
|
|
|
85120
85418
|
// This relies on the results of other lazy diagnostics, so must be computed after them
|
|
85121
85419
|
if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
|
|
85122
85420
|
checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
|
|
85123
|
-
if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags &
|
|
85421
|
+
if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 16777216 /* Ambient */))) {
|
|
85124
85422
|
diagnostics.add(diag);
|
|
85125
85423
|
}
|
|
85126
85424
|
});
|
|
@@ -85220,7 +85518,7 @@ var ts;
|
|
|
85220
85518
|
}
|
|
85221
85519
|
// Language service support
|
|
85222
85520
|
function getSymbolsInScope(location, meaning) {
|
|
85223
|
-
if (location.flags &
|
|
85521
|
+
if (location.flags & 33554432 /* InWithStatement */) {
|
|
85224
85522
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85225
85523
|
return [];
|
|
85226
85524
|
}
|
|
@@ -85570,7 +85868,7 @@ var ts;
|
|
|
85570
85868
|
}
|
|
85571
85869
|
var parent = node.parent;
|
|
85572
85870
|
var grandParent = parent.parent;
|
|
85573
|
-
if (node.flags &
|
|
85871
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
85574
85872
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85575
85873
|
return undefined;
|
|
85576
85874
|
}
|
|
@@ -85712,7 +86010,7 @@ var ts;
|
|
|
85712
86010
|
if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
|
|
85713
86011
|
return errorType;
|
|
85714
86012
|
}
|
|
85715
|
-
if (node.flags &
|
|
86013
|
+
if (node.flags & 33554432 /* InWithStatement */) {
|
|
85716
86014
|
// We cannot answer semantic questions within a with block, do not proceed any further
|
|
85717
86015
|
return errorType;
|
|
85718
86016
|
}
|
|
@@ -86765,7 +87063,7 @@ var ts;
|
|
|
86765
87063
|
function checkExternalEmitHelpers(location, helpers) {
|
|
86766
87064
|
if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
|
|
86767
87065
|
var sourceFile = ts.getSourceFileOfNode(location);
|
|
86768
|
-
if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags &
|
|
87066
|
+
if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 16777216 /* Ambient */)) {
|
|
86769
87067
|
var helpersModule = resolveHelpersModule(sourceFile, location);
|
|
86770
87068
|
if (helpersModule !== unknownSymbol) {
|
|
86771
87069
|
var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
|
|
@@ -87018,7 +87316,7 @@ var ts;
|
|
|
87018
87316
|
else if (node.kind === 164 /* Parameter */) {
|
|
87019
87317
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
|
|
87020
87318
|
}
|
|
87021
|
-
else if ((node.parent.flags &
|
|
87319
|
+
else if ((node.parent.flags & 16777216 /* Ambient */) && node.parent.kind === 262 /* ModuleBlock */) {
|
|
87022
87320
|
return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
|
|
87023
87321
|
}
|
|
87024
87322
|
else if (ts.isPrivateIdentifierClassElementDeclaration(node)) {
|
|
@@ -87064,7 +87362,7 @@ var ts;
|
|
|
87064
87362
|
if (flags & 256 /* Async */) {
|
|
87065
87363
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
|
|
87066
87364
|
}
|
|
87067
|
-
else if (flags & 2 /* Ambient */ || node.parent.flags &
|
|
87365
|
+
else if (flags & 2 /* Ambient */ || node.parent.flags & 16777216 /* Ambient */) {
|
|
87068
87366
|
return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
|
|
87069
87367
|
}
|
|
87070
87368
|
else if (node.kind === 164 /* Parameter */) {
|
|
@@ -87210,7 +87508,7 @@ var ts;
|
|
|
87210
87508
|
if (i !== (parameterCount - 1)) {
|
|
87211
87509
|
return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
|
|
87212
87510
|
}
|
|
87213
|
-
if (!(parameter.flags &
|
|
87511
|
+
if (!(parameter.flags & 16777216 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070
|
|
87214
87512
|
checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
|
|
87215
87513
|
}
|
|
87216
87514
|
if (parameter.questionToken) {
|
|
@@ -87421,7 +87719,7 @@ var ts;
|
|
|
87421
87719
|
ts.Debug.assert(node.kind === 256 /* FunctionDeclaration */ ||
|
|
87422
87720
|
node.kind === 213 /* FunctionExpression */ ||
|
|
87423
87721
|
node.kind === 169 /* MethodDeclaration */);
|
|
87424
|
-
if (node.flags &
|
|
87722
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87425
87723
|
return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
|
|
87426
87724
|
}
|
|
87427
87725
|
if (!node.body) {
|
|
@@ -87659,7 +87957,7 @@ var ts;
|
|
|
87659
87957
|
return false;
|
|
87660
87958
|
}
|
|
87661
87959
|
function checkGrammarAccessor(accessor) {
|
|
87662
|
-
if (!(accessor.flags &
|
|
87960
|
+
if (!(accessor.flags & 16777216 /* Ambient */) && (accessor.parent.kind !== 182 /* TypeLiteral */) && (accessor.parent.kind !== 258 /* InterfaceDeclaration */)) {
|
|
87663
87961
|
if (languageVersion < 1 /* ES5 */) {
|
|
87664
87962
|
return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
|
|
87665
87963
|
}
|
|
@@ -87799,7 +88097,7 @@ var ts;
|
|
|
87799
88097
|
// However, property declarations disallow computed names in general,
|
|
87800
88098
|
// and accessors are not allowed in ambient contexts in general,
|
|
87801
88099
|
// so this error only really matters for methods.
|
|
87802
|
-
if (node.flags &
|
|
88100
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87803
88101
|
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);
|
|
87804
88102
|
}
|
|
87805
88103
|
else if (node.kind === 169 /* MethodDeclaration */ && !node.body) {
|
|
@@ -87915,7 +88213,7 @@ var ts;
|
|
|
87915
88213
|
}
|
|
87916
88214
|
function checkGrammarVariableDeclaration(node) {
|
|
87917
88215
|
if (node.parent.parent.kind !== 243 /* ForInStatement */ && node.parent.parent.kind !== 244 /* ForOfStatement */) {
|
|
87918
|
-
if (node.flags &
|
|
88216
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
87919
88217
|
checkAmbientInitializer(node);
|
|
87920
88218
|
}
|
|
87921
88219
|
else if (!node.initializer) {
|
|
@@ -87927,7 +88225,7 @@ var ts;
|
|
|
87927
88225
|
}
|
|
87928
88226
|
}
|
|
87929
88227
|
}
|
|
87930
|
-
if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags &
|
|
88228
|
+
if (node.exclamationToken && (node.parent.parent.kind !== 237 /* VariableStatement */ || !node.type || node.initializer || node.flags & 16777216 /* Ambient */)) {
|
|
87931
88229
|
var message = node.initializer
|
|
87932
88230
|
? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
|
|
87933
88231
|
: !node.type
|
|
@@ -87936,7 +88234,7 @@ var ts;
|
|
|
87936
88234
|
return grammarErrorOnNode(node.exclamationToken, message);
|
|
87937
88235
|
}
|
|
87938
88236
|
if ((moduleKind < ts.ModuleKind.ES2015 || ts.getSourceFileOfNode(node).impliedNodeFormat === ts.ModuleKind.CommonJS) && moduleKind !== ts.ModuleKind.System &&
|
|
87939
|
-
!(node.parent.parent.flags &
|
|
88237
|
+
!(node.parent.parent.flags & 16777216 /* Ambient */) && ts.hasSyntacticModifier(node.parent.parent, 1 /* Export */)) {
|
|
87940
88238
|
checkESModuleMarker(node.name);
|
|
87941
88239
|
}
|
|
87942
88240
|
var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
|
|
@@ -88113,11 +88411,11 @@ var ts;
|
|
|
88113
88411
|
return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
|
|
88114
88412
|
}
|
|
88115
88413
|
}
|
|
88116
|
-
if (node.flags &
|
|
88414
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
88117
88415
|
checkAmbientInitializer(node);
|
|
88118
88416
|
}
|
|
88119
88417
|
if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
|
|
88120
|
-
node.flags &
|
|
88418
|
+
node.flags & 16777216 /* Ambient */ || ts.isStatic(node) || ts.hasAbstractModifier(node))) {
|
|
88121
88419
|
var message = node.initializer
|
|
88122
88420
|
? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
|
|
88123
88421
|
: !node.type
|
|
@@ -88163,10 +88461,10 @@ var ts;
|
|
|
88163
88461
|
return false;
|
|
88164
88462
|
}
|
|
88165
88463
|
function checkGrammarSourceFile(node) {
|
|
88166
|
-
return !!(node.flags &
|
|
88464
|
+
return !!(node.flags & 16777216 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
|
|
88167
88465
|
}
|
|
88168
88466
|
function checkGrammarStatementInAmbientContext(node) {
|
|
88169
|
-
if (node.flags &
|
|
88467
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
88170
88468
|
// Find containing block which is either Block, ModuleBlock, SourceFile
|
|
88171
88469
|
var links = getNodeLinks(node);
|
|
88172
88470
|
if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
|
|
@@ -92284,7 +92582,7 @@ var ts;
|
|
|
92284
92582
|
return !ts.nodeIsMissing(node.body);
|
|
92285
92583
|
}
|
|
92286
92584
|
function visitPropertyDeclaration(node) {
|
|
92287
|
-
if (node.flags &
|
|
92585
|
+
if (node.flags & 16777216 /* Ambient */ || ts.hasSyntacticModifier(node, 128 /* Abstract */)) {
|
|
92288
92586
|
return undefined;
|
|
92289
92587
|
}
|
|
92290
92588
|
var updated = factory.updatePropertyDeclaration(node,
|
|
@@ -99174,8 +99472,8 @@ var ts;
|
|
|
99174
99472
|
// declarations may not be sorted by position.
|
|
99175
99473
|
// pos should be the minimum* position over all nodes (that's not -1), end should be the maximum end over all nodes.
|
|
99176
99474
|
var pos = -1, end = -1;
|
|
99177
|
-
for (var _i = 0,
|
|
99178
|
-
var node =
|
|
99475
|
+
for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
|
|
99476
|
+
var node = declarations_10[_i];
|
|
99179
99477
|
pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
|
|
99180
99478
|
end = Math.max(end, node.end);
|
|
99181
99479
|
}
|
|
@@ -108218,7 +108516,7 @@ var ts;
|
|
|
108218
108516
|
needsScopeFixMarker = false;
|
|
108219
108517
|
var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
|
|
108220
108518
|
var lateStatements = transformAndReplaceLatePaintedStatements(statements);
|
|
108221
|
-
if (input.flags &
|
|
108519
|
+
if (input.flags & 16777216 /* Ambient */) {
|
|
108222
108520
|
needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates"
|
|
108223
108521
|
}
|
|
108224
108522
|
// With the final list of statements, there are 3 possibilities:
|
|
@@ -109866,6 +110164,9 @@ var ts;
|
|
|
109866
110164
|
var currentParenthesizerRule;
|
|
109867
110165
|
var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
|
|
109868
110166
|
var parenthesizer = ts.factory.parenthesizer;
|
|
110167
|
+
var typeArgumentParenthesizerRuleSelector = {
|
|
110168
|
+
select: function (index) { return index === 0 ? parenthesizer.parenthesizeLeadingTypeArgument : undefined; }
|
|
110169
|
+
};
|
|
109869
110170
|
var emitBinaryExpression = createEmitBinaryExpression();
|
|
109870
110171
|
reset();
|
|
109871
110172
|
return {
|
|
@@ -111078,7 +111379,7 @@ var ts;
|
|
|
111078
111379
|
writePunctuation("}");
|
|
111079
111380
|
}
|
|
111080
111381
|
function emitArrayType(node) {
|
|
111081
|
-
emit(node.elementType, parenthesizer.
|
|
111382
|
+
emit(node.elementType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
|
|
111082
111383
|
writePunctuation("[");
|
|
111083
111384
|
writePunctuation("]");
|
|
111084
111385
|
}
|
|
@@ -111089,7 +111390,7 @@ var ts;
|
|
|
111089
111390
|
function emitTupleType(node) {
|
|
111090
111391
|
emitTokenWithComment(22 /* OpenBracketToken */, node.pos, writePunctuation, node);
|
|
111091
111392
|
var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 528 /* SingleLineTupleTypeElements */ : 657 /* MultiLineTupleTypeElements */;
|
|
111092
|
-
emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty
|
|
111393
|
+
emitList(node, node.elements, flags | 524288 /* NoSpaceIfEmpty */, parenthesizer.parenthesizeElementTypeOfTupleType);
|
|
111093
111394
|
emitTokenWithComment(23 /* CloseBracketToken */, node.elements.end, writePunctuation, node);
|
|
111094
111395
|
}
|
|
111095
111396
|
function emitNamedTupleMember(node) {
|
|
@@ -111101,21 +111402,21 @@ var ts;
|
|
|
111101
111402
|
emit(node.type);
|
|
111102
111403
|
}
|
|
111103
111404
|
function emitOptionalType(node) {
|
|
111104
|
-
emit(node.type, parenthesizer.
|
|
111405
|
+
emit(node.type, parenthesizer.parenthesizeTypeOfOptionalType);
|
|
111105
111406
|
writePunctuation("?");
|
|
111106
111407
|
}
|
|
111107
111408
|
function emitUnionType(node) {
|
|
111108
|
-
emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.
|
|
111409
|
+
emitList(node, node.types, 516 /* UnionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfUnionType);
|
|
111109
111410
|
}
|
|
111110
111411
|
function emitIntersectionType(node) {
|
|
111111
|
-
emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.
|
|
111412
|
+
emitList(node, node.types, 520 /* IntersectionTypeConstituents */, parenthesizer.parenthesizeConstituentTypeOfIntersectionType);
|
|
111112
111413
|
}
|
|
111113
111414
|
function emitConditionalType(node) {
|
|
111114
|
-
emit(node.checkType, parenthesizer.
|
|
111415
|
+
emit(node.checkType, parenthesizer.parenthesizeCheckTypeOfConditionalType);
|
|
111115
111416
|
writeSpace();
|
|
111116
111417
|
writeKeyword("extends");
|
|
111117
111418
|
writeSpace();
|
|
111118
|
-
emit(node.extendsType, parenthesizer.
|
|
111419
|
+
emit(node.extendsType, parenthesizer.parenthesizeExtendsTypeOfConditionalType);
|
|
111119
111420
|
writeSpace();
|
|
111120
111421
|
writePunctuation("?");
|
|
111121
111422
|
writeSpace();
|
|
@@ -111141,10 +111442,13 @@ var ts;
|
|
|
111141
111442
|
function emitTypeOperator(node) {
|
|
111142
111443
|
writeTokenText(node.operator, writeKeyword);
|
|
111143
111444
|
writeSpace();
|
|
111144
|
-
|
|
111445
|
+
var parenthesizerRule = node.operator === 145 /* ReadonlyKeyword */ ?
|
|
111446
|
+
parenthesizer.parenthesizeOperandOfReadonlyTypeOperator :
|
|
111447
|
+
parenthesizer.parenthesizeOperandOfTypeOperator;
|
|
111448
|
+
emit(node.type, parenthesizerRule);
|
|
111145
111449
|
}
|
|
111146
111450
|
function emitIndexedAccessType(node) {
|
|
111147
|
-
emit(node.objectType, parenthesizer.
|
|
111451
|
+
emit(node.objectType, parenthesizer.parenthesizeNonArrayTypeOfPostfixType);
|
|
111148
111452
|
writePunctuation("[");
|
|
111149
111453
|
emit(node.indexType);
|
|
111150
111454
|
writePunctuation("]");
|
|
@@ -112878,7 +113182,7 @@ var ts;
|
|
|
112878
113182
|
emitList(parentNode, decorators, 2146305 /* Decorators */);
|
|
112879
113183
|
}
|
|
112880
113184
|
function emitTypeArguments(parentNode, typeArguments) {
|
|
112881
|
-
emitList(parentNode, typeArguments, 53776 /* TypeArguments */,
|
|
113185
|
+
emitList(parentNode, typeArguments, 53776 /* TypeArguments */, typeArgumentParenthesizerRuleSelector);
|
|
112882
113186
|
}
|
|
112883
113187
|
function emitTypeParameters(parentNode, typeParameters) {
|
|
112884
113188
|
if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) { // Quick info uses type arguments in place of type parameters on instantiated signatures
|
|
@@ -112997,6 +113301,7 @@ var ts;
|
|
|
112997
113301
|
if (format & 128 /* Indented */) {
|
|
112998
113302
|
increaseIndent();
|
|
112999
113303
|
}
|
|
113304
|
+
var emitListItem = getEmitListItem(emit, parenthesizerRule);
|
|
113000
113305
|
// Emit each child.
|
|
113001
113306
|
var previousSibling = void 0;
|
|
113002
113307
|
var previousSourceFileTextKind = void 0;
|
|
@@ -113047,12 +113352,7 @@ var ts;
|
|
|
113047
113352
|
shouldEmitInterveningComments = mayEmitInterveningComments;
|
|
113048
113353
|
}
|
|
113049
113354
|
nextListElementPos = child.pos;
|
|
113050
|
-
|
|
113051
|
-
emit(child);
|
|
113052
|
-
}
|
|
113053
|
-
else {
|
|
113054
|
-
emit(child, parenthesizerRule);
|
|
113055
|
-
}
|
|
113355
|
+
emitListItem(child, emit, parenthesizerRule, i);
|
|
113056
113356
|
if (shouldDecreaseIndentAfterEmit) {
|
|
113057
113357
|
decreaseIndent();
|
|
113058
113358
|
shouldDecreaseIndentAfterEmit = false;
|
|
@@ -114293,6 +114593,20 @@ var ts;
|
|
|
114293
114593
|
TempFlags[TempFlags["CountMask"] = 268435455] = "CountMask";
|
|
114294
114594
|
TempFlags[TempFlags["_i"] = 268435456] = "_i";
|
|
114295
114595
|
})(TempFlags || (TempFlags = {}));
|
|
114596
|
+
function emitListItemNoParenthesizer(node, emit, _parenthesizerRule, _index) {
|
|
114597
|
+
emit(node);
|
|
114598
|
+
}
|
|
114599
|
+
function emitListItemWithParenthesizerRuleSelector(node, emit, parenthesizerRuleSelector, index) {
|
|
114600
|
+
emit(node, parenthesizerRuleSelector.select(index));
|
|
114601
|
+
}
|
|
114602
|
+
function emitListItemWithParenthesizerRule(node, emit, parenthesizerRule, _index) {
|
|
114603
|
+
emit(node, parenthesizerRule);
|
|
114604
|
+
}
|
|
114605
|
+
function getEmitListItem(emit, parenthesizerRule) {
|
|
114606
|
+
return emit.length === 1 ? emitListItemNoParenthesizer :
|
|
114607
|
+
typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
|
|
114608
|
+
emitListItemWithParenthesizerRule;
|
|
114609
|
+
}
|
|
114296
114610
|
})(ts || (ts = {}));
|
|
114297
114611
|
/* @internal */
|
|
114298
114612
|
var ts;
|
|
@@ -116359,7 +116673,7 @@ var ts;
|
|
|
116359
116673
|
// moduleAugmentations has changed
|
|
116360
116674
|
structureIsReused = 1 /* SafeModules */;
|
|
116361
116675
|
}
|
|
116362
|
-
if ((oldSourceFile.flags &
|
|
116676
|
+
if ((oldSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 6291456 /* PermanentlySetIncrementalFlags */)) {
|
|
116363
116677
|
// dynamicImport has changed
|
|
116364
116678
|
structureIsReused = 1 /* SafeModules */;
|
|
116365
116679
|
}
|
|
@@ -116523,6 +116837,9 @@ var ts;
|
|
|
116523
116837
|
return !!sourceFilesFoundSearchingNodeModules.get(file.path);
|
|
116524
116838
|
}
|
|
116525
116839
|
function isSourceFileDefaultLibrary(file) {
|
|
116840
|
+
if (!file.isDeclarationFile) {
|
|
116841
|
+
return false;
|
|
116842
|
+
}
|
|
116526
116843
|
if (file.hasNoDefaultLib) {
|
|
116527
116844
|
return true;
|
|
116528
116845
|
}
|
|
@@ -117034,7 +117351,7 @@ var ts;
|
|
|
117034
117351
|
var node = _a[_i];
|
|
117035
117352
|
collectModuleReferences(node, /*inAmbientModule*/ false);
|
|
117036
117353
|
}
|
|
117037
|
-
if ((file.flags &
|
|
117354
|
+
if ((file.flags & 2097152 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) {
|
|
117038
117355
|
collectDynamicImportOrRequireCalls(file);
|
|
117039
117356
|
}
|
|
117040
117357
|
file.imports = imports || ts.emptyArray;
|
|
@@ -117632,7 +117949,7 @@ var ts;
|
|
|
117632
117949
|
&& index < file.imports.length
|
|
117633
117950
|
&& !elideImport
|
|
117634
117951
|
&& !(isJsFile && !ts.getAllowJSCompilerOption(optionsForFile))
|
|
117635
|
-
&& (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags &
|
|
117952
|
+
&& (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 8388608 /* JSDoc */));
|
|
117636
117953
|
if (elideImport) {
|
|
117637
117954
|
modulesWithElidedImports.set(file.path, true);
|
|
117638
117955
|
}
|
|
@@ -126499,7 +126816,7 @@ var ts;
|
|
|
126499
126816
|
result.push("export" /* exportedModifier */);
|
|
126500
126817
|
if (flags & 8192 /* Deprecated */)
|
|
126501
126818
|
result.push("deprecated" /* deprecatedModifier */);
|
|
126502
|
-
if (node.flags &
|
|
126819
|
+
if (node.flags & 16777216 /* Ambient */)
|
|
126503
126820
|
result.push("declare" /* ambientModifier */);
|
|
126504
126821
|
if (node.kind === 271 /* ExportAssignment */)
|
|
126505
126822
|
result.push("export" /* exportedModifier */);
|
|
@@ -132815,7 +133132,7 @@ var ts;
|
|
|
132815
133132
|
var instantiatedType = tryGetObjectLiteralContextualType(objectLikeContainer, typeChecker);
|
|
132816
133133
|
// Check completions for Object property value shorthand
|
|
132817
133134
|
if (instantiatedType === undefined) {
|
|
132818
|
-
if (objectLikeContainer.flags &
|
|
133135
|
+
if (objectLikeContainer.flags & 33554432 /* InWithStatement */) {
|
|
132819
133136
|
return 2 /* Fail */;
|
|
132820
133137
|
}
|
|
132821
133138
|
isNonContextualObjectLiteral = true;
|
|
@@ -135478,17 +135795,25 @@ var ts;
|
|
|
135478
135795
|
var options = { use: 1 /* References */ };
|
|
135479
135796
|
var referencedSymbols = Core.getReferencedSymbolsForNode(position, node, program, sourceFiles, cancellationToken, options);
|
|
135480
135797
|
var checker = program.getTypeChecker();
|
|
135481
|
-
|
|
135798
|
+
// Unless the starting node is a declaration (vs e.g. JSDoc), don't attempt to compute isDefinition
|
|
135799
|
+
var adjustedNode = Core.getAdjustedNode(node, options);
|
|
135800
|
+
var symbol = isDefinitionForReference(adjustedNode) ? checker.getSymbolAtLocation(adjustedNode) : undefined;
|
|
135482
135801
|
return !referencedSymbols || !referencedSymbols.length ? undefined : ts.mapDefined(referencedSymbols, function (_a) {
|
|
135483
135802
|
var definition = _a.definition, references = _a.references;
|
|
135484
135803
|
// Only include referenced symbols that have a valid definition.
|
|
135485
135804
|
return definition && {
|
|
135486
135805
|
definition: checker.runWithCancellationToken(cancellationToken, function (checker) { return definitionToReferencedSymbolDefinitionInfo(definition, checker, node); }),
|
|
135487
|
-
references: references.map(function (r) { return
|
|
135806
|
+
references: references.map(function (r) { return toReferencedSymbolEntry(r, symbol); })
|
|
135488
135807
|
};
|
|
135489
135808
|
});
|
|
135490
135809
|
}
|
|
135491
135810
|
FindAllReferences.findReferencedSymbols = findReferencedSymbols;
|
|
135811
|
+
function isDefinitionForReference(node) {
|
|
135812
|
+
return node.kind === 88 /* DefaultKeyword */
|
|
135813
|
+
|| !!ts.getDeclarationFromName(node)
|
|
135814
|
+
|| ts.isLiteralComputedPropertyDeclarationName(node)
|
|
135815
|
+
|| (node.kind === 134 /* ConstructorKeyword */ && ts.isConstructorDeclaration(node.parent));
|
|
135816
|
+
}
|
|
135492
135817
|
function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
|
|
135493
135818
|
var node = ts.getTouchingPropertyName(sourceFile, position);
|
|
135494
135819
|
var referenceEntries;
|
|
@@ -135617,13 +135942,19 @@ var ts;
|
|
|
135617
135942
|
return __assign(__assign({}, entryToDocumentSpan(entry)), (providePrefixAndSuffixText && getPrefixAndSuffixText(entry, originalNode, checker)));
|
|
135618
135943
|
}
|
|
135619
135944
|
FindAllReferences.toRenameLocation = toRenameLocation;
|
|
135620
|
-
function
|
|
135945
|
+
function toReferencedSymbolEntry(entry, symbol) {
|
|
135946
|
+
var referenceEntry = toReferenceEntry(entry);
|
|
135947
|
+
if (!symbol)
|
|
135948
|
+
return referenceEntry;
|
|
135949
|
+
return __assign(__assign({}, referenceEntry), { isDefinition: entry.kind !== 0 /* Span */ && isDeclarationOfSymbol(entry.node, symbol) });
|
|
135950
|
+
}
|
|
135951
|
+
function toReferenceEntry(entry) {
|
|
135621
135952
|
var documentSpan = entryToDocumentSpan(entry);
|
|
135622
135953
|
if (entry.kind === 0 /* Span */) {
|
|
135623
|
-
return __assign(__assign({}, documentSpan), { isWriteAccess: false
|
|
135954
|
+
return __assign(__assign({}, documentSpan), { isWriteAccess: false });
|
|
135624
135955
|
}
|
|
135625
135956
|
var kind = entry.kind, node = entry.node;
|
|
135626
|
-
return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node),
|
|
135957
|
+
return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined });
|
|
135627
135958
|
}
|
|
135628
135959
|
FindAllReferences.toReferenceEntry = toReferenceEntry;
|
|
135629
135960
|
function entryToDocumentSpan(entry) {
|
|
@@ -135766,7 +136097,7 @@ var ts;
|
|
|
135766
136097
|
*/
|
|
135767
136098
|
function declarationIsWriteAccess(decl) {
|
|
135768
136099
|
// Consider anything in an ambient declaration to be a write access since it may be coming from JS.
|
|
135769
|
-
if (!!(decl.flags &
|
|
136100
|
+
if (!!(decl.flags & 16777216 /* Ambient */))
|
|
135770
136101
|
return true;
|
|
135771
136102
|
switch (decl.kind) {
|
|
135772
136103
|
case 221 /* BinaryExpression */:
|
|
@@ -136331,15 +136662,21 @@ var ts;
|
|
|
136331
136662
|
}
|
|
136332
136663
|
function eachExportReference(sourceFiles, checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName, isDefaultExport, cb) {
|
|
136333
136664
|
var importTracker = FindAllReferences.createImportTracker(sourceFiles, new ts.Set(sourceFiles.map(function (f) { return f.fileName; })), checker, cancellationToken);
|
|
136334
|
-
var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers;
|
|
136665
|
+
var _a = importTracker(exportSymbol, { exportKind: isDefaultExport ? 1 /* Default */ : 0 /* Named */, exportingModuleSymbol: exportingModuleSymbol }, /*isForRename*/ false), importSearches = _a.importSearches, indirectUsers = _a.indirectUsers, singleReferences = _a.singleReferences;
|
|
136335
136666
|
for (var _i = 0, importSearches_2 = importSearches; _i < importSearches_2.length; _i++) {
|
|
136336
136667
|
var importLocation = importSearches_2[_i][0];
|
|
136337
136668
|
cb(importLocation);
|
|
136338
136669
|
}
|
|
136339
|
-
for (var _b = 0,
|
|
136340
|
-
var
|
|
136341
|
-
|
|
136342
|
-
|
|
136670
|
+
for (var _b = 0, singleReferences_2 = singleReferences; _b < singleReferences_2.length; _b++) {
|
|
136671
|
+
var singleReference = singleReferences_2[_b];
|
|
136672
|
+
if (ts.isIdentifier(singleReference) && ts.isImportTypeNode(singleReference.parent)) {
|
|
136673
|
+
cb(singleReference);
|
|
136674
|
+
}
|
|
136675
|
+
}
|
|
136676
|
+
for (var _c = 0, indirectUsers_2 = indirectUsers; _c < indirectUsers_2.length; _c++) {
|
|
136677
|
+
var indirectUser = indirectUsers_2[_c];
|
|
136678
|
+
for (var _d = 0, _e = getPossibleSymbolReferenceNodes(indirectUser, isDefaultExport ? "default" : exportName); _d < _e.length; _d++) {
|
|
136679
|
+
var node = _e[_d];
|
|
136343
136680
|
// Import specifiers should be handled by importSearches
|
|
136344
136681
|
var symbol = checker.getSymbolAtLocation(node);
|
|
136345
136682
|
var hasExportAssignmentDeclaration = ts.some(symbol === null || symbol === void 0 ? void 0 : symbol.declarations, function (d) { return ts.tryCast(d, ts.isExportAssignment) ? true : false; });
|
|
@@ -137341,7 +137678,7 @@ var ts;
|
|
|
137341
137678
|
}
|
|
137342
137679
|
Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations;
|
|
137343
137680
|
function isImplementation(node) {
|
|
137344
|
-
return !!(node.flags &
|
|
137681
|
+
return !!(node.flags & 16777216 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) :
|
|
137345
137682
|
(ts.isVariableLike(node) ? ts.hasInitializer(node) :
|
|
137346
137683
|
ts.isFunctionLikeDeclaration(node) ? !!node.body :
|
|
137347
137684
|
ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node));
|
|
@@ -137719,7 +138056,7 @@ var ts;
|
|
|
137719
138056
|
function collect(node) {
|
|
137720
138057
|
if (!node)
|
|
137721
138058
|
return;
|
|
137722
|
-
if (node.flags &
|
|
138059
|
+
if (node.flags & 16777216 /* Ambient */) {
|
|
137723
138060
|
// do not descend into ambient nodes.
|
|
137724
138061
|
return;
|
|
137725
138062
|
}
|
|
@@ -137878,7 +138215,7 @@ var ts;
|
|
|
137878
138215
|
}
|
|
137879
138216
|
/** Gets the call sites that call out of the provided call hierarchy declaration. */
|
|
137880
138217
|
function getOutgoingCalls(program, declaration) {
|
|
137881
|
-
if (declaration.flags &
|
|
138218
|
+
if (declaration.flags & 16777216 /* Ambient */ || ts.isMethodSignature(declaration)) {
|
|
137882
138219
|
return [];
|
|
137883
138220
|
}
|
|
137884
138221
|
return ts.group(collectCallSites(program, declaration), getCallSiteGroupKey, function (entries) { return convertCallSiteGroupToOutgoingCall(program, entries); });
|
|
@@ -140012,8 +140349,8 @@ var ts;
|
|
|
140012
140349
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
140013
140350
|
var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
|
|
140014
140351
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
140015
|
-
var
|
|
140016
|
-
organizeImportsWorker(
|
|
140352
|
+
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
140353
|
+
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
|
|
140017
140354
|
// All of the old ExportDeclarations in the file, in syntactic order.
|
|
140018
140355
|
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
|
|
140019
140356
|
organizeImportsWorker(topLevelExportDecls, coalesceExports);
|
|
@@ -140021,8 +140358,8 @@ var ts;
|
|
|
140021
140358
|
var ambientModule = _a[_i];
|
|
140022
140359
|
if (!ambientModule.body)
|
|
140023
140360
|
continue;
|
|
140024
|
-
var
|
|
140025
|
-
organizeImportsWorker(
|
|
140361
|
+
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
140362
|
+
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
|
|
140026
140363
|
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
|
|
140027
140364
|
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
|
|
140028
140365
|
}
|
|
@@ -140068,6 +140405,40 @@ var ts;
|
|
|
140068
140405
|
}
|
|
140069
140406
|
}
|
|
140070
140407
|
OrganizeImports.organizeImports = organizeImports;
|
|
140408
|
+
function groupImportsByNewlineContiguous(sourceFile, importDecls) {
|
|
140409
|
+
var scanner = ts.createScanner(sourceFile.languageVersion, /*skipTrivia*/ false, sourceFile.languageVariant);
|
|
140410
|
+
var groupImports = [];
|
|
140411
|
+
var groupIndex = 0;
|
|
140412
|
+
for (var _i = 0, importDecls_1 = importDecls; _i < importDecls_1.length; _i++) {
|
|
140413
|
+
var topLevelImportDecl = importDecls_1[_i];
|
|
140414
|
+
if (isNewGroup(sourceFile, topLevelImportDecl, scanner)) {
|
|
140415
|
+
groupIndex++;
|
|
140416
|
+
}
|
|
140417
|
+
if (!groupImports[groupIndex]) {
|
|
140418
|
+
groupImports[groupIndex] = [];
|
|
140419
|
+
}
|
|
140420
|
+
groupImports[groupIndex].push(topLevelImportDecl);
|
|
140421
|
+
}
|
|
140422
|
+
return groupImports;
|
|
140423
|
+
}
|
|
140424
|
+
// a new group is created if an import includes at least two new line
|
|
140425
|
+
// new line from multi-line comment doesn't count
|
|
140426
|
+
function isNewGroup(sourceFile, topLevelImportDecl, scanner) {
|
|
140427
|
+
var startPos = topLevelImportDecl.getFullStart();
|
|
140428
|
+
var endPos = topLevelImportDecl.getStart();
|
|
140429
|
+
scanner.setText(sourceFile.text, startPos, endPos - startPos);
|
|
140430
|
+
var numberOfNewLines = 0;
|
|
140431
|
+
while (scanner.getTokenPos() < endPos) {
|
|
140432
|
+
var tokenKind = scanner.scan();
|
|
140433
|
+
if (tokenKind === 4 /* NewLineTrivia */) {
|
|
140434
|
+
numberOfNewLines++;
|
|
140435
|
+
if (numberOfNewLines >= 2) {
|
|
140436
|
+
return true;
|
|
140437
|
+
}
|
|
140438
|
+
}
|
|
140439
|
+
}
|
|
140440
|
+
return false;
|
|
140441
|
+
}
|
|
140071
140442
|
function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
|
|
140072
140443
|
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
140073
140444
|
if (skipDestructiveCodeActions) {
|
|
@@ -148028,8 +148399,11 @@ var ts;
|
|
|
148028
148399
|
function isTrivia(s) {
|
|
148029
148400
|
return ts.skipTrivia(s, 0) === s.length;
|
|
148030
148401
|
}
|
|
148402
|
+
// A transformation context that won't perform parenthesization, as some parenthesization rules
|
|
148403
|
+
// are more aggressive than is strictly necessary.
|
|
148404
|
+
var textChangesTransformationContext = __assign(__assign({}, ts.nullTransformationContext), { factory: ts.createNodeFactory(ts.nullTransformationContext.factory.flags | 1 /* NoParenthesizerRules */, ts.nullTransformationContext.factory.baseFactory) });
|
|
148031
148405
|
function assignPositionsToNode(node) {
|
|
148032
|
-
var visited = ts.visitEachChild(node, assignPositionsToNode,
|
|
148406
|
+
var visited = ts.visitEachChild(node, assignPositionsToNode, textChangesTransformationContext, assignPositionsToNodeArray, assignPositionsToNode);
|
|
148033
148407
|
// create proxy node for non synthesized nodes
|
|
148034
148408
|
var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited);
|
|
148035
148409
|
ts.setTextRangePosEnd(newNode, getPos(node), getEnd(node));
|
|
@@ -155994,7 +156368,7 @@ var ts;
|
|
|
155994
156368
|
var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
|
|
155995
156369
|
var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
|
|
155996
156370
|
var optional = !!(symbol.flags & 16777216 /* Optional */);
|
|
155997
|
-
var ambient = !!(enclosingDeclaration.flags &
|
|
156371
|
+
var ambient = !!(enclosingDeclaration.flags & 16777216 /* Ambient */) || isAmbient;
|
|
155998
156372
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
155999
156373
|
switch (declaration.kind) {
|
|
156000
156374
|
case 166 /* PropertySignature */:
|
|
@@ -157571,6 +157945,10 @@ var ts;
|
|
|
157571
157945
|
}
|
|
157572
157946
|
break;
|
|
157573
157947
|
}
|
|
157948
|
+
case 200 /* ImportType */:
|
|
157949
|
+
var importTypeNode = parent;
|
|
157950
|
+
changes.replaceNode(importingSourceFile, parent, ts.factory.createImportTypeNode(importTypeNode.argument, ts.factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf));
|
|
157951
|
+
break;
|
|
157574
157952
|
default:
|
|
157575
157953
|
ts.Debug.failBadSyntaxKind(parent);
|
|
157576
157954
|
}
|
|
@@ -158511,7 +158889,7 @@ var ts;
|
|
|
158511
158889
|
// cannot find either start or end node
|
|
158512
158890
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
158513
158891
|
}
|
|
158514
|
-
if (start.flags &
|
|
158892
|
+
if (start.flags & 8388608 /* JSDoc */) {
|
|
158515
158893
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] };
|
|
158516
158894
|
}
|
|
158517
158895
|
if (start.parent !== end.parent) {
|
|
@@ -158637,7 +159015,7 @@ var ts;
|
|
|
158637
159015
|
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
|
|
158638
159016
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
|
|
158639
159017
|
}
|
|
158640
|
-
if (nodeToCheck.flags &
|
|
159018
|
+
if (nodeToCheck.flags & 16777216 /* Ambient */) {
|
|
158641
159019
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)];
|
|
158642
159020
|
}
|
|
158643
159021
|
// If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default)
|
|
@@ -160169,6 +160547,7 @@ var ts;
|
|
|
160169
160547
|
}
|
|
160170
160548
|
function doTypedefChange(changes, file, name, info) {
|
|
160171
160549
|
var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters;
|
|
160550
|
+
ts.setEmitFlags(selection, 1536 /* NoComments */ | 2048 /* NoNestedComments */);
|
|
160172
160551
|
var node = ts.factory.createJSDocTypedefTag(ts.factory.createIdentifier("typedef"), ts.factory.createJSDocTypeExpression(selection), ts.factory.createIdentifier(name));
|
|
160173
160552
|
var templates = [];
|
|
160174
160553
|
ts.forEach(typeParameters, function (typeParameter) {
|
|
@@ -162199,7 +162578,7 @@ var ts;
|
|
|
162199
162578
|
kind === 80 /* PrivateIdentifier */ ? new PrivateIdentifierObject(80 /* PrivateIdentifier */, pos, end) :
|
|
162200
162579
|
new TokenObject(kind, pos, end);
|
|
162201
162580
|
node.parent = parent;
|
|
162202
|
-
node.flags = parent.flags &
|
|
162581
|
+
node.flags = parent.flags & 50720768 /* ContextFlags */;
|
|
162203
162582
|
return node;
|
|
162204
162583
|
}
|
|
162205
162584
|
var NodeObject = /** @class */ (function () {
|
|
@@ -163655,7 +164034,7 @@ var ts;
|
|
|
163655
164034
|
}
|
|
163656
164035
|
/// References and Occurrences
|
|
163657
164036
|
function getOccurrencesAtPosition(fileName, position) {
|
|
163658
|
-
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
|
|
164037
|
+
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 */ }, highlightSpan.isInString && { isInString: true }), highlightSpan.contextSpan && { contextSpan: highlightSpan.contextSpan })); }); });
|
|
163659
164038
|
}
|
|
163660
164039
|
function getDocumentHighlights(fileName, position, filesToSearch) {
|
|
163661
164040
|
var normalizedFileName = ts.normalizePath(fileName);
|
|
@@ -163684,7 +164063,7 @@ var ts;
|
|
|
163684
164063
|
}
|
|
163685
164064
|
function getReferencesAtPosition(fileName, position) {
|
|
163686
164065
|
synchronizeHostData();
|
|
163687
|
-
return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ },
|
|
164066
|
+
return getReferencesWorker(ts.getTouchingPropertyName(getValidSourceFile(fileName), position), position, { use: 1 /* References */ }, ts.FindAllReferences.toReferenceEntry);
|
|
163688
164067
|
}
|
|
163689
164068
|
function getReferencesWorker(node, position, options, cb) {
|
|
163690
164069
|
synchronizeHostData();
|
|
@@ -163699,10 +164078,8 @@ var ts;
|
|
|
163699
164078
|
return ts.FindAllReferences.findReferencedSymbols(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position);
|
|
163700
164079
|
}
|
|
163701
164080
|
function getFileReferences(fileName) {
|
|
163702
|
-
var _a;
|
|
163703
164081
|
synchronizeHostData();
|
|
163704
|
-
|
|
163705
|
-
return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(function (r) { return ts.FindAllReferences.toReferenceEntry(r, moduleSymbol); });
|
|
164082
|
+
return ts.FindAllReferences.Core.getReferencesForFileName(fileName, program, program.getSourceFiles()).map(ts.FindAllReferences.toReferenceEntry);
|
|
163706
164083
|
}
|
|
163707
164084
|
function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) {
|
|
163708
164085
|
if (excludeDtsFiles === void 0) { excludeDtsFiles = false; }
|
|
@@ -164175,7 +164552,7 @@ var ts;
|
|
|
164175
164552
|
}
|
|
164176
164553
|
function isUnclosedFragment(_a) {
|
|
164177
164554
|
var closingFragment = _a.closingFragment, parent = _a.parent;
|
|
164178
|
-
return !!(closingFragment.flags &
|
|
164555
|
+
return !!(closingFragment.flags & 131072 /* ThisNodeHasError */) || (ts.isJsxFragment(parent) && isUnclosedFragment(parent));
|
|
164179
164556
|
}
|
|
164180
164557
|
function getSpanOfEnclosingComment(fileName, position, onlyMultiLine) {
|
|
164181
164558
|
var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
|
|
@@ -164623,7 +165000,7 @@ var ts;
|
|
|
164623
165000
|
tokenAtLocation = preceding;
|
|
164624
165001
|
}
|
|
164625
165002
|
// Cannot set breakpoint in ambient declarations
|
|
164626
|
-
if (tokenAtLocation.flags &
|
|
165003
|
+
if (tokenAtLocation.flags & 16777216 /* Ambient */) {
|
|
164627
165004
|
return undefined;
|
|
164628
165005
|
}
|
|
164629
165006
|
// Get the span in the node based on its syntax
|
|
@@ -173543,6 +173920,7 @@ var ts;
|
|
|
173543
173920
|
logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
|
|
173544
173921
|
var projectOutputs = project.getLanguageService().findReferences(location.fileName, location.pos);
|
|
173545
173922
|
if (projectOutputs) {
|
|
173923
|
+
var clearIsDefinition = projectOutputs[0].references[0].isDefinition === undefined;
|
|
173546
173924
|
var _loop_9 = function (referencedSymbol) {
|
|
173547
173925
|
var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(referencedSymbol.definition));
|
|
173548
173926
|
var definition = mappedDefinitionFile === undefined ?
|
|
@@ -173556,6 +173934,9 @@ var ts;
|
|
|
173556
173934
|
var ref = _b[_a];
|
|
173557
173935
|
// If it's in a mapped file, that is added to the todo list by `getMappedLocation`.
|
|
173558
173936
|
if (!ts.contains(symbolToAddTo.references, ref, ts.documentSpansEqual) && !getMappedLocation(project, documentSpanLocation(ref))) {
|
|
173937
|
+
if (clearIsDefinition) {
|
|
173938
|
+
delete ref.isDefinition;
|
|
173939
|
+
}
|
|
173559
173940
|
symbolToAddTo.references.push(ref);
|
|
173560
173941
|
}
|
|
173561
173942
|
}
|