@typescript-deploys/pr-build 4.6.0-pr-47550-8 → 4.6.0-pr-47607-13
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/fr/diagnosticMessages.generated.json +17 -4
- package/lib/ja/diagnosticMessages.generated.json +17 -4
- package/lib/ko/diagnosticMessages.generated.json +17 -4
- package/lib/lib.dom.d.ts +73 -1
- package/lib/lib.dom.iterable.d.ts +4 -0
- package/lib/lib.webworker.d.ts +48 -0
- package/lib/pl/diagnosticMessages.generated.json +17 -4
- package/lib/ru/diagnosticMessages.generated.json +17 -4
- package/lib/tr/diagnosticMessages.generated.json +17 -4
- package/lib/tsc.js +318 -190
- package/lib/tsserver.js +632 -302
- package/lib/tsserverlibrary.d.ts +16 -12
- package/lib/tsserverlibrary.js +632 -302
- package/lib/typescript.d.ts +16 -12
- package/lib/typescript.js +632 -302
- package/lib/typescriptServices.d.ts +16 -12
- package/lib/typescriptServices.js +632 -302
- package/lib/typingsInstaller.js +337 -221
- package/lib/zh-tw/diagnosticMessages.generated.json +17 -4
- 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-insiders.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220127";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -4918,13 +4918,14 @@ var ts;
|
|
|
4918
4918
|
// Flags that require TypeFlags.Object
|
|
4919
4919
|
ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread";
|
|
4920
4920
|
ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType";
|
|
4921
|
+
ObjectFlags[ObjectFlags["InstantiationExpressionType"] = 16777216] = "InstantiationExpressionType";
|
|
4921
4922
|
/* @internal */
|
|
4922
|
-
ObjectFlags[ObjectFlags["IsClassInstanceClone"] =
|
|
4923
|
+
ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 33554432] = "IsClassInstanceClone";
|
|
4923
4924
|
// Flags that require TypeFlags.Object and ObjectFlags.Reference
|
|
4924
4925
|
/* @internal */
|
|
4925
|
-
ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] =
|
|
4926
|
+
ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 67108864] = "IdenticalBaseTypeCalculated";
|
|
4926
4927
|
/* @internal */
|
|
4927
|
-
ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] =
|
|
4928
|
+
ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 134217728] = "IdenticalBaseTypeExists";
|
|
4928
4929
|
// Flags that require TypeFlags.UnionOrIntersection or TypeFlags.Substitution
|
|
4929
4930
|
/* @internal */
|
|
4930
4931
|
ObjectFlags[ObjectFlags["IsGenericTypeComputed"] = 4194304] = "IsGenericTypeComputed";
|
|
@@ -8530,6 +8531,7 @@ var ts;
|
|
|
8530
8531
|
Cannot_assign_to_0_because_it_is_an_import: diag(2632, ts.DiagnosticCategory.Error, "Cannot_assign_to_0_because_it_is_an_import_2632", "Cannot assign to '{0}' because it is an import."),
|
|
8531
8532
|
JSX_property_access_expressions_cannot_include_JSX_namespace_names: diag(2633, ts.DiagnosticCategory.Error, "JSX_property_access_expressions_cannot_include_JSX_namespace_names_2633", "JSX property access expressions cannot include JSX namespace names"),
|
|
8532
8533
|
_0_index_signatures_are_incompatible: diag(2634, ts.DiagnosticCategory.Error, "_0_index_signatures_are_incompatible_2634", "'{0}' index signatures are incompatible."),
|
|
8534
|
+
Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable: diag(2635, ts.DiagnosticCategory.Error, "Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable_2635", "Type '{0}' has no signatures for which the type argument list is applicable."),
|
|
8533
8535
|
Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."),
|
|
8534
8536
|
A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."),
|
|
8535
8537
|
Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."),
|
|
@@ -9473,6 +9475,8 @@ var ts;
|
|
|
9473
9475
|
Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
|
|
9474
9476
|
Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
|
|
9475
9477
|
Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
|
|
9478
|
+
Remove_type_from_import_declaration_from_0: diag(90055, ts.DiagnosticCategory.Message, "Remove_type_from_import_declaration_from_0_90055", "Remove 'type' from import declaration from \"{0}\""),
|
|
9479
|
+
Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
|
|
9476
9480
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9477
9481
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9478
9482
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -13413,6 +13417,7 @@ var ts;
|
|
|
13413
13417
|
case 110 /* TrueKeyword */:
|
|
13414
13418
|
case 106 /* SuperKeyword */:
|
|
13415
13419
|
case 229 /* NonNullExpression */:
|
|
13420
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
13416
13421
|
case 230 /* MetaProperty */:
|
|
13417
13422
|
case 100 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression
|
|
13418
13423
|
return true;
|
|
@@ -14063,10 +14068,13 @@ var ts;
|
|
|
14063
14068
|
function packageIdIsEqual(a, b) {
|
|
14064
14069
|
return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
|
|
14065
14070
|
}
|
|
14066
|
-
function
|
|
14067
|
-
var name = _a.name, subModuleName = _a.subModuleName
|
|
14068
|
-
|
|
14069
|
-
|
|
14071
|
+
function packageIdToPackageName(_a) {
|
|
14072
|
+
var name = _a.name, subModuleName = _a.subModuleName;
|
|
14073
|
+
return subModuleName ? name + "/" + subModuleName : name;
|
|
14074
|
+
}
|
|
14075
|
+
ts.packageIdToPackageName = packageIdToPackageName;
|
|
14076
|
+
function packageIdToString(packageId) {
|
|
14077
|
+
return packageIdToPackageName(packageId) + "@" + packageId.version;
|
|
14070
14078
|
}
|
|
14071
14079
|
ts.packageIdToString = packageIdToString;
|
|
14072
14080
|
function typeDirectiveIsEqualTo(oldResolution, newResolution) {
|
|
@@ -14899,6 +14907,15 @@ var ts;
|
|
|
14899
14907
|
};
|
|
14900
14908
|
}
|
|
14901
14909
|
ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain;
|
|
14910
|
+
function createDiagnosticMessageChainFromDiagnostic(diagnostic) {
|
|
14911
|
+
return typeof diagnostic.messageText === "string" ? {
|
|
14912
|
+
code: diagnostic.code,
|
|
14913
|
+
category: diagnostic.category,
|
|
14914
|
+
messageText: diagnostic.messageText,
|
|
14915
|
+
next: diagnostic.next,
|
|
14916
|
+
} : diagnostic.messageText;
|
|
14917
|
+
}
|
|
14918
|
+
ts.createDiagnosticMessageChainFromDiagnostic = createDiagnosticMessageChainFromDiagnostic;
|
|
14902
14919
|
function createDiagnosticForRange(sourceFile, range, message) {
|
|
14903
14920
|
return {
|
|
14904
14921
|
file: sourceFile,
|
|
@@ -15067,7 +15084,8 @@ var ts;
|
|
|
15067
15084
|
node.kind === 212 /* FunctionExpression */ ||
|
|
15068
15085
|
node.kind === 213 /* ArrowFunction */ ||
|
|
15069
15086
|
node.kind === 211 /* ParenthesizedExpression */ ||
|
|
15070
|
-
node.kind === 253 /* VariableDeclaration */
|
|
15087
|
+
node.kind === 253 /* VariableDeclaration */ ||
|
|
15088
|
+
node.kind === 274 /* ExportSpecifier */) ?
|
|
15071
15089
|
ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
|
|
15072
15090
|
ts.getLeadingCommentRanges(text, node.pos);
|
|
15073
15091
|
// True if the comment starts with '/**' but not if it is '/**/'
|
|
@@ -15101,7 +15119,7 @@ var ts;
|
|
|
15101
15119
|
case 114 /* VoidKeyword */:
|
|
15102
15120
|
return node.parent.kind !== 216 /* VoidExpression */;
|
|
15103
15121
|
case 227 /* ExpressionWithTypeArguments */:
|
|
15104
|
-
return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
15122
|
+
return ts.isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
15105
15123
|
case 162 /* TypeParameter */:
|
|
15106
15124
|
return node.parent.kind === 194 /* MappedType */ || node.parent.kind === 189 /* InferType */;
|
|
15107
15125
|
// Identifiers and qualified names may be type nodes, depending on their context. Climb
|
|
@@ -15138,7 +15156,7 @@ var ts;
|
|
|
15138
15156
|
}
|
|
15139
15157
|
switch (parent.kind) {
|
|
15140
15158
|
case 227 /* ExpressionWithTypeArguments */:
|
|
15141
|
-
return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
|
15159
|
+
return ts.isHeritageClause(parent.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
|
|
15142
15160
|
case 162 /* TypeParameter */:
|
|
15143
15161
|
return node === parent.constraint;
|
|
15144
15162
|
case 342 /* JSDocTemplateTag */:
|
|
@@ -15841,7 +15859,7 @@ var ts;
|
|
|
15841
15859
|
case 296 /* SpreadAssignment */:
|
|
15842
15860
|
return true;
|
|
15843
15861
|
case 227 /* ExpressionWithTypeArguments */:
|
|
15844
|
-
return parent.expression === node &&
|
|
15862
|
+
return parent.expression === node && !isPartOfTypeNode(parent);
|
|
15845
15863
|
case 295 /* ShorthandPropertyAssignment */:
|
|
15846
15864
|
return parent.objectAssignmentInitializer === node;
|
|
15847
15865
|
default:
|
|
@@ -22775,16 +22793,18 @@ var ts;
|
|
|
22775
22793
|
return updateConstructorTypeNode1(node, node.modifiers, typeParameters, parameters, type);
|
|
22776
22794
|
}
|
|
22777
22795
|
// @api
|
|
22778
|
-
function createTypeQueryNode(exprName) {
|
|
22796
|
+
function createTypeQueryNode(exprName, typeArguments) {
|
|
22779
22797
|
var node = createBaseNode(180 /* TypeQuery */);
|
|
22780
22798
|
node.exprName = exprName;
|
|
22799
|
+
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
22781
22800
|
node.transformFlags = 1 /* ContainsTypeScript */;
|
|
22782
22801
|
return node;
|
|
22783
22802
|
}
|
|
22784
22803
|
// @api
|
|
22785
|
-
function updateTypeQueryNode(node, exprName) {
|
|
22804
|
+
function updateTypeQueryNode(node, exprName, typeArguments) {
|
|
22786
22805
|
return node.exprName !== exprName
|
|
22787
|
-
|
|
22806
|
+
|| node.typeArguments !== typeArguments
|
|
22807
|
+
? update(createTypeQueryNode(exprName, typeArguments), node)
|
|
22788
22808
|
: node;
|
|
22789
22809
|
}
|
|
22790
22810
|
// @api
|
|
@@ -29900,7 +29920,8 @@ var ts;
|
|
|
29900
29920
|
visitNode(cbNode, node.parameterName) ||
|
|
29901
29921
|
visitNode(cbNode, node.type);
|
|
29902
29922
|
case 180 /* TypeQuery */:
|
|
29903
|
-
return visitNode(cbNode, node.exprName)
|
|
29923
|
+
return visitNode(cbNode, node.exprName) ||
|
|
29924
|
+
visitNodes(cbNode, cbNodes, node.typeArguments);
|
|
29904
29925
|
case 181 /* TypeLiteral */:
|
|
29905
29926
|
return visitNodes(cbNode, cbNodes, node.members);
|
|
29906
29927
|
case 182 /* ArrayType */:
|
|
@@ -32433,7 +32454,9 @@ var ts;
|
|
|
32433
32454
|
function parseTypeQuery() {
|
|
32434
32455
|
var pos = getNodePos();
|
|
32435
32456
|
parseExpected(112 /* TypeOfKeyword */);
|
|
32436
|
-
|
|
32457
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true);
|
|
32458
|
+
var typeArguments = tryParseTypeArguments();
|
|
32459
|
+
return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
|
|
32437
32460
|
}
|
|
32438
32461
|
function parseTypeParameter() {
|
|
32439
32462
|
var pos = getNodePos();
|
|
@@ -33372,7 +33395,7 @@ var ts;
|
|
|
33372
33395
|
function parseInitializer() {
|
|
33373
33396
|
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
33374
33397
|
}
|
|
33375
|
-
function parseAssignmentExpressionOrHigher(
|
|
33398
|
+
function parseAssignmentExpressionOrHigher() {
|
|
33376
33399
|
// AssignmentExpression[in,yield]:
|
|
33377
33400
|
// 1) ConditionalExpression[?in,?yield]
|
|
33378
33401
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
@@ -33398,7 +33421,7 @@ var ts;
|
|
|
33398
33421
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
33399
33422
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
33400
33423
|
// with AssignmentExpression if we see one.
|
|
33401
|
-
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(
|
|
33424
|
+
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
33402
33425
|
if (arrowExpression) {
|
|
33403
33426
|
return arrowExpression;
|
|
33404
33427
|
}
|
|
@@ -33417,7 +33440,7 @@ var ts;
|
|
|
33417
33440
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
33418
33441
|
// identifier and the current token is an arrow.
|
|
33419
33442
|
if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
|
|
33420
|
-
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined
|
|
33443
|
+
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
|
|
33421
33444
|
}
|
|
33422
33445
|
// Now see if we might be in cases '2' or '3'.
|
|
33423
33446
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
@@ -33477,7 +33500,7 @@ var ts;
|
|
|
33477
33500
|
return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
|
|
33478
33501
|
}
|
|
33479
33502
|
}
|
|
33480
|
-
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier
|
|
33503
|
+
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
|
|
33481
33504
|
ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
33482
33505
|
var parameter = factory.createParameterDeclaration(
|
|
33483
33506
|
/*decorators*/ undefined,
|
|
@@ -33489,11 +33512,11 @@ var ts;
|
|
|
33489
33512
|
finishNode(parameter, identifier.pos);
|
|
33490
33513
|
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
33491
33514
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
33492
|
-
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier
|
|
33515
|
+
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
33493
33516
|
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
|
33494
33517
|
return addJSDocComment(finishNode(node, pos));
|
|
33495
33518
|
}
|
|
33496
|
-
function tryParseParenthesizedArrowFunctionExpression(
|
|
33519
|
+
function tryParseParenthesizedArrowFunctionExpression() {
|
|
33497
33520
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
33498
33521
|
if (triState === 0 /* False */) {
|
|
33499
33522
|
// It's definitely not a parenthesized arrow function expression.
|
|
@@ -33504,8 +33527,8 @@ var ts;
|
|
|
33504
33527
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
33505
33528
|
// expression instead.
|
|
33506
33529
|
return triState === 1 /* True */ ?
|
|
33507
|
-
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true
|
|
33508
|
-
tryParse(
|
|
33530
|
+
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
|
33531
|
+
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
|
33509
33532
|
}
|
|
33510
33533
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
33511
33534
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
@@ -33635,25 +33658,25 @@ var ts;
|
|
|
33635
33658
|
return 2 /* Unknown */;
|
|
33636
33659
|
}
|
|
33637
33660
|
}
|
|
33638
|
-
function parsePossibleParenthesizedArrowFunctionExpression(
|
|
33661
|
+
function parsePossibleParenthesizedArrowFunctionExpression() {
|
|
33639
33662
|
var tokenPos = scanner.getTokenPos();
|
|
33640
33663
|
if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
|
|
33641
33664
|
return undefined;
|
|
33642
33665
|
}
|
|
33643
|
-
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false
|
|
33666
|
+
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
|
33644
33667
|
if (!result) {
|
|
33645
33668
|
(notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
|
|
33646
33669
|
}
|
|
33647
33670
|
return result;
|
|
33648
33671
|
}
|
|
33649
|
-
function tryParseAsyncSimpleArrowFunctionExpression(
|
|
33672
|
+
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
33650
33673
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
33651
33674
|
if (token() === 131 /* AsyncKeyword */) {
|
|
33652
33675
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
33653
33676
|
var pos = getNodePos();
|
|
33654
33677
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
33655
33678
|
var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
|
|
33656
|
-
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier
|
|
33679
|
+
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
|
|
33657
33680
|
}
|
|
33658
33681
|
}
|
|
33659
33682
|
return undefined;
|
|
@@ -33677,7 +33700,7 @@ var ts;
|
|
|
33677
33700
|
}
|
|
33678
33701
|
return 0 /* False */;
|
|
33679
33702
|
}
|
|
33680
|
-
function parseParenthesizedArrowFunctionExpression(allowAmbiguity
|
|
33703
|
+
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
|
|
33681
33704
|
var pos = getNodePos();
|
|
33682
33705
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
33683
33706
|
var modifiers = parseModifiersForArrowFunction();
|
|
@@ -33703,20 +33726,6 @@ var ts;
|
|
|
33703
33726
|
return undefined;
|
|
33704
33727
|
}
|
|
33705
33728
|
}
|
|
33706
|
-
// Given:
|
|
33707
|
-
// x ? y => ({ y }) : z => ({ z })
|
|
33708
|
-
// We try to parse the body of the first arrow function by looking at:
|
|
33709
|
-
// ({ y }) : z => ({ z })
|
|
33710
|
-
// This is a valid arrow function with "z" as the return type.
|
|
33711
|
-
//
|
|
33712
|
-
// But, if we're in the true side of a conditional expression, this colon
|
|
33713
|
-
// terminates the true side, so cannot be the return type. If we are in the
|
|
33714
|
-
// false side, we may still be within the true side of a parent conditional
|
|
33715
|
-
// expression, so don't allow it to be a return type either.
|
|
33716
|
-
if (parsingConditionalExpression && token() === 58 /* ColonToken */) {
|
|
33717
|
-
ts.Debug.assert(!allowAmbiguity);
|
|
33718
|
-
return undefined;
|
|
33719
|
-
}
|
|
33720
33729
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
33721
33730
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
33722
33731
|
return undefined;
|
|
@@ -33750,7 +33759,7 @@ var ts;
|
|
|
33750
33759
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
33751
33760
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
33752
33761
|
}
|
|
33753
|
-
function parseArrowFunctionExpressionBody(isAsync
|
|
33762
|
+
function parseArrowFunctionExpressionBody(isAsync) {
|
|
33754
33763
|
if (token() === 18 /* OpenBraceToken */) {
|
|
33755
33764
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
33756
33765
|
}
|
|
@@ -33778,8 +33787,8 @@ var ts;
|
|
|
33778
33787
|
var savedTopLevel = topLevel;
|
|
33779
33788
|
topLevel = false;
|
|
33780
33789
|
var node = isAsync
|
|
33781
|
-
? doInAwaitContext(
|
|
33782
|
-
: doOutsideOfAwaitContext(
|
|
33790
|
+
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
33791
|
+
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
33783
33792
|
topLevel = savedTopLevel;
|
|
33784
33793
|
return node;
|
|
33785
33794
|
}
|
|
@@ -33792,8 +33801,8 @@ var ts;
|
|
|
33792
33801
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
33793
33802
|
// we do not that for the 'whenFalse' part.
|
|
33794
33803
|
var colonToken;
|
|
33795
|
-
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext,
|
|
33796
|
-
? parseAssignmentExpressionOrHigher(
|
|
33804
|
+
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
33805
|
+
? parseAssignmentExpressionOrHigher()
|
|
33797
33806
|
: createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
|
|
33798
33807
|
}
|
|
33799
33808
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
@@ -34564,12 +34573,16 @@ var ts;
|
|
|
34564
34573
|
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34565
34574
|
continue;
|
|
34566
34575
|
}
|
|
34567
|
-
|
|
34568
|
-
|
|
34569
|
-
|
|
34570
|
-
|
|
34571
|
-
|
|
34572
|
-
|
|
34576
|
+
if (questionDotToken || token() === 20 /* OpenParenToken */) {
|
|
34577
|
+
var argumentList = parseArgumentList();
|
|
34578
|
+
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34579
|
+
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34580
|
+
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34581
|
+
expression = finishNode(callExpr, pos);
|
|
34582
|
+
continue;
|
|
34583
|
+
}
|
|
34584
|
+
expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
34585
|
+
break;
|
|
34573
34586
|
}
|
|
34574
34587
|
}
|
|
34575
34588
|
else if (token() === 20 /* OpenParenToken */) {
|
|
@@ -34609,20 +34622,23 @@ var ts;
|
|
|
34609
34622
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
34610
34623
|
return undefined;
|
|
34611
34624
|
}
|
|
34612
|
-
//
|
|
34613
|
-
//
|
|
34614
|
-
|
|
34615
|
-
|
|
34616
|
-
|
|
34625
|
+
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
34626
|
+
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
34627
|
+
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
34628
|
+
// it as a relational expression.
|
|
34629
|
+
return typeArguments && canFollowTypeArgumentsInExpression() ? typeArguments : undefined;
|
|
34617
34630
|
}
|
|
34618
34631
|
function canFollowTypeArgumentsInExpression() {
|
|
34619
34632
|
switch (token()) {
|
|
34633
|
+
// These tokens can follow a type argument list in a call expression.
|
|
34620
34634
|
case 20 /* OpenParenToken */: // foo<x>(
|
|
34621
34635
|
case 14 /* NoSubstitutionTemplateLiteral */: // foo<T> `...`
|
|
34622
34636
|
case 15 /* TemplateHead */: // foo<T> `...${100}...`
|
|
34623
|
-
//
|
|
34624
|
-
//
|
|
34637
|
+
// These tokens can't follow in a call expression, nor can they start an
|
|
34638
|
+
// expression. So, consider the type argument list part of an instantiation
|
|
34639
|
+
// expression.
|
|
34625
34640
|
// falls through
|
|
34641
|
+
case 27 /* CommaToken */: // foo<x>,
|
|
34626
34642
|
case 24 /* DotToken */: // foo<x>.
|
|
34627
34643
|
case 21 /* CloseParenToken */: // foo<x>)
|
|
34628
34644
|
case 23 /* CloseBracketToken */: // foo<x>]
|
|
@@ -34641,20 +34657,10 @@ var ts;
|
|
|
34641
34657
|
case 51 /* BarToken */: // foo<x> |
|
|
34642
34658
|
case 19 /* CloseBraceToken */: // foo<x> }
|
|
34643
34659
|
case 1 /* EndOfFileToken */: // foo<x>
|
|
34644
|
-
// these cases can't legally follow a type arg list. However, they're not legal
|
|
34645
|
-
// expressions either. The user is probably in the middle of a generic type. So
|
|
34646
|
-
// treat it as such.
|
|
34647
34660
|
return true;
|
|
34648
|
-
case 27 /* CommaToken */: // foo<x>,
|
|
34649
|
-
case 18 /* OpenBraceToken */: // foo<x> {
|
|
34650
|
-
// We don't want to treat these as type arguments. Otherwise we'll parse this
|
|
34651
|
-
// as an invocation expression. Instead, we want to parse out the expression
|
|
34652
|
-
// in isolation from the type arguments.
|
|
34653
|
-
// falls through
|
|
34654
|
-
default:
|
|
34655
|
-
// Anything else treat as an expression.
|
|
34656
|
-
return false;
|
|
34657
34661
|
}
|
|
34662
|
+
// Treat anything else as an expression.
|
|
34663
|
+
return false;
|
|
34658
34664
|
}
|
|
34659
34665
|
function parsePrimaryExpression() {
|
|
34660
34666
|
switch (token()) {
|
|
@@ -34835,17 +34841,12 @@ var ts;
|
|
|
34835
34841
|
return finishNode(factory.createMetaProperty(103 /* NewKeyword */, name), pos);
|
|
34836
34842
|
}
|
|
34837
34843
|
var expressionPos = getNodePos();
|
|
34838
|
-
var expression = parsePrimaryExpression();
|
|
34839
|
-
var typeArguments;
|
|
34840
|
-
|
|
34841
|
-
|
|
34842
|
-
|
|
34843
|
-
|
|
34844
|
-
ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
|
|
34845
|
-
expression = parseTaggedTemplateRest(expressionPos, expression, /*optionalChain*/ undefined, typeArguments);
|
|
34846
|
-
typeArguments = undefined;
|
|
34847
|
-
}
|
|
34848
|
-
break;
|
|
34844
|
+
var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false);
|
|
34845
|
+
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34846
|
+
if (isTemplateStartOfTaggedTemplate()) {
|
|
34847
|
+
ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
|
|
34848
|
+
expression = parseTaggedTemplateRest(expressionPos, expression, /*optionalChain*/ undefined, typeArguments);
|
|
34849
|
+
typeArguments = undefined;
|
|
34849
34850
|
}
|
|
34850
34851
|
var argumentsArray;
|
|
34851
34852
|
if (token() === 20 /* OpenParenToken */) {
|
|
@@ -35942,6 +35943,9 @@ var ts;
|
|
|
35942
35943
|
function parseExpressionWithTypeArguments() {
|
|
35943
35944
|
var pos = getNodePos();
|
|
35944
35945
|
var expression = parseLeftHandSideExpressionOrHigher();
|
|
35946
|
+
if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
35947
|
+
return expression;
|
|
35948
|
+
}
|
|
35945
35949
|
var typeArguments = tryParseTypeArguments();
|
|
35946
35950
|
return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
35947
35951
|
}
|
|
@@ -36232,7 +36236,8 @@ var ts;
|
|
|
36232
36236
|
return finishNode(node, pos);
|
|
36233
36237
|
}
|
|
36234
36238
|
function parseExportSpecifier() {
|
|
36235
|
-
|
|
36239
|
+
var hasJSDoc = hasPrecedingJSDocComment();
|
|
36240
|
+
return withJSDoc(parseImportOrExportSpecifier(274 /* ExportSpecifier */), hasJSDoc);
|
|
36236
36241
|
}
|
|
36237
36242
|
function parseImportSpecifier() {
|
|
36238
36243
|
return parseImportOrExportSpecifier(269 /* ImportSpecifier */);
|
|
@@ -43437,14 +43442,12 @@ var ts;
|
|
|
43437
43442
|
}
|
|
43438
43443
|
var binder = createBinder();
|
|
43439
43444
|
function bindSourceFile(file, options) {
|
|
43440
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
|
|
43441
43445
|
ts.performance.mark("beforeBind");
|
|
43442
43446
|
ts.perfLogger.logStartBindFile("" + file.fileName);
|
|
43443
43447
|
binder(file, options);
|
|
43444
43448
|
ts.perfLogger.logStopBindFile();
|
|
43445
43449
|
ts.performance.mark("afterBind");
|
|
43446
43450
|
ts.performance.measure("Bind", "beforeBind", "afterBind");
|
|
43447
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
43448
43451
|
}
|
|
43449
43452
|
ts.bindSourceFile = bindSourceFile;
|
|
43450
43453
|
function createBinder() {
|
|
@@ -43504,7 +43507,9 @@ var ts;
|
|
|
43504
43507
|
ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
|
|
43505
43508
|
ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
|
|
43506
43509
|
if (!file.locals) {
|
|
43510
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
|
|
43507
43511
|
bind(file);
|
|
43512
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
43508
43513
|
file.symbolCount = symbolCount;
|
|
43509
43514
|
file.classifiableNames = classifiableNames;
|
|
43510
43515
|
delayedBindJSDocTypedefTag();
|
|
@@ -47771,6 +47776,9 @@ var ts;
|
|
|
47771
47776
|
suggestionDiagnostics.add(diagnostic);
|
|
47772
47777
|
return diagnostic;
|
|
47773
47778
|
}
|
|
47779
|
+
function isDeprecatedSymbol(symbol) {
|
|
47780
|
+
return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 134217728 /* Deprecated */);
|
|
47781
|
+
}
|
|
47774
47782
|
function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
|
|
47775
47783
|
var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
|
|
47776
47784
|
return addDeprecatedSuggestionWorker(declarations, diagnostic);
|
|
@@ -50866,7 +50874,7 @@ var ts;
|
|
|
50866
50874
|
// get symbol of the first identifier of the entityName
|
|
50867
50875
|
var meaning;
|
|
50868
50876
|
if (entityName.parent.kind === 180 /* TypeQuery */ ||
|
|
50869
|
-
ts.
|
|
50877
|
+
entityName.parent.kind === 227 /* ExpressionWithTypeArguments */ && !ts.isPartOfTypeNode(entityName.parent) ||
|
|
50870
50878
|
entityName.parent.kind === 161 /* ComputedPropertyName */) {
|
|
50871
50879
|
// Typeof value
|
|
50872
50880
|
meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
|
|
@@ -50977,7 +50985,7 @@ var ts;
|
|
|
50977
50985
|
return flags & 814775659 /* NodeBuilderFlagsMask */;
|
|
50978
50986
|
}
|
|
50979
50987
|
function isClassInstanceSide(type) {
|
|
50980
|
-
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) &
|
|
50988
|
+
return !!type.symbol && !!(type.symbol.flags & 32 /* Class */) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || (!!(type.flags & 524288 /* Object */) && !!(ts.getObjectFlags(type) & 33554432 /* IsClassInstanceClone */)));
|
|
50981
50989
|
}
|
|
50982
50990
|
function createNodeBuilder() {
|
|
50983
50991
|
return {
|
|
@@ -52541,7 +52549,8 @@ var ts;
|
|
|
52541
52549
|
includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
|
|
52542
52550
|
}
|
|
52543
52551
|
if (ts.isIdentifier(node)) {
|
|
52544
|
-
var
|
|
52552
|
+
var type = getDeclaredTypeOfSymbol(sym);
|
|
52553
|
+
var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
|
|
52545
52554
|
name.symbol = sym; // for quickinfo, which uses identifier symbol information
|
|
52546
52555
|
return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
|
|
52547
52556
|
}
|
|
@@ -54904,7 +54913,7 @@ var ts;
|
|
|
54904
54913
|
members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.indexInfos);
|
|
54905
54914
|
result.objectFlags |= (ts.getObjectFlags(type) & 8192 /* JSLiteral */); // Propagate JSLiteral flag
|
|
54906
54915
|
if (result.symbol && result.symbol.flags & 32 /* Class */ && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
|
|
54907
|
-
result.objectFlags |=
|
|
54916
|
+
result.objectFlags |= 33554432 /* IsClassInstanceClone */; // Propagate the knowledge that this type is equivalent to the symbol's class instance type
|
|
54908
54917
|
}
|
|
54909
54918
|
return result;
|
|
54910
54919
|
}
|
|
@@ -56914,87 +56923,87 @@ var ts;
|
|
|
56914
56923
|
* Converts an AnonymousType to a ResolvedType.
|
|
56915
56924
|
*/
|
|
56916
56925
|
function resolveAnonymousTypeMembers(type) {
|
|
56917
|
-
var symbol = getMergedSymbol(type.symbol);
|
|
56918
56926
|
if (type.target) {
|
|
56919
56927
|
setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
56920
|
-
var
|
|
56928
|
+
var members_6 = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false);
|
|
56921
56929
|
var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0 /* Call */), type.mapper);
|
|
56922
56930
|
var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1 /* Construct */), type.mapper);
|
|
56923
|
-
var
|
|
56924
|
-
setStructuredTypeMembers(type,
|
|
56931
|
+
var indexInfos_1 = instantiateIndexInfos(getIndexInfosOfType(type.target), type.mapper);
|
|
56932
|
+
setStructuredTypeMembers(type, members_6, callSignatures, constructSignatures, indexInfos_1);
|
|
56933
|
+
return;
|
|
56925
56934
|
}
|
|
56926
|
-
|
|
56935
|
+
var symbol = getMergedSymbol(type.symbol);
|
|
56936
|
+
if (symbol.flags & 2048 /* TypeLiteral */) {
|
|
56927
56937
|
setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
56928
|
-
var
|
|
56929
|
-
var callSignatures = getSignaturesOfSymbol(
|
|
56930
|
-
var constructSignatures = getSignaturesOfSymbol(
|
|
56931
|
-
var
|
|
56932
|
-
setStructuredTypeMembers(type,
|
|
56938
|
+
var members_7 = getMembersOfSymbol(symbol);
|
|
56939
|
+
var callSignatures = getSignaturesOfSymbol(members_7.get("__call" /* Call */));
|
|
56940
|
+
var constructSignatures = getSignaturesOfSymbol(members_7.get("__new" /* New */));
|
|
56941
|
+
var indexInfos_2 = getIndexInfosOfSymbol(symbol);
|
|
56942
|
+
setStructuredTypeMembers(type, members_7, callSignatures, constructSignatures, indexInfos_2);
|
|
56943
|
+
return;
|
|
56933
56944
|
}
|
|
56934
|
-
|
|
56935
|
-
|
|
56936
|
-
|
|
56937
|
-
|
|
56938
|
-
|
|
56939
|
-
|
|
56940
|
-
|
|
56941
|
-
|
|
56942
|
-
|
|
56943
|
-
|
|
56944
|
-
|
|
56945
|
-
|
|
56946
|
-
|
|
56947
|
-
members = varsOnly_1;
|
|
56948
|
-
}
|
|
56945
|
+
// Combinations of function, class, enum and module
|
|
56946
|
+
var members = emptySymbols;
|
|
56947
|
+
var indexInfos;
|
|
56948
|
+
if (symbol.exports) {
|
|
56949
|
+
members = getExportsOfSymbol(symbol);
|
|
56950
|
+
if (symbol === globalThisSymbol) {
|
|
56951
|
+
var varsOnly_1 = new ts.Map();
|
|
56952
|
+
members.forEach(function (p) {
|
|
56953
|
+
if (!(p.flags & 418 /* BlockScoped */)) {
|
|
56954
|
+
varsOnly_1.set(p.escapedName, p);
|
|
56955
|
+
}
|
|
56956
|
+
});
|
|
56957
|
+
members = varsOnly_1;
|
|
56949
56958
|
}
|
|
56950
|
-
|
|
56951
|
-
|
|
56952
|
-
|
|
56953
|
-
|
|
56954
|
-
|
|
56955
|
-
|
|
56956
|
-
|
|
56957
|
-
|
|
56958
|
-
|
|
56959
|
-
else if (baseConstructorType === anyType) {
|
|
56960
|
-
baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
|
|
56961
|
-
}
|
|
56959
|
+
}
|
|
56960
|
+
var baseConstructorIndexInfo;
|
|
56961
|
+
setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, ts.emptyArray);
|
|
56962
|
+
if (symbol.flags & 32 /* Class */) {
|
|
56963
|
+
var classType = getDeclaredTypeOfClassOrInterface(symbol);
|
|
56964
|
+
var baseConstructorType = getBaseConstructorTypeOfClass(classType);
|
|
56965
|
+
if (baseConstructorType.flags & (524288 /* Object */ | 2097152 /* Intersection */ | 8650752 /* TypeVariable */)) {
|
|
56966
|
+
members = ts.createSymbolTable(getNamedOrIndexSignatureMembers(members));
|
|
56967
|
+
addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
|
|
56962
56968
|
}
|
|
56963
|
-
|
|
56964
|
-
|
|
56965
|
-
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
|
56969
|
+
else if (baseConstructorType === anyType) {
|
|
56970
|
+
baseConstructorIndexInfo = createIndexInfo(stringType, anyType, /*isReadonly*/ false);
|
|
56966
56971
|
}
|
|
56967
|
-
|
|
56968
|
-
|
|
56969
|
-
|
|
56970
|
-
|
|
56971
|
-
|
|
56972
|
-
|
|
56973
|
-
|
|
56974
|
-
|
|
56972
|
+
}
|
|
56973
|
+
var indexSymbol = getIndexSymbolFromSymbolTable(members);
|
|
56974
|
+
if (indexSymbol) {
|
|
56975
|
+
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
|
56976
|
+
}
|
|
56977
|
+
else {
|
|
56978
|
+
if (baseConstructorIndexInfo) {
|
|
56979
|
+
indexInfos = ts.append(indexInfos, baseConstructorIndexInfo);
|
|
56975
56980
|
}
|
|
56976
|
-
|
|
56977
|
-
|
|
56978
|
-
|
|
56979
|
-
// in the process of resolving (see issue #6072). The temporarily empty signature list
|
|
56980
|
-
// will never be observed because a qualified name can't reference signatures.
|
|
56981
|
-
if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
|
|
56982
|
-
type.callSignatures = getSignaturesOfSymbol(symbol);
|
|
56981
|
+
if (symbol.flags & 384 /* Enum */ && (getDeclaredTypeOfSymbol(symbol).flags & 32 /* Enum */ ||
|
|
56982
|
+
ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296 /* NumberLike */); }))) {
|
|
56983
|
+
indexInfos = ts.append(indexInfos, enumNumberIndexInfo);
|
|
56983
56984
|
}
|
|
56984
|
-
|
|
56985
|
-
|
|
56986
|
-
|
|
56987
|
-
|
|
56988
|
-
|
|
56989
|
-
|
|
56990
|
-
|
|
56991
|
-
|
|
56992
|
-
|
|
56993
|
-
|
|
56994
|
-
|
|
56995
|
-
|
|
56996
|
-
|
|
56985
|
+
}
|
|
56986
|
+
setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, indexInfos || ts.emptyArray);
|
|
56987
|
+
// We resolve the members before computing the signatures because a signature may use
|
|
56988
|
+
// typeof with a qualified name expression that circularly references the type we are
|
|
56989
|
+
// in the process of resolving (see issue #6072). The temporarily empty signature list
|
|
56990
|
+
// will never be observed because a qualified name can't reference signatures.
|
|
56991
|
+
if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) {
|
|
56992
|
+
type.callSignatures = getSignaturesOfSymbol(symbol);
|
|
56993
|
+
}
|
|
56994
|
+
// And likewise for construct signatures for classes
|
|
56995
|
+
if (symbol.flags & 32 /* Class */) {
|
|
56996
|
+
var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
|
|
56997
|
+
var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray;
|
|
56998
|
+
if (symbol.flags & 16 /* Function */) {
|
|
56999
|
+
constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
|
|
57000
|
+
createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 39 /* PropagatingFlags */) :
|
|
57001
|
+
undefined; }));
|
|
56997
57002
|
}
|
|
57003
|
+
if (!constructSignatures.length) {
|
|
57004
|
+
constructSignatures = getDefaultConstructSignatures(classType_1);
|
|
57005
|
+
}
|
|
57006
|
+
type.constructSignatures = constructSignatures;
|
|
56998
57007
|
}
|
|
56999
57008
|
}
|
|
57000
57009
|
function replaceIndexedAccess(instantiable, type, replacement) {
|
|
@@ -57986,8 +57995,8 @@ var ts;
|
|
|
57986
57995
|
var stringIndexInfo;
|
|
57987
57996
|
var applicableInfo;
|
|
57988
57997
|
var applicableInfos;
|
|
57989
|
-
for (var _i = 0,
|
|
57990
|
-
var info =
|
|
57998
|
+
for (var _i = 0, indexInfos_3 = indexInfos; _i < indexInfos_3.length; _i++) {
|
|
57999
|
+
var info = indexInfos_3[_i];
|
|
57991
58000
|
if (info.keyType === stringType) {
|
|
57992
58001
|
stringIndexInfo = info;
|
|
57993
58002
|
}
|
|
@@ -58551,14 +58560,14 @@ var ts;
|
|
|
58551
58560
|
}
|
|
58552
58561
|
function getIndexInfosOfIndexSymbol(indexSymbol) {
|
|
58553
58562
|
if (indexSymbol.declarations) {
|
|
58554
|
-
var
|
|
58563
|
+
var indexInfos_4 = [];
|
|
58555
58564
|
var _loop_14 = function (declaration) {
|
|
58556
58565
|
if (declaration.parameters.length === 1) {
|
|
58557
58566
|
var parameter = declaration.parameters[0];
|
|
58558
58567
|
if (parameter.type) {
|
|
58559
58568
|
forEachType(getTypeFromTypeNode(parameter.type), function (keyType) {
|
|
58560
|
-
if (isValidIndexKeyType(keyType) && !findIndexInfo(
|
|
58561
|
-
|
|
58569
|
+
if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos_4, keyType)) {
|
|
58570
|
+
indexInfos_4.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64 /* Readonly */), declaration));
|
|
58562
58571
|
}
|
|
58563
58572
|
});
|
|
58564
58573
|
}
|
|
@@ -58568,7 +58577,7 @@ var ts;
|
|
|
58568
58577
|
var declaration = _a[_i];
|
|
58569
58578
|
_loop_14(declaration);
|
|
58570
58579
|
}
|
|
58571
|
-
return
|
|
58580
|
+
return indexInfos_4;
|
|
58572
58581
|
}
|
|
58573
58582
|
return ts.emptyArray;
|
|
58574
58583
|
}
|
|
@@ -59116,7 +59125,7 @@ var ts;
|
|
|
59116
59125
|
// The expression is processed as an identifier expression (section 4.3)
|
|
59117
59126
|
// or property access expression(section 4.10),
|
|
59118
59127
|
// the widened type(section 3.9) of which becomes the result.
|
|
59119
|
-
var type =
|
|
59128
|
+
var type = checkExpressionWithTypeArguments(node);
|
|
59120
59129
|
links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(type));
|
|
59121
59130
|
}
|
|
59122
59131
|
return links.resolvedType;
|
|
@@ -60557,7 +60566,7 @@ var ts;
|
|
|
60557
60566
|
}
|
|
60558
60567
|
var prop = getPropertyOfType(objectType, propName);
|
|
60559
60568
|
if (prop) {
|
|
60560
|
-
if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations &&
|
|
60569
|
+
if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) {
|
|
60561
60570
|
var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
|
|
60562
60571
|
addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName);
|
|
60563
60572
|
}
|
|
@@ -61820,7 +61829,9 @@ var ts;
|
|
|
61820
61829
|
return result;
|
|
61821
61830
|
}
|
|
61822
61831
|
function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
61823
|
-
var declaration = type.objectFlags & 4 /* Reference */ ? type.node :
|
|
61832
|
+
var declaration = type.objectFlags & 4 /* Reference */ ? type.node :
|
|
61833
|
+
type.objectFlags & 16777216 /* InstantiationExpressionType */ ? type.node :
|
|
61834
|
+
type.symbol.declarations[0];
|
|
61824
61835
|
var links = getNodeLinks(declaration);
|
|
61825
61836
|
var target = type.objectFlags & 4 /* Reference */ ? links.resolvedType :
|
|
61826
61837
|
type.objectFlags & 64 /* Instantiated */ ? type.target : type;
|
|
@@ -61836,8 +61847,8 @@ var ts;
|
|
|
61836
61847
|
outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
|
|
61837
61848
|
}
|
|
61838
61849
|
typeParameters = outerTypeParameters || ts.emptyArray;
|
|
61839
|
-
var allDeclarations_1 = type.objectFlags & 4 /* Reference */ ? [declaration] : type.symbol.declarations;
|
|
61840
|
-
typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
|
|
61850
|
+
var allDeclarations_1 = type.objectFlags & (4 /* Reference */ | 16777216 /* InstantiationExpressionType */) ? [declaration] : type.symbol.declarations;
|
|
61851
|
+
typeParameters = (target.objectFlags & (4 /* Reference */ | 16777216 /* InstantiationExpressionType */) || target.symbol.flags & 8192 /* Method */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ?
|
|
61841
61852
|
ts.filter(typeParameters, function (tp) { return ts.some(allDeclarations_1, function (d) { return isTypeParameterPossiblyReferenced(tp, d); }); }) :
|
|
61842
61853
|
typeParameters;
|
|
61843
61854
|
links.outerTypeParameters = typeParameters;
|
|
@@ -62009,6 +62020,9 @@ var ts;
|
|
|
62009
62020
|
mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
|
|
62010
62021
|
freshTypeParameter.mapper = mapper;
|
|
62011
62022
|
}
|
|
62023
|
+
if (type.objectFlags & 16777216 /* InstantiationExpressionType */) {
|
|
62024
|
+
result.node = type.node;
|
|
62025
|
+
}
|
|
62012
62026
|
result.target = type;
|
|
62013
62027
|
result.mapper = mapper;
|
|
62014
62028
|
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
@@ -65183,8 +65197,8 @@ var ts;
|
|
|
65183
65197
|
var indexInfos = getIndexInfosOfType(target);
|
|
65184
65198
|
var targetHasStringIndex = ts.some(indexInfos, function (info) { return info.keyType === stringType; });
|
|
65185
65199
|
var result = -1 /* True */;
|
|
65186
|
-
for (var _i = 0,
|
|
65187
|
-
var targetInfo =
|
|
65200
|
+
for (var _i = 0, indexInfos_5 = indexInfos; _i < indexInfos_5.length; _i++) {
|
|
65201
|
+
var targetInfo = indexInfos_5[_i];
|
|
65188
65202
|
var related = !sourceIsPrimitive && targetHasStringIndex && targetInfo.type.flags & 1 /* Any */ ? -1 /* True */ :
|
|
65189
65203
|
isGenericMappedType(source) && targetHasStringIndex ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, 3 /* Both */, reportErrors) :
|
|
65190
65204
|
typeRelatedToIndexInfo(source, targetInfo, reportErrors, intersectionState);
|
|
@@ -65791,10 +65805,10 @@ var ts;
|
|
|
65791
65805
|
if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !(ts.getObjectFlags(type.target) & 3 /* ClassOrInterface */)) {
|
|
65792
65806
|
return undefined;
|
|
65793
65807
|
}
|
|
65794
|
-
if (ts.getObjectFlags(type) &
|
|
65795
|
-
return ts.getObjectFlags(type) &
|
|
65808
|
+
if (ts.getObjectFlags(type) & 67108864 /* IdenticalBaseTypeCalculated */) {
|
|
65809
|
+
return ts.getObjectFlags(type) & 134217728 /* IdenticalBaseTypeExists */ ? type.cachedEquivalentBaseType : undefined;
|
|
65796
65810
|
}
|
|
65797
|
-
type.objectFlags |=
|
|
65811
|
+
type.objectFlags |= 67108864 /* IdenticalBaseTypeCalculated */;
|
|
65798
65812
|
var target = type.target;
|
|
65799
65813
|
if (ts.getObjectFlags(target) & 1 /* Class */) {
|
|
65800
65814
|
var baseTypeNode = getBaseTypeNodeOfClass(target);
|
|
@@ -65815,7 +65829,7 @@ var ts;
|
|
|
65815
65829
|
if (ts.length(getTypeArguments(type)) > ts.length(target.typeParameters)) {
|
|
65816
65830
|
instantiatedBase = getTypeWithThisArgument(instantiatedBase, ts.last(getTypeArguments(type)));
|
|
65817
65831
|
}
|
|
65818
|
-
type.objectFlags |=
|
|
65832
|
+
type.objectFlags |= 134217728 /* IdenticalBaseTypeExists */;
|
|
65819
65833
|
return type.cachedEquivalentBaseType = instantiatedBase;
|
|
65820
65834
|
}
|
|
65821
65835
|
function isEmptyLiteralType(type) {
|
|
@@ -66479,7 +66493,7 @@ var ts;
|
|
|
66479
66493
|
var result = !!(type.flags & 465829888 /* Instantiable */ ||
|
|
66480
66494
|
type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
|
|
66481
66495
|
objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations ||
|
|
66482
|
-
objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */)) ||
|
|
66496
|
+
objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 8388608 /* ObjectRestType */ | 16777216 /* InstantiationExpressionType */)) ||
|
|
66483
66497
|
type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables));
|
|
66484
66498
|
if (type.flags & 3899393 /* ObjectFlagsType */) {
|
|
66485
66499
|
type.objectFlags |= 1048576 /* CouldContainTypeVariablesComputed */ | (result ? 2097152 /* CouldContainTypeVariables */ : 0);
|
|
@@ -67396,8 +67410,8 @@ var ts;
|
|
|
67396
67410
|
var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0;
|
|
67397
67411
|
var indexInfos = getIndexInfosOfType(target);
|
|
67398
67412
|
if (isObjectTypeWithInferableIndex(source)) {
|
|
67399
|
-
for (var _i = 0,
|
|
67400
|
-
var targetInfo =
|
|
67413
|
+
for (var _i = 0, indexInfos_6 = indexInfos; _i < indexInfos_6.length; _i++) {
|
|
67414
|
+
var targetInfo = indexInfos_6[_i];
|
|
67401
67415
|
var propTypes = [];
|
|
67402
67416
|
for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) {
|
|
67403
67417
|
var prop = _b[_a];
|
|
@@ -67417,8 +67431,8 @@ var ts;
|
|
|
67417
67431
|
}
|
|
67418
67432
|
}
|
|
67419
67433
|
}
|
|
67420
|
-
for (var _e = 0,
|
|
67421
|
-
var targetInfo =
|
|
67434
|
+
for (var _e = 0, indexInfos_7 = indexInfos; _e < indexInfos_7.length; _e++) {
|
|
67435
|
+
var targetInfo = indexInfos_7[_e];
|
|
67422
67436
|
var sourceInfo = getApplicableIndexInfo(source, targetInfo.keyType);
|
|
67423
67437
|
if (sourceInfo) {
|
|
67424
67438
|
inferWithPriority(sourceInfo.type, targetInfo.type, priority);
|
|
@@ -69960,9 +69974,9 @@ var ts;
|
|
|
69960
69974
|
markAliasReferenced(symbol, node);
|
|
69961
69975
|
}
|
|
69962
69976
|
var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
69963
|
-
var
|
|
69964
|
-
if (
|
|
69965
|
-
addDeprecatedSuggestion(node,
|
|
69977
|
+
var targetSymbol = checkDeprecatedAliasedSymbol(localOrExportSymbol, node);
|
|
69978
|
+
if (isDeprecatedSymbol(targetSymbol) && isUncalledFunctionReference(node, targetSymbol) && targetSymbol.declarations) {
|
|
69979
|
+
addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText);
|
|
69966
69980
|
}
|
|
69967
69981
|
var declaration = localOrExportSymbol.valueDeclaration;
|
|
69968
69982
|
if (declaration && localOrExportSymbol.flags & 32 /* Class */) {
|
|
@@ -72974,7 +72988,7 @@ var ts;
|
|
|
72974
72988
|
}
|
|
72975
72989
|
}
|
|
72976
72990
|
else {
|
|
72977
|
-
if (
|
|
72991
|
+
if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
|
|
72978
72992
|
addDeprecatedSuggestion(right, prop.declarations, right.escapedText);
|
|
72979
72993
|
}
|
|
72980
72994
|
checkPropertyNotUsedBeforeDeclaration(prop, node, right);
|
|
@@ -74433,7 +74447,7 @@ var ts;
|
|
|
74433
74447
|
}
|
|
74434
74448
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
74435
74449
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
74436
|
-
var chain = ts.chainDiagnosticMessages(ts.map(diags_3,
|
|
74450
|
+
var chain = ts.chainDiagnosticMessages(ts.map(diags_3, ts.createDiagnosticMessageChainFromDiagnostic), ts.Diagnostics.No_overload_matches_this_call);
|
|
74437
74451
|
// The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input
|
|
74438
74452
|
// arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic
|
|
74439
74453
|
var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; }), true);
|
|
@@ -75588,6 +75602,66 @@ var ts;
|
|
|
75588
75602
|
return node.flags & 32 /* OptionalChain */ ? checkNonNullChain(node) :
|
|
75589
75603
|
getNonNullableType(checkExpression(node.expression));
|
|
75590
75604
|
}
|
|
75605
|
+
function checkExpressionWithTypeArguments(node) {
|
|
75606
|
+
checkGrammarExpressionWithTypeArguments(node);
|
|
75607
|
+
var exprType = node.kind === 227 /* ExpressionWithTypeArguments */ ? checkExpression(node.expression) :
|
|
75608
|
+
ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
|
|
75609
|
+
checkExpression(node.exprName);
|
|
75610
|
+
var typeArguments = node.typeArguments;
|
|
75611
|
+
if (!ts.some(typeArguments)) {
|
|
75612
|
+
return exprType;
|
|
75613
|
+
}
|
|
75614
|
+
var funcType = getApparentType(exprType);
|
|
75615
|
+
if (funcType === silentNeverType || isErrorType(funcType)) {
|
|
75616
|
+
return funcType;
|
|
75617
|
+
}
|
|
75618
|
+
var hasSomeApplicableSignature = false;
|
|
75619
|
+
var nonApplicableType;
|
|
75620
|
+
var hasSignatures;
|
|
75621
|
+
var hasApplicableSignature;
|
|
75622
|
+
var result = mapType(funcType, getInstantiatedType);
|
|
75623
|
+
var errorType = hasSomeApplicableSignature ? nonApplicableType : funcType;
|
|
75624
|
+
if (errorType) {
|
|
75625
|
+
diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable, typeToString(errorType)));
|
|
75626
|
+
}
|
|
75627
|
+
return result;
|
|
75628
|
+
function getInstantiatedType(type) {
|
|
75629
|
+
hasSignatures = false;
|
|
75630
|
+
hasApplicableSignature = false;
|
|
75631
|
+
var result = getInstantiatedTypeWorker(type);
|
|
75632
|
+
hasSomeApplicableSignature || (hasSomeApplicableSignature = hasApplicableSignature);
|
|
75633
|
+
if (hasSignatures && !hasApplicableSignature) {
|
|
75634
|
+
nonApplicableType !== null && nonApplicableType !== void 0 ? nonApplicableType : (nonApplicableType = type);
|
|
75635
|
+
}
|
|
75636
|
+
return result;
|
|
75637
|
+
}
|
|
75638
|
+
function getInstantiatedTypeWorker(type) {
|
|
75639
|
+
if (type.flags & 524288 /* Object */) {
|
|
75640
|
+
var resolved = resolveStructuredTypeMembers(type);
|
|
75641
|
+
var callSignatures = getInstantiatedSignatures(resolved.callSignatures);
|
|
75642
|
+
var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
|
|
75643
|
+
hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
|
|
75644
|
+
hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
|
|
75645
|
+
if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
|
|
75646
|
+
var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
|
|
75647
|
+
result_11.objectFlags |= 16777216 /* InstantiationExpressionType */;
|
|
75648
|
+
result_11.node = node;
|
|
75649
|
+
return result_11;
|
|
75650
|
+
}
|
|
75651
|
+
}
|
|
75652
|
+
else if (type.flags & 2097152 /* Intersection */) {
|
|
75653
|
+
return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypeWorker));
|
|
75654
|
+
}
|
|
75655
|
+
return type;
|
|
75656
|
+
}
|
|
75657
|
+
function getInstantiatedSignatures(signatures) {
|
|
75658
|
+
var applicableSignatures = ts.filter(signatures, function (sig) { return !!sig.typeParameters && hasCorrectTypeArgumentArity(sig, typeArguments); });
|
|
75659
|
+
return ts.sameMap(applicableSignatures, function (sig) {
|
|
75660
|
+
var typeArgumentTypes = checkTypeArguments(sig, typeArguments, /*reportErrors*/ true);
|
|
75661
|
+
return typeArgumentTypes ? getSignatureInstantiation(sig, typeArgumentTypes, ts.isInJSFile(sig.declaration)) : sig;
|
|
75662
|
+
});
|
|
75663
|
+
}
|
|
75664
|
+
}
|
|
75591
75665
|
function checkMetaProperty(node) {
|
|
75592
75666
|
checkGrammarMetaProperty(node);
|
|
75593
75667
|
if (node.keywordToken === 103 /* NewKeyword */) {
|
|
@@ -78097,6 +78171,8 @@ var ts;
|
|
|
78097
78171
|
return checkAssertion(node);
|
|
78098
78172
|
case 229 /* NonNullExpression */:
|
|
78099
78173
|
return checkNonNullAssertion(node);
|
|
78174
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
78175
|
+
return checkExpressionWithTypeArguments(node);
|
|
78100
78176
|
case 230 /* MetaProperty */:
|
|
78101
78177
|
return checkMetaProperty(node);
|
|
78102
78178
|
case 214 /* DeleteExpression */:
|
|
@@ -79302,12 +79378,12 @@ var ts;
|
|
|
79302
79378
|
case 264 /* ImportEqualsDeclaration */:
|
|
79303
79379
|
case 267 /* NamespaceImport */:
|
|
79304
79380
|
case 266 /* ImportClause */:
|
|
79305
|
-
var
|
|
79381
|
+
var result_12 = 0 /* None */;
|
|
79306
79382
|
var target = resolveAlias(getSymbolOfNode(d));
|
|
79307
79383
|
ts.forEach(target.declarations, function (d) {
|
|
79308
|
-
|
|
79384
|
+
result_12 |= getDeclarationSpaces(d);
|
|
79309
79385
|
});
|
|
79310
|
-
return
|
|
79386
|
+
return result_12;
|
|
79311
79387
|
case 253 /* VariableDeclaration */:
|
|
79312
79388
|
case 202 /* BindingElement */:
|
|
79313
79389
|
case 255 /* FunctionDeclaration */:
|
|
@@ -81894,8 +81970,8 @@ var ts;
|
|
|
81894
81970
|
}
|
|
81895
81971
|
}
|
|
81896
81972
|
if (indexInfos.length > 1) {
|
|
81897
|
-
for (var _d = 0,
|
|
81898
|
-
var info =
|
|
81973
|
+
for (var _d = 0, indexInfos_8 = indexInfos; _d < indexInfos_8.length; _d++) {
|
|
81974
|
+
var info = indexInfos_8[_d];
|
|
81899
81975
|
checkIndexConstraintForIndexSignature(type, info);
|
|
81900
81976
|
}
|
|
81901
81977
|
}
|
|
@@ -81921,8 +81997,8 @@ var ts;
|
|
|
81921
81997
|
error(errorNode, ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_2_index_type_3, symbolToString(prop), typeToString(propType), typeToString(info.keyType), typeToString(info.type));
|
|
81922
81998
|
}
|
|
81923
81999
|
};
|
|
81924
|
-
for (var _i = 0,
|
|
81925
|
-
var info =
|
|
82000
|
+
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
82001
|
+
var info = indexInfos_9[_i];
|
|
81926
82002
|
_loop_27(info);
|
|
81927
82003
|
}
|
|
81928
82004
|
}
|
|
@@ -81944,8 +82020,8 @@ var ts;
|
|
|
81944
82020
|
error(errorNode, ts.Diagnostics._0_index_type_1_is_not_assignable_to_2_index_type_3, typeToString(checkInfo.keyType), typeToString(checkInfo.type), typeToString(info.keyType), typeToString(info.type));
|
|
81945
82021
|
}
|
|
81946
82022
|
};
|
|
81947
|
-
for (var _i = 0,
|
|
81948
|
-
var info =
|
|
82023
|
+
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
82024
|
+
var info = indexInfos_10[_i];
|
|
81949
82025
|
_loop_28(info);
|
|
81950
82026
|
}
|
|
81951
82027
|
}
|
|
@@ -82812,16 +82888,15 @@ var ts;
|
|
|
82812
82888
|
return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
|
|
82813
82889
|
case 206 /* ElementAccessExpression */:
|
|
82814
82890
|
case 205 /* PropertyAccessExpression */:
|
|
82815
|
-
|
|
82816
|
-
|
|
82817
|
-
var type = getTypeOfExpression(ex.expression);
|
|
82891
|
+
if (isConstantMemberAccess(expr)) {
|
|
82892
|
+
var type = getTypeOfExpression(expr.expression);
|
|
82818
82893
|
if (type.symbol && type.symbol.flags & 384 /* Enum */) {
|
|
82819
82894
|
var name = void 0;
|
|
82820
|
-
if (
|
|
82821
|
-
name =
|
|
82895
|
+
if (expr.kind === 205 /* PropertyAccessExpression */) {
|
|
82896
|
+
name = expr.name.escapedText;
|
|
82822
82897
|
}
|
|
82823
82898
|
else {
|
|
82824
|
-
name = ts.escapeLeadingUnderscores(ts.cast(
|
|
82899
|
+
name = ts.escapeLeadingUnderscores(ts.cast(expr.argumentExpression, ts.isLiteralExpression).text);
|
|
82825
82900
|
}
|
|
82826
82901
|
return evaluateEnumMember(expr, type.symbol, name);
|
|
82827
82902
|
}
|
|
@@ -82849,6 +82924,10 @@ var ts;
|
|
|
82849
82924
|
}
|
|
82850
82925
|
}
|
|
82851
82926
|
function isConstantMemberAccess(node) {
|
|
82927
|
+
var type = getTypeOfExpression(node);
|
|
82928
|
+
if (type === errorType) {
|
|
82929
|
+
return false;
|
|
82930
|
+
}
|
|
82852
82931
|
return node.kind === 79 /* Identifier */ ||
|
|
82853
82932
|
node.kind === 205 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) ||
|
|
82854
82933
|
node.kind === 206 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) &&
|
|
@@ -83143,7 +83222,6 @@ var ts;
|
|
|
83143
83222
|
return true;
|
|
83144
83223
|
}
|
|
83145
83224
|
function checkAliasSymbol(node) {
|
|
83146
|
-
var _a;
|
|
83147
83225
|
var symbol = getSymbolOfNode(node);
|
|
83148
83226
|
var target = resolveAlias(symbol);
|
|
83149
83227
|
if (target !== unknownSymbol) {
|
|
@@ -83199,11 +83277,46 @@ var ts;
|
|
|
83199
83277
|
}
|
|
83200
83278
|
}
|
|
83201
83279
|
}
|
|
83202
|
-
if (ts.isImportSpecifier(node)
|
|
83203
|
-
|
|
83280
|
+
if (ts.isImportSpecifier(node)) {
|
|
83281
|
+
var targetSymbol = checkDeprecatedAliasedSymbol(symbol, node);
|
|
83282
|
+
if (isDeprecatedAliasedSymbol(targetSymbol) && targetSymbol.declarations) {
|
|
83283
|
+
addDeprecatedSuggestion(node, targetSymbol.declarations, targetSymbol.escapedName);
|
|
83284
|
+
}
|
|
83204
83285
|
}
|
|
83205
83286
|
}
|
|
83206
83287
|
}
|
|
83288
|
+
function isDeprecatedAliasedSymbol(symbol) {
|
|
83289
|
+
return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
|
|
83290
|
+
}
|
|
83291
|
+
function checkDeprecatedAliasedSymbol(symbol, location) {
|
|
83292
|
+
if (!(symbol.flags & 2097152 /* Alias */))
|
|
83293
|
+
return symbol;
|
|
83294
|
+
var targetSymbol = resolveAlias(symbol);
|
|
83295
|
+
if (targetSymbol === unknownSymbol)
|
|
83296
|
+
return targetSymbol;
|
|
83297
|
+
while (symbol.flags & 2097152 /* Alias */) {
|
|
83298
|
+
var target = getImmediateAliasedSymbol(symbol);
|
|
83299
|
+
if (target) {
|
|
83300
|
+
if (target === targetSymbol)
|
|
83301
|
+
break;
|
|
83302
|
+
if (target.declarations && ts.length(target.declarations)) {
|
|
83303
|
+
if (isDeprecatedAliasedSymbol(target)) {
|
|
83304
|
+
addDeprecatedSuggestion(location, target.declarations, target.escapedName);
|
|
83305
|
+
break;
|
|
83306
|
+
}
|
|
83307
|
+
else {
|
|
83308
|
+
if (symbol === targetSymbol)
|
|
83309
|
+
break;
|
|
83310
|
+
symbol = target;
|
|
83311
|
+
}
|
|
83312
|
+
}
|
|
83313
|
+
}
|
|
83314
|
+
else {
|
|
83315
|
+
break;
|
|
83316
|
+
}
|
|
83317
|
+
}
|
|
83318
|
+
return targetSymbol;
|
|
83319
|
+
}
|
|
83207
83320
|
function checkImportBinding(node) {
|
|
83208
83321
|
checkCollisionsForDeclarationName(node, node.name);
|
|
83209
83322
|
checkAliasSymbol(node);
|
|
@@ -87504,7 +87617,7 @@ var ts;
|
|
|
87504
87617
|
return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
87505
87618
|
case 180 /* TypeQuery */:
|
|
87506
87619
|
ts.Debug.type(node);
|
|
87507
|
-
return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName));
|
|
87620
|
+
return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
|
|
87508
87621
|
case 181 /* TypeLiteral */:
|
|
87509
87622
|
ts.Debug.type(node);
|
|
87510
87623
|
return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
|
|
@@ -90396,8 +90509,8 @@ var ts;
|
|
|
90396
90509
|
function generateClassElementDecorationExpressions(node, isStatic) {
|
|
90397
90510
|
var members = getDecoratedClassElements(node, isStatic);
|
|
90398
90511
|
var expressions;
|
|
90399
|
-
for (var _i = 0,
|
|
90400
|
-
var member =
|
|
90512
|
+
for (var _i = 0, members_8 = members; _i < members_8.length; _i++) {
|
|
90513
|
+
var member = members_8[_i];
|
|
90401
90514
|
var expression = generateClassElementDecorationExpression(node, member);
|
|
90402
90515
|
if (expression) {
|
|
90403
90516
|
if (!expressions) {
|
|
@@ -95598,8 +95711,8 @@ var ts;
|
|
|
95598
95711
|
function convertJsxChildrenToChildrenPropAssignment(children) {
|
|
95599
95712
|
var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
|
|
95600
95713
|
if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) {
|
|
95601
|
-
var
|
|
95602
|
-
return
|
|
95714
|
+
var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
|
|
95715
|
+
return result_13 && factory.createPropertyAssignment("children", result_13);
|
|
95603
95716
|
}
|
|
95604
95717
|
var result = ts.mapDefined(children, transformJsxChildToExpression);
|
|
95605
95718
|
return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
|
|
@@ -109228,6 +109341,8 @@ var ts;
|
|
|
109228
109341
|
return emitAsExpression(node);
|
|
109229
109342
|
case 229 /* NonNullExpression */:
|
|
109230
109343
|
return emitNonNullExpression(node);
|
|
109344
|
+
case 227 /* ExpressionWithTypeArguments */:
|
|
109345
|
+
return emitExpressionWithTypeArguments(node);
|
|
109231
109346
|
case 230 /* MetaProperty */:
|
|
109232
109347
|
return emitMetaProperty(node);
|
|
109233
109348
|
case 231 /* SyntheticExpression */:
|
|
@@ -109672,6 +109787,7 @@ var ts;
|
|
|
109672
109787
|
writeKeyword("typeof");
|
|
109673
109788
|
writeSpace();
|
|
109674
109789
|
emit(node.exprName);
|
|
109790
|
+
emitTypeArguments(node, node.typeArguments);
|
|
109675
109791
|
}
|
|
109676
109792
|
function emitTypeLiteral(node) {
|
|
109677
109793
|
writePunctuation("{");
|
|
@@ -114631,15 +114747,15 @@ var ts;
|
|
|
114631
114747
|
// which per above occurred during the current program creation.
|
|
114632
114748
|
// Since we assume the filesystem does not change during program creation,
|
|
114633
114749
|
// it is safe to reuse resolutions from the earlier call.
|
|
114634
|
-
var
|
|
114750
|
+
var result_14 = [];
|
|
114635
114751
|
var i = 0;
|
|
114636
114752
|
for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
|
|
114637
114753
|
var moduleName = moduleNames_1[_i];
|
|
114638
114754
|
var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
|
|
114639
114755
|
i++;
|
|
114640
|
-
|
|
114756
|
+
result_14.push(resolvedModule);
|
|
114641
114757
|
}
|
|
114642
|
-
return
|
|
114758
|
+
return result_14;
|
|
114643
114759
|
}
|
|
114644
114760
|
// At this point, we know at least one of the following hold:
|
|
114645
114761
|
// - file has local declarations for ambient modules
|
|
@@ -115861,14 +115977,14 @@ var ts;
|
|
|
115861
115977
|
redirectTargetsMap.add(fileFromPackageId.path, fileName);
|
|
115862
115978
|
addFileToFilesByName(dupFile, path, redirectedPath);
|
|
115863
115979
|
addFileIncludeReason(dupFile, reason);
|
|
115864
|
-
sourceFileToPackageName.set(path, packageId
|
|
115980
|
+
sourceFileToPackageName.set(path, ts.packageIdToPackageName(packageId));
|
|
115865
115981
|
processingOtherFiles.push(dupFile);
|
|
115866
115982
|
return dupFile;
|
|
115867
115983
|
}
|
|
115868
115984
|
else if (file) {
|
|
115869
115985
|
// This is the first source file to have this packageId.
|
|
115870
115986
|
packageIdToSourceFile.set(packageIdKey, file);
|
|
115871
|
-
sourceFileToPackageName.set(path, packageId
|
|
115987
|
+
sourceFileToPackageName.set(path, ts.packageIdToPackageName(packageId));
|
|
115872
115988
|
}
|
|
115873
115989
|
}
|
|
115874
115990
|
addFileToFilesByName(file, path, redirectedPath);
|
|
@@ -119747,9 +119863,9 @@ var ts;
|
|
|
119747
119863
|
if (!preferSymlinks) {
|
|
119748
119864
|
// Symlinks inside ignored paths are already filtered out of the symlink cache,
|
|
119749
119865
|
// so we only need to remove them from the realpath filenames.
|
|
119750
|
-
var
|
|
119751
|
-
if (
|
|
119752
|
-
return
|
|
119866
|
+
var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
|
|
119867
|
+
if (result_15)
|
|
119868
|
+
return result_15;
|
|
119753
119869
|
}
|
|
119754
119870
|
var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
|
|
119755
119871
|
var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
|
|
@@ -119769,10 +119885,10 @@ var ts;
|
|
|
119769
119885
|
for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
|
|
119770
119886
|
var symlinkDirectory = symlinkDirectories_1[_i];
|
|
119771
119887
|
var option = ts.resolvePath(symlinkDirectory, relative);
|
|
119772
|
-
var
|
|
119888
|
+
var result_16 = cb(option, target === referenceRedirect);
|
|
119773
119889
|
shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
|
|
119774
|
-
if (
|
|
119775
|
-
return
|
|
119890
|
+
if (result_16)
|
|
119891
|
+
return result_16;
|
|
119776
119892
|
}
|
|
119777
119893
|
});
|
|
119778
119894
|
});
|
|
@@ -123665,7 +123781,7 @@ var ts;
|
|
|
123665
123781
|
case 199 /* ImportType */:
|
|
123666
123782
|
return !node.parent.isTypeOf;
|
|
123667
123783
|
case 227 /* ExpressionWithTypeArguments */:
|
|
123668
|
-
return
|
|
123784
|
+
return ts.isPartOfTypeNode(node.parent);
|
|
123669
123785
|
}
|
|
123670
123786
|
return false;
|
|
123671
123787
|
}
|
|
@@ -126528,11 +126644,11 @@ var ts;
|
|
|
126528
126644
|
return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
|
|
126529
126645
|
}
|
|
126530
126646
|
ts.firstOrOnly = firstOrOnly;
|
|
126531
|
-
function getNameForExportedSymbol(symbol, scriptTarget) {
|
|
126647
|
+
function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
|
|
126532
126648
|
if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
|
|
126533
126649
|
// Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
|
|
126534
126650
|
return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; })
|
|
126535
|
-
|| ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget);
|
|
126651
|
+
|| ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
|
|
126536
126652
|
}
|
|
126537
126653
|
return symbol.name;
|
|
126538
126654
|
}
|
|
@@ -126660,7 +126776,7 @@ var ts;
|
|
|
126660
126776
|
symbols.clear();
|
|
126661
126777
|
usableByFileName = undefined;
|
|
126662
126778
|
},
|
|
126663
|
-
add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson,
|
|
126779
|
+
add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, checker) {
|
|
126664
126780
|
if (importingFile !== usableByFileName) {
|
|
126665
126781
|
cache.clear();
|
|
126666
126782
|
usableByFileName = importingFile;
|
|
@@ -126676,7 +126792,7 @@ var ts;
|
|
|
126676
126792
|
// get a better name.
|
|
126677
126793
|
var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
|
|
126678
126794
|
? ts.unescapeLeadingUnderscores(symbolTableKey)
|
|
126679
|
-
: ts.getNameForExportedSymbol(namedSymbol, scriptTarget);
|
|
126795
|
+
: ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
|
|
126680
126796
|
var moduleName = ts.stripQuotes(moduleSymbol.name);
|
|
126681
126797
|
var id = exportInfoId++;
|
|
126682
126798
|
var target = ts.skipAlias(symbol, checker);
|
|
@@ -126709,7 +126825,14 @@ var ts;
|
|
|
126709
126825
|
return;
|
|
126710
126826
|
exportInfo.forEach(function (info, key) {
|
|
126711
126827
|
var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
|
|
126712
|
-
|
|
126828
|
+
var rehydrated = info.map(rehydrateCachedInfo);
|
|
126829
|
+
action(rehydrated, function (preferCapitalized) {
|
|
126830
|
+
var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
|
|
126831
|
+
var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
|
|
126832
|
+
return preferCapitalized
|
|
126833
|
+
? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
|
|
126834
|
+
: symbolName;
|
|
126835
|
+
}, !!ambientModuleName, key);
|
|
126713
126836
|
});
|
|
126714
126837
|
},
|
|
126715
126838
|
releaseSymbols: function () {
|
|
@@ -126891,7 +127014,6 @@ var ts;
|
|
|
126891
127014
|
}
|
|
126892
127015
|
(_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
|
|
126893
127016
|
var compilerOptions = program.getCompilerOptions();
|
|
126894
|
-
var scriptTarget = ts.getEmitScriptTarget(compilerOptions);
|
|
126895
127017
|
var moduleCount = 0;
|
|
126896
127018
|
forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
|
|
126897
127019
|
if (++moduleCount % 100 === 0)
|
|
@@ -126902,11 +127024,11 @@ var ts;
|
|
|
126902
127024
|
// Note: I think we shouldn't actually see resolved module symbols here, but weird merges
|
|
126903
127025
|
// can cause it to happen: see 'completionsImport_mergedReExport.ts'
|
|
126904
127026
|
if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
|
|
126905
|
-
cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson,
|
|
127027
|
+
cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
|
|
126906
127028
|
}
|
|
126907
127029
|
checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
|
|
126908
127030
|
if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
|
|
126909
|
-
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson,
|
|
127031
|
+
cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
|
|
126910
127032
|
}
|
|
126911
127033
|
});
|
|
126912
127034
|
});
|
|
@@ -128980,6 +129102,8 @@ var ts;
|
|
|
128980
129102
|
CompletionSource["ThisProperty"] = "ThisProperty/";
|
|
128981
129103
|
/** Auto-import that comes attached to a class member snippet */
|
|
128982
129104
|
CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
|
|
129105
|
+
/** A type-only import that needs to be promoted in order to be used at the completion location */
|
|
129106
|
+
CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
|
|
128983
129107
|
})(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
|
|
128984
129108
|
var SymbolOriginInfoKind;
|
|
128985
129109
|
(function (SymbolOriginInfoKind) {
|
|
@@ -128989,6 +129113,7 @@ var ts;
|
|
|
128989
129113
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
|
|
128990
129114
|
SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
|
|
128991
129115
|
SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
|
|
129116
|
+
SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
|
|
128992
129117
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
|
|
128993
129118
|
SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
|
|
128994
129119
|
})(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
|
|
@@ -129016,6 +129141,9 @@ var ts;
|
|
|
129016
129141
|
function originIsNullableMember(origin) {
|
|
129017
129142
|
return !!(origin.kind & 16 /* Nullable */);
|
|
129018
129143
|
}
|
|
129144
|
+
function originIsTypeOnlyAlias(origin) {
|
|
129145
|
+
return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
|
|
129146
|
+
}
|
|
129019
129147
|
var KeywordCompletionFilters;
|
|
129020
129148
|
(function (KeywordCompletionFilters) {
|
|
129021
129149
|
KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
|
|
@@ -129420,6 +129548,9 @@ var ts;
|
|
|
129420
129548
|
isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
|
|
129421
129549
|
}
|
|
129422
129550
|
}
|
|
129551
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
|
|
129552
|
+
hasAction = true;
|
|
129553
|
+
}
|
|
129423
129554
|
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
129424
129555
|
preferences.includeCompletionsWithInsertText &&
|
|
129425
129556
|
completionKind === 3 /* MemberLike */ &&
|
|
@@ -129764,6 +129895,9 @@ var ts;
|
|
|
129764
129895
|
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
|
|
129765
129896
|
return CompletionSource.ThisProperty;
|
|
129766
129897
|
}
|
|
129898
|
+
if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
|
|
129899
|
+
return CompletionSource.TypeOnlyAlias;
|
|
129900
|
+
}
|
|
129767
129901
|
}
|
|
129768
129902
|
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
129769
129903
|
var _a;
|
|
@@ -129791,7 +129925,7 @@ var ts;
|
|
|
129791
129925
|
continue;
|
|
129792
129926
|
}
|
|
129793
129927
|
/** True for locals; false for globals, module exports from other files, `this.` completions. */
|
|
129794
|
-
var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
129928
|
+
var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
|
|
129795
129929
|
uniques.set(name, shouldShadowLaterSymbols);
|
|
129796
129930
|
ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129797
129931
|
}
|
|
@@ -129804,6 +129938,7 @@ var ts;
|
|
|
129804
129938
|
add: function (name) { return uniques.set(name, true); },
|
|
129805
129939
|
};
|
|
129806
129940
|
function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
|
|
129941
|
+
var allFlags = symbol.flags;
|
|
129807
129942
|
if (!ts.isSourceFile(location)) {
|
|
129808
129943
|
// export = /**/ here we want to get all meanings, so any symbol is ok
|
|
129809
129944
|
if (ts.isExportAssignment(location.parent)) {
|
|
@@ -129829,11 +129964,10 @@ var ts;
|
|
|
129829
129964
|
|| symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
|
|
129830
129965
|
return false;
|
|
129831
129966
|
}
|
|
129832
|
-
|
|
129833
|
-
symbol = symbolOrigin;
|
|
129967
|
+
allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
|
|
129834
129968
|
// import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
|
|
129835
129969
|
if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
|
|
129836
|
-
return !!(
|
|
129970
|
+
return !!(allFlags & 1920 /* Namespace */);
|
|
129837
129971
|
}
|
|
129838
129972
|
if (isTypeOnlyLocation) {
|
|
129839
129973
|
// It's a type, but you can reach it by namespace.type as well
|
|
@@ -129841,7 +129975,7 @@ var ts;
|
|
|
129841
129975
|
}
|
|
129842
129976
|
}
|
|
129843
129977
|
// expressions are value space (which includes the value namespaces)
|
|
129844
|
-
return !!(
|
|
129978
|
+
return !!(allFlags & 111551 /* Value */);
|
|
129845
129979
|
}
|
|
129846
129980
|
}
|
|
129847
129981
|
Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
|
|
@@ -129975,8 +130109,7 @@ var ts;
|
|
|
129975
130109
|
Completions.createCompletionDetails = createCompletionDetails;
|
|
129976
130110
|
function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
|
|
129977
130111
|
if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
|
|
129978
|
-
|
|
129979
|
-
if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
|
|
130112
|
+
if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
|
|
129980
130113
|
// Import statement completion: 'import c|'
|
|
129981
130114
|
return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
|
|
129982
130115
|
}
|
|
@@ -129994,13 +130127,19 @@ var ts;
|
|
|
129994
130127
|
};
|
|
129995
130128
|
}
|
|
129996
130129
|
}
|
|
130130
|
+
if (originIsTypeOnlyAlias(origin)) {
|
|
130131
|
+
var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
|
|
130132
|
+
ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
|
|
130133
|
+
return { codeActions: [codeAction_1], sourceDisplay: undefined };
|
|
130134
|
+
}
|
|
129997
130135
|
if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
|
|
129998
130136
|
return { codeActions: undefined, sourceDisplay: undefined };
|
|
129999
130137
|
}
|
|
130000
130138
|
var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
|
|
130001
130139
|
var moduleSymbol = origin.moduleSymbol;
|
|
130002
130140
|
var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
|
|
130003
|
-
var
|
|
130141
|
+
var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
|
|
130142
|
+
var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction;
|
|
130004
130143
|
ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
|
|
130005
130144
|
return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
|
|
130006
130145
|
}
|
|
@@ -130670,21 +130809,29 @@ var ts;
|
|
|
130670
130809
|
var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
|
|
130671
130810
|
isInSnippetScope = isSnippetScope(scopeNode);
|
|
130672
130811
|
var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
|
|
130812
|
+
var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
|
|
130673
130813
|
symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
|
|
130674
130814
|
ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
|
|
130675
|
-
for (var
|
|
130676
|
-
var symbol =
|
|
130815
|
+
for (var i = 0; i < symbols.length; i++) {
|
|
130816
|
+
var symbol = symbols[i];
|
|
130677
130817
|
if (!typeChecker.isArgumentsSymbol(symbol) &&
|
|
130678
130818
|
!ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
|
|
130679
130819
|
symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
|
|
130680
130820
|
}
|
|
130821
|
+
if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
|
|
130822
|
+
var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
|
|
130823
|
+
if (typeOnlyAliasDeclaration) {
|
|
130824
|
+
var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
|
|
130825
|
+
symbolToOriginInfoMap[i] = origin;
|
|
130826
|
+
}
|
|
130827
|
+
}
|
|
130681
130828
|
}
|
|
130682
130829
|
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
|
130683
130830
|
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
|
|
130684
130831
|
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
|
|
130685
130832
|
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
|
130686
|
-
for (var
|
|
130687
|
-
var symbol =
|
|
130833
|
+
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
|
|
130834
|
+
var symbol = _a[_i];
|
|
130688
130835
|
symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
|
|
130689
130836
|
symbols.push(symbol);
|
|
130690
130837
|
symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
|
|
@@ -130787,7 +130934,8 @@ var ts;
|
|
|
130787
130934
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
130788
130935
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
130789
130936
|
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
|
|
130790
|
-
exportInfo.forEach(sourceFile.path, function (info,
|
|
130937
|
+
exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
|
|
130938
|
+
var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
|
|
130791
130939
|
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
|
130792
130940
|
return;
|
|
130793
130941
|
if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
|
|
@@ -130797,6 +130945,10 @@ var ts;
|
|
|
130797
130945
|
return;
|
|
130798
130946
|
if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
|
|
130799
130947
|
return;
|
|
130948
|
+
// Do not try to auto-import something with a lowercase first letter for a JSX tag
|
|
130949
|
+
var firstChar = symbolName.charCodeAt(0);
|
|
130950
|
+
if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
|
|
130951
|
+
return;
|
|
130800
130952
|
var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
|
|
130801
130953
|
if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
|
|
130802
130954
|
var defaultExportInfo = ts.find(info, isImportableExportInfo);
|
|
@@ -130873,16 +131025,19 @@ var ts;
|
|
|
130873
131025
|
return true;
|
|
130874
131026
|
}
|
|
130875
131027
|
if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) {
|
|
131028
|
+
// <Component<string> /**/ />
|
|
131029
|
+
// <Component<string> /**/ ><Component>
|
|
131030
|
+
// - contextToken: GreaterThanToken (before cursor)
|
|
131031
|
+
// - location: JsxSelfClosingElement or JsxOpeningElement
|
|
131032
|
+
// - contextToken.parent === location
|
|
131033
|
+
if (location === contextToken.parent && (location.kind === 279 /* JsxOpeningElement */ || location.kind === 278 /* JsxSelfClosingElement */)) {
|
|
131034
|
+
return false;
|
|
131035
|
+
}
|
|
130876
131036
|
if (contextToken.parent.kind === 279 /* JsxOpeningElement */) {
|
|
130877
|
-
//
|
|
130878
|
-
//
|
|
130879
|
-
//
|
|
130880
|
-
//
|
|
130881
|
-
// - different parents (JSXOpeningElement, JSXElement)
|
|
130882
|
-
// 2. <Component<string> /**/>
|
|
130883
|
-
// - contextToken: GreaterThanToken (before cursor)
|
|
130884
|
-
// - location: GreaterThanToken (after cursor)
|
|
130885
|
-
// - same parent (JSXOpeningElement)
|
|
131037
|
+
// <div>/**/
|
|
131038
|
+
// - contextToken: GreaterThanToken (before cursor)
|
|
131039
|
+
// - location: JSXElement
|
|
131040
|
+
// - different parents (JSXOpeningElement, JSXElement)
|
|
130886
131041
|
return location.parent.kind !== 279 /* JsxOpeningElement */;
|
|
130887
131042
|
}
|
|
130888
131043
|
if (contextToken.parent.kind === 280 /* JsxClosingElement */ || contextToken.parent.kind === 278 /* JsxSelfClosingElement */) {
|
|
@@ -132083,10 +132238,14 @@ var ts;
|
|
|
132083
132238
|
/** True if symbol is a type or a module containing at least one type. */
|
|
132084
132239
|
function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
|
|
132085
132240
|
if (seenModules === void 0) { seenModules = new ts.Map(); }
|
|
132086
|
-
|
|
132087
|
-
|
|
132088
|
-
|
|
132089
|
-
|
|
132241
|
+
// Since an alias can be merged with a local declaration, we need to test both the alias and its target.
|
|
132242
|
+
// This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
|
|
132243
|
+
return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
|
|
132244
|
+
function nonAliasCanBeReferencedAtTypeLocation(symbol) {
|
|
132245
|
+
return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
|
|
132246
|
+
!!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
|
|
132247
|
+
checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
|
|
132248
|
+
}
|
|
132090
132249
|
}
|
|
132091
132250
|
function isDeprecated(symbol, checker) {
|
|
132092
132251
|
var declarations = ts.skipAlias(symbol, checker).declarations;
|
|
@@ -134340,8 +134499,8 @@ var ts;
|
|
|
134340
134499
|
var sourceId = ts.getNodeId(sourceFile);
|
|
134341
134500
|
var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
|
|
134342
134501
|
var anyNewSymbols = false;
|
|
134343
|
-
for (var _i = 0,
|
|
134344
|
-
var sym =
|
|
134502
|
+
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
|
|
134503
|
+
var sym = symbols_1[_i];
|
|
134345
134504
|
anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
|
|
134346
134505
|
}
|
|
134347
134506
|
return anyNewSymbols;
|
|
@@ -141301,6 +141460,8 @@ var ts;
|
|
|
141301
141460
|
}
|
|
141302
141461
|
if (flags & 16 /* Function */)
|
|
141303
141462
|
return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */;
|
|
141463
|
+
// FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag.
|
|
141464
|
+
// So, even when the location is just on the declaration of setter, this function returns getter.
|
|
141304
141465
|
if (flags & 32768 /* GetAccessor */)
|
|
141305
141466
|
return "getter" /* memberGetAccessorElement */;
|
|
141306
141467
|
if (flags & 65536 /* SetAccessor */)
|
|
@@ -141387,9 +141548,24 @@ var ts;
|
|
|
141387
141548
|
}
|
|
141388
141549
|
// Class at constructor site need to be shown as constructor apart from property,method, vars
|
|
141389
141550
|
if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) {
|
|
141390
|
-
// If
|
|
141551
|
+
// If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor
|
|
141391
141552
|
if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) {
|
|
141392
|
-
|
|
141553
|
+
var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; });
|
|
141554
|
+
if (declaration) {
|
|
141555
|
+
switch (declaration.kind) {
|
|
141556
|
+
case 171 /* GetAccessor */:
|
|
141557
|
+
symbolKind = "getter" /* memberGetAccessorElement */;
|
|
141558
|
+
break;
|
|
141559
|
+
case 172 /* SetAccessor */:
|
|
141560
|
+
symbolKind = "setter" /* memberSetAccessorElement */;
|
|
141561
|
+
break;
|
|
141562
|
+
default:
|
|
141563
|
+
ts.Debug.assertNever(declaration);
|
|
141564
|
+
}
|
|
141565
|
+
}
|
|
141566
|
+
else {
|
|
141567
|
+
symbolKind = "property" /* memberVariableElement */;
|
|
141568
|
+
}
|
|
141393
141569
|
}
|
|
141394
141570
|
var signature = void 0;
|
|
141395
141571
|
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
@@ -141703,6 +141879,8 @@ var ts;
|
|
|
141703
141879
|
}
|
|
141704
141880
|
// For properties, variables and local vars: show the type
|
|
141705
141881
|
if (symbolKind === "property" /* memberVariableElement */ ||
|
|
141882
|
+
symbolKind === "getter" /* memberGetAccessorElement */ ||
|
|
141883
|
+
symbolKind === "setter" /* memberSetAccessorElement */ ||
|
|
141706
141884
|
symbolKind === "JSX attribute" /* jsxAttribute */ ||
|
|
141707
141885
|
symbolFlags & 3 /* Variable */ ||
|
|
141708
141886
|
symbolKind === "local var" /* localVariableElement */ ||
|
|
@@ -141773,7 +141951,7 @@ var ts;
|
|
|
141773
141951
|
}
|
|
141774
141952
|
}
|
|
141775
141953
|
if (tags.length === 0 && !hasMultipleSignatures) {
|
|
141776
|
-
tags = symbol.
|
|
141954
|
+
tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
|
|
141777
141955
|
}
|
|
141778
141956
|
if (documentation.length === 0 && documentationFromAlias) {
|
|
141779
141957
|
documentation = documentationFromAlias;
|
|
@@ -145193,6 +145371,7 @@ var ts;
|
|
|
145193
145371
|
ChangeTracker.prototype.delete = function (sourceFile, node) {
|
|
145194
145372
|
this.deletedNodes.push({ sourceFile: sourceFile, node: node });
|
|
145195
145373
|
};
|
|
145374
|
+
/** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
|
|
145196
145375
|
ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
|
|
145197
145376
|
if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
|
|
145198
145377
|
this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
|
|
@@ -145596,6 +145775,15 @@ var ts;
|
|
|
145596
145775
|
ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
|
|
145597
145776
|
this.insertText(sourceFile, node.getStart(sourceFile), "export ");
|
|
145598
145777
|
};
|
|
145778
|
+
ChangeTracker.prototype.insertImportSpecifierAtIndex = function (sourceFile, importSpecifier, namedImports, index) {
|
|
145779
|
+
var prevSpecifier = namedImports.elements[index - 1];
|
|
145780
|
+
if (prevSpecifier) {
|
|
145781
|
+
this.insertNodeInListAfter(sourceFile, prevSpecifier, importSpecifier);
|
|
145782
|
+
}
|
|
145783
|
+
else {
|
|
145784
|
+
this.insertNodeBefore(sourceFile, namedImports.elements[0], importSpecifier, !ts.positionsAreOnSameLine(namedImports.elements[0].getStart(), namedImports.parent.parent.getStart(), sourceFile));
|
|
145785
|
+
}
|
|
145786
|
+
};
|
|
145599
145787
|
/**
|
|
145600
145788
|
* This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
|
|
145601
145789
|
* i.e. arguments in arguments lists, parameters in parameter lists etc.
|
|
@@ -149098,7 +149286,8 @@ var ts;
|
|
|
149098
149286
|
ts.Diagnostics.Cannot_find_namespace_0.code,
|
|
149099
149287
|
ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
|
|
149100
149288
|
ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
|
|
149101
|
-
ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
|
|
149289
|
+
ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
|
|
149290
|
+
ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
|
|
149102
149291
|
];
|
|
149103
149292
|
codefix.registerCodeFix({
|
|
149104
149293
|
errorCodes: errorCodes,
|
|
@@ -149144,7 +149333,7 @@ var ts;
|
|
|
149144
149333
|
var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
|
|
149145
149334
|
var checker = program.getTypeChecker();
|
|
149146
149335
|
var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
|
|
149147
|
-
var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, program, preferences, useAutoImportProvider);
|
|
149336
|
+
var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
|
|
149148
149337
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149149
149338
|
var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
149150
149339
|
if (fix) {
|
|
@@ -149203,6 +149392,9 @@ var ts;
|
|
|
149203
149392
|
}
|
|
149204
149393
|
break;
|
|
149205
149394
|
}
|
|
149395
|
+
case 4 /* PromoteTypeOnly */:
|
|
149396
|
+
// Excluding from fix-all
|
|
149397
|
+
break;
|
|
149206
149398
|
default:
|
|
149207
149399
|
ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
|
|
149208
149400
|
}
|
|
@@ -149294,6 +149486,7 @@ var ts;
|
|
|
149294
149486
|
ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
|
|
149295
149487
|
ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
|
|
149296
149488
|
ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
|
|
149489
|
+
ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
|
|
149297
149490
|
})(ImportFixKind || (ImportFixKind = {}));
|
|
149298
149491
|
// These should not be combined as bitflags, but are given powers of 2 values to
|
|
149299
149492
|
// easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
|
|
@@ -149305,11 +149498,11 @@ var ts;
|
|
|
149305
149498
|
AddAsTypeOnly[AddAsTypeOnly["Required"] = 2] = "Required";
|
|
149306
149499
|
AddAsTypeOnly[AddAsTypeOnly["NotAllowed"] = 4] = "NotAllowed";
|
|
149307
149500
|
})(AddAsTypeOnly || (AddAsTypeOnly = {}));
|
|
149308
|
-
function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) {
|
|
149501
|
+
function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, isJsxTagName, host, program, formatContext, position, preferences) {
|
|
149309
149502
|
var compilerOptions = program.getCompilerOptions();
|
|
149310
149503
|
var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name))
|
|
149311
149504
|
? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
|
|
149312
|
-
: getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true);
|
|
149505
|
+
: getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
|
|
149313
149506
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149314
149507
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
|
|
149315
149508
|
var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
|
|
@@ -149319,6 +149512,13 @@ var ts;
|
|
|
149319
149512
|
};
|
|
149320
149513
|
}
|
|
149321
149514
|
codefix.getImportCompletionAction = getImportCompletionAction;
|
|
149515
|
+
function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
|
|
149516
|
+
var compilerOptions = program.getCompilerOptions();
|
|
149517
|
+
var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
|
|
149518
|
+
var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
|
|
149519
|
+
return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
|
|
149520
|
+
}
|
|
149521
|
+
codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
|
|
149322
149522
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
149323
149523
|
ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
|
|
149324
149524
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
@@ -149348,7 +149548,7 @@ var ts;
|
|
|
149348
149548
|
}
|
|
149349
149549
|
}
|
|
149350
149550
|
}
|
|
149351
|
-
function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) {
|
|
149551
|
+
function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, isJsxTagName, host, program, preferences, useAutoImportProvider) {
|
|
149352
149552
|
var result = [];
|
|
149353
149553
|
var compilerOptions = program.getCompilerOptions();
|
|
149354
149554
|
var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
|
|
@@ -149361,7 +149561,7 @@ var ts;
|
|
|
149361
149561
|
return;
|
|
149362
149562
|
}
|
|
149363
149563
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
149364
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
|
|
149564
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
|
|
149365
149565
|
result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson: isFromPackageJson });
|
|
149366
149566
|
}
|
|
149367
149567
|
for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
|
|
@@ -149599,9 +149799,21 @@ var ts;
|
|
|
149599
149799
|
}
|
|
149600
149800
|
function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
|
|
149601
149801
|
var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
|
|
149602
|
-
var info
|
|
149603
|
-
|
|
149604
|
-
|
|
149802
|
+
var info;
|
|
149803
|
+
if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
|
|
149804
|
+
info = getFixesInfoForUMDImport(context, symbolToken);
|
|
149805
|
+
}
|
|
149806
|
+
else if (!ts.isIdentifier(symbolToken)) {
|
|
149807
|
+
return undefined;
|
|
149808
|
+
}
|
|
149809
|
+
else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
|
|
149810
|
+
var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
|
|
149811
|
+
var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
|
|
149812
|
+
return fix && { fixes: [fix], symbolName: symbolName_1 };
|
|
149813
|
+
}
|
|
149814
|
+
else {
|
|
149815
|
+
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
149816
|
+
}
|
|
149605
149817
|
var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
|
|
149606
149818
|
return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
|
|
149607
149819
|
}
|
|
@@ -149718,13 +149930,23 @@ var ts;
|
|
|
149718
149930
|
ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
|
|
149719
149931
|
var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
|
|
149720
149932
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149721
|
-
var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
149933
|
+
var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
|
|
149722
149934
|
var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
|
|
149723
149935
|
var _ = _a[0], exportInfos = _a[1];
|
|
149724
149936
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
149725
149937
|
}));
|
|
149726
149938
|
return { fixes: fixes, symbolName: symbolName };
|
|
149727
149939
|
}
|
|
149940
|
+
function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
|
|
149941
|
+
var checker = program.getTypeChecker();
|
|
149942
|
+
var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
|
|
149943
|
+
if (!symbol)
|
|
149944
|
+
return undefined;
|
|
149945
|
+
var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
|
|
149946
|
+
if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
|
|
149947
|
+
return undefined;
|
|
149948
|
+
return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
|
|
149949
|
+
}
|
|
149728
149950
|
function jsxModeNeedsExplicitImport(jsx) {
|
|
149729
149951
|
return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
|
|
149730
149952
|
}
|
|
@@ -149732,14 +149954,20 @@ var ts;
|
|
|
149732
149954
|
var parent = symbolToken.parent;
|
|
149733
149955
|
if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
|
|
149734
149956
|
var jsxNamespace = checker.getJsxNamespace(sourceFile);
|
|
149735
|
-
if (
|
|
149957
|
+
if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
|
|
149736
149958
|
return jsxNamespace;
|
|
149737
149959
|
}
|
|
149738
149960
|
}
|
|
149739
149961
|
return symbolToken.text;
|
|
149740
149962
|
}
|
|
149963
|
+
function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
|
|
149964
|
+
if (ts.isIntrinsicJsxName(symbolToken.text))
|
|
149965
|
+
return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
|
|
149966
|
+
var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
|
|
149967
|
+
return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
|
|
149968
|
+
}
|
|
149741
149969
|
// Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
|
|
149742
|
-
function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
|
|
149970
|
+
function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
|
|
149743
149971
|
var _a;
|
|
149744
149972
|
// For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
|
|
149745
149973
|
// Maps symbol id to info for modules providing that symbol (original export + re-exports).
|
|
@@ -149762,7 +149990,7 @@ var ts;
|
|
|
149762
149990
|
cancellationToken.throwIfCancellationRequested();
|
|
149763
149991
|
var compilerOptions = program.getCompilerOptions();
|
|
149764
149992
|
var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
|
|
149765
|
-
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
|
|
149993
|
+
if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
|
|
149766
149994
|
addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
|
|
149767
149995
|
}
|
|
149768
149996
|
// check exports with the same name
|
|
@@ -149836,10 +150064,80 @@ var ts;
|
|
|
149836
150064
|
ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
|
|
149837
150065
|
return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
|
|
149838
150066
|
}
|
|
150067
|
+
case 4 /* PromoteTypeOnly */: {
|
|
150068
|
+
var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
|
|
150069
|
+
var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
|
|
150070
|
+
return promotedDeclaration.kind === 269 /* ImportSpecifier */
|
|
150071
|
+
? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
|
|
150072
|
+
: [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
|
|
150073
|
+
}
|
|
149839
150074
|
default:
|
|
149840
150075
|
return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
|
|
149841
150076
|
}
|
|
149842
150077
|
}
|
|
150078
|
+
function getModuleSpecifierText(promotedDeclaration) {
|
|
150079
|
+
var _a, _b;
|
|
150080
|
+
return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
|
|
150081
|
+
? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText()
|
|
150082
|
+
: ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
|
|
150083
|
+
}
|
|
150084
|
+
function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceFile) {
|
|
150085
|
+
// See comment in `doAddExistingFix` on constant with the same name.
|
|
150086
|
+
var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
|
|
150087
|
+
switch (aliasDeclaration.kind) {
|
|
150088
|
+
case 269 /* ImportSpecifier */:
|
|
150089
|
+
if (aliasDeclaration.isTypeOnly) {
|
|
150090
|
+
if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
|
|
150091
|
+
changes.delete(sourceFile, aliasDeclaration);
|
|
150092
|
+
var newSpecifier = ts.factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name);
|
|
150093
|
+
var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier);
|
|
150094
|
+
changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
|
|
150095
|
+
}
|
|
150096
|
+
else {
|
|
150097
|
+
changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
|
|
150098
|
+
}
|
|
150099
|
+
return aliasDeclaration;
|
|
150100
|
+
}
|
|
150101
|
+
else {
|
|
150102
|
+
ts.Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
|
|
150103
|
+
promoteImportClause(aliasDeclaration.parent.parent);
|
|
150104
|
+
return aliasDeclaration.parent.parent;
|
|
150105
|
+
}
|
|
150106
|
+
case 266 /* ImportClause */:
|
|
150107
|
+
promoteImportClause(aliasDeclaration);
|
|
150108
|
+
return aliasDeclaration;
|
|
150109
|
+
case 267 /* NamespaceImport */:
|
|
150110
|
+
promoteImportClause(aliasDeclaration.parent);
|
|
150111
|
+
return aliasDeclaration.parent;
|
|
150112
|
+
case 264 /* ImportEqualsDeclaration */:
|
|
150113
|
+
changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
|
|
150114
|
+
return aliasDeclaration;
|
|
150115
|
+
default:
|
|
150116
|
+
ts.Debug.failBadSyntaxKind(aliasDeclaration);
|
|
150117
|
+
}
|
|
150118
|
+
function promoteImportClause(importClause) {
|
|
150119
|
+
changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
|
|
150120
|
+
if (convertExistingToTypeOnly) {
|
|
150121
|
+
var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
|
|
150122
|
+
if (namedImports && namedImports.elements.length > 1) {
|
|
150123
|
+
if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
|
|
150124
|
+
aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
|
|
150125
|
+
namedImports.elements.indexOf(aliasDeclaration) !== 0) {
|
|
150126
|
+
// The import specifier being promoted will be the only non-type-only,
|
|
150127
|
+
// import in the NamedImports, so it should be moved to the front.
|
|
150128
|
+
changes.delete(sourceFile, aliasDeclaration);
|
|
150129
|
+
changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
|
|
150130
|
+
}
|
|
150131
|
+
for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
|
|
150132
|
+
var element = _a[_i];
|
|
150133
|
+
if (element !== aliasDeclaration && !element.isTypeOnly) {
|
|
150134
|
+
changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
|
|
150135
|
+
}
|
|
150136
|
+
}
|
|
150137
|
+
}
|
|
150138
|
+
}
|
|
150139
|
+
}
|
|
150140
|
+
}
|
|
149843
150141
|
function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
|
|
149844
150142
|
var _a;
|
|
149845
150143
|
if (clause.kind === 200 /* ObjectBindingPattern */) {
|
|
@@ -149877,13 +150175,7 @@ var ts;
|
|
|
149877
150175
|
var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
|
|
149878
150176
|
? 0
|
|
149879
150177
|
: ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
|
|
149880
|
-
|
|
149881
|
-
if (prevSpecifier) {
|
|
149882
|
-
changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
|
|
149883
|
-
}
|
|
149884
|
-
else {
|
|
149885
|
-
changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
|
|
149886
|
-
}
|
|
150178
|
+
changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
|
|
149887
150179
|
}
|
|
149888
150180
|
}
|
|
149889
150181
|
else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
|
|
@@ -149998,17 +150290,20 @@ var ts;
|
|
|
149998
150290
|
var declarations = _a.declarations;
|
|
149999
150291
|
return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); });
|
|
150000
150292
|
}
|
|
150001
|
-
function moduleSymbolToValidIdentifier(moduleSymbol, target) {
|
|
150002
|
-
return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target);
|
|
150293
|
+
function moduleSymbolToValidIdentifier(moduleSymbol, target, forceCapitalize) {
|
|
150294
|
+
return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target, forceCapitalize);
|
|
150003
150295
|
}
|
|
150004
150296
|
codefix.moduleSymbolToValidIdentifier = moduleSymbolToValidIdentifier;
|
|
150005
|
-
function moduleSpecifierToValidIdentifier(moduleSpecifier, target) {
|
|
150297
|
+
function moduleSpecifierToValidIdentifier(moduleSpecifier, target, forceCapitalize) {
|
|
150006
150298
|
var baseName = ts.getBaseFileName(ts.removeSuffix(moduleSpecifier, "/index"));
|
|
150007
150299
|
var res = "";
|
|
150008
150300
|
var lastCharWasValid = true;
|
|
150009
150301
|
var firstCharCode = baseName.charCodeAt(0);
|
|
150010
150302
|
if (ts.isIdentifierStart(firstCharCode, target)) {
|
|
150011
150303
|
res += String.fromCharCode(firstCharCode);
|
|
150304
|
+
if (forceCapitalize) {
|
|
150305
|
+
res = res.toUpperCase();
|
|
150306
|
+
}
|
|
150012
150307
|
}
|
|
150013
150308
|
else {
|
|
150014
150309
|
lastCharWasValid = false;
|
|
@@ -159977,13 +160272,11 @@ var ts;
|
|
|
159977
160272
|
switch (context === null || context === void 0 ? void 0 : context.kind) {
|
|
159978
160273
|
case 171 /* GetAccessor */:
|
|
159979
160274
|
if (!this.contextualGetAccessorDocumentationComment) {
|
|
159980
|
-
this.contextualGetAccessorDocumentationComment = ts.emptyArray;
|
|
159981
160275
|
this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
159982
160276
|
}
|
|
159983
160277
|
return this.contextualGetAccessorDocumentationComment;
|
|
159984
160278
|
case 172 /* SetAccessor */:
|
|
159985
160279
|
if (!this.contextualSetAccessorDocumentationComment) {
|
|
159986
|
-
this.contextualSetAccessorDocumentationComment = ts.emptyArray;
|
|
159987
160280
|
this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
159988
160281
|
}
|
|
159989
160282
|
return this.contextualSetAccessorDocumentationComment;
|
|
@@ -159993,10 +160286,26 @@ var ts;
|
|
|
159993
160286
|
};
|
|
159994
160287
|
SymbolObject.prototype.getJsDocTags = function (checker) {
|
|
159995
160288
|
if (this.tags === undefined) {
|
|
159996
|
-
this.tags =
|
|
160289
|
+
this.tags = getJsDocTagsOfDeclarations(this.declarations, checker);
|
|
159997
160290
|
}
|
|
159998
160291
|
return this.tags;
|
|
159999
160292
|
};
|
|
160293
|
+
SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
|
|
160294
|
+
switch (context === null || context === void 0 ? void 0 : context.kind) {
|
|
160295
|
+
case 171 /* GetAccessor */:
|
|
160296
|
+
if (!this.contextualGetAccessorTags) {
|
|
160297
|
+
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
|
|
160298
|
+
}
|
|
160299
|
+
return this.contextualGetAccessorTags;
|
|
160300
|
+
case 172 /* SetAccessor */:
|
|
160301
|
+
if (!this.contextualSetAccessorTags) {
|
|
160302
|
+
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
|
|
160303
|
+
}
|
|
160304
|
+
return this.contextualSetAccessorTags;
|
|
160305
|
+
default:
|
|
160306
|
+
return this.getJsDocTags(checker);
|
|
160307
|
+
}
|
|
160308
|
+
};
|
|
160000
160309
|
return SymbolObject;
|
|
160001
160310
|
}());
|
|
160002
160311
|
var TokenObject = /** @class */ (function (_super) {
|
|
@@ -160166,10 +160475,7 @@ var ts;
|
|
|
160166
160475
|
return this.documentationComment || (this.documentationComment = getDocumentationComment(ts.singleElementArray(this.declaration), this.checker));
|
|
160167
160476
|
};
|
|
160168
160477
|
SignatureObject.prototype.getJsDocTags = function () {
|
|
160169
|
-
|
|
160170
|
-
this.jsDocTags = this.declaration ? getJsDocTagsOfSignature(this.declaration, this.checker) : [];
|
|
160171
|
-
}
|
|
160172
|
-
return this.jsDocTags;
|
|
160478
|
+
return this.jsDocTags || (this.jsDocTags = getJsDocTagsOfDeclarations(ts.singleElementArray(this.declaration), this.checker));
|
|
160173
160479
|
};
|
|
160174
160480
|
return SignatureObject;
|
|
160175
160481
|
}());
|
|
@@ -160181,12 +160487,30 @@ var ts;
|
|
|
160181
160487
|
function hasJSDocInheritDocTag(node) {
|
|
160182
160488
|
return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; });
|
|
160183
160489
|
}
|
|
160184
|
-
function
|
|
160185
|
-
|
|
160186
|
-
|
|
160187
|
-
|
|
160188
|
-
|
|
160189
|
-
|
|
160490
|
+
function getJsDocTagsOfDeclarations(declarations, checker) {
|
|
160491
|
+
if (!declarations)
|
|
160492
|
+
return ts.emptyArray;
|
|
160493
|
+
var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
|
|
160494
|
+
if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
|
|
160495
|
+
var seenSymbols_1 = new ts.Set();
|
|
160496
|
+
var _loop_22 = function (declaration) {
|
|
160497
|
+
var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
|
|
160498
|
+
var _a;
|
|
160499
|
+
if (!seenSymbols_1.has(symbol)) {
|
|
160500
|
+
seenSymbols_1.add(symbol);
|
|
160501
|
+
if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
|
|
160502
|
+
return symbol.getContextualJsDocTags(declaration, checker);
|
|
160503
|
+
}
|
|
160504
|
+
return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined;
|
|
160505
|
+
}
|
|
160506
|
+
});
|
|
160507
|
+
if (inheritedTags) {
|
|
160508
|
+
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
160509
|
+
}
|
|
160510
|
+
};
|
|
160511
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
160512
|
+
var declaration = declarations_6[_i];
|
|
160513
|
+
_loop_22(declaration);
|
|
160190
160514
|
}
|
|
160191
160515
|
}
|
|
160192
160516
|
return tags;
|
|
@@ -160196,18 +160520,24 @@ var ts;
|
|
|
160196
160520
|
return ts.emptyArray;
|
|
160197
160521
|
var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
|
|
160198
160522
|
if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
|
|
160199
|
-
var
|
|
160200
|
-
|
|
160201
|
-
var declaration = declarations_6[_i];
|
|
160523
|
+
var seenSymbols_2 = new ts.Set();
|
|
160524
|
+
var _loop_23 = function (declaration) {
|
|
160202
160525
|
var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
|
|
160203
|
-
if (!
|
|
160204
|
-
|
|
160526
|
+
if (!seenSymbols_2.has(symbol)) {
|
|
160527
|
+
seenSymbols_2.add(symbol);
|
|
160528
|
+
if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
|
|
160529
|
+
return symbol.getContextualDocumentationComment(declaration, checker);
|
|
160530
|
+
}
|
|
160205
160531
|
return symbol.getDocumentationComment(checker);
|
|
160206
160532
|
}
|
|
160207
160533
|
});
|
|
160208
160534
|
// TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs
|
|
160209
160535
|
if (inheritedDocs)
|
|
160210
160536
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
160537
|
+
};
|
|
160538
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
160539
|
+
var declaration = declarations_7[_i];
|
|
160540
|
+
_loop_23(declaration);
|
|
160211
160541
|
}
|
|
160212
160542
|
}
|
|
160213
160543
|
return doc;
|