typescript 4.7.0-dev.20220315 → 4.7.0-dev.20220318
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/tsc.js +94 -56
- package/lib/tsserver.js +256 -78
- package/lib/tsserverlibrary.js +256 -78
- package/lib/typescript.js +235 -76
- package/lib/typescriptServices.js +235 -76
- package/lib/typingsInstaller.js +100 -57
- package/package.json +1 -1
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220318";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8228,7 +8228,7 @@ var ts;
|
|
|
8228
8228
|
Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
|
|
8229
8229
|
_0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
|
|
8230
8230
|
A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."),
|
|
8231
|
-
|
|
8231
|
+
The_parser_expected_to_find_a_1_to_match_the_0_token_here: diag(1007, ts.DiagnosticCategory.Error, "The_parser_expected_to_find_a_1_to_match_the_0_token_here_1007", "The parser expected to find a '{1}' to match the '{0}' token here."),
|
|
8232
8232
|
Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
|
|
8233
8233
|
Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
|
|
8234
8234
|
An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."),
|
|
@@ -8444,6 +8444,7 @@ var ts;
|
|
|
8444
8444
|
Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided: diag(1269, ts.DiagnosticCategory.Error, "Cannot_use_export_import_on_a_type_or_type_only_namespace_when_the_isolatedModules_flag_is_provided_1269", "Cannot use 'export import' on a type or type-only namespace when the '--isolatedModules' flag is provided."),
|
|
8445
8445
|
Decorator_function_return_type_0_is_not_assignable_to_type_1: diag(1270, ts.DiagnosticCategory.Error, "Decorator_function_return_type_0_is_not_assignable_to_type_1_1270", "Decorator function return type '{0}' is not assignable to type '{1}'."),
|
|
8446
8446
|
Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any: diag(1271, ts.DiagnosticCategory.Error, "Decorator_function_return_type_is_0_but_is_expected_to_be_void_or_any_1271", "Decorator function return type is '{0}' but is expected to be 'void' or 'any'."),
|
|
8447
|
+
A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled: diag(1272, ts.DiagnosticCategory.Error, "A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_w_1272", "A type referenced in a decorated signature must be imported with 'import type' or a namespace import when 'isolatedModules' and 'emitDecoratorMetadata' are enabled."),
|
|
8447
8448
|
with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."),
|
|
8448
8449
|
await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1308, ts.DiagnosticCategory.Error, "await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1308", "'await' expressions are only allowed within async functions and at the top levels of modules."),
|
|
8449
8450
|
Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern: diag(1312, ts.DiagnosticCategory.Error, "Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_1312", "Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern."),
|
|
@@ -31620,20 +31621,23 @@ var ts;
|
|
|
31620
31621
|
return inContext(32768 /* AwaitContext */);
|
|
31621
31622
|
}
|
|
31622
31623
|
function parseErrorAtCurrentToken(message, arg0) {
|
|
31623
|
-
parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
|
|
31624
|
+
return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
|
|
31624
31625
|
}
|
|
31625
31626
|
function parseErrorAtPosition(start, length, message, arg0) {
|
|
31626
31627
|
// Don't report another error if it would just be at the same position as the last error.
|
|
31627
31628
|
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
31629
|
+
var result;
|
|
31628
31630
|
if (!lastError || start !== lastError.start) {
|
|
31629
|
-
|
|
31631
|
+
result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0);
|
|
31632
|
+
parseDiagnostics.push(result);
|
|
31630
31633
|
}
|
|
31631
31634
|
// Mark that we've encountered an error. We'll set an appropriate bit on the next
|
|
31632
31635
|
// node we finish so that it can't be reused incrementally.
|
|
31633
31636
|
parseErrorBeforeNextFinishedNode = true;
|
|
31637
|
+
return result;
|
|
31634
31638
|
}
|
|
31635
31639
|
function parseErrorAt(start, end, message, arg0) {
|
|
31636
|
-
parseErrorAtPosition(start, end - start, message, arg0);
|
|
31640
|
+
return parseErrorAtPosition(start, end - start, message, arg0);
|
|
31637
31641
|
}
|
|
31638
31642
|
function parseErrorAtRange(range, message, arg0) {
|
|
31639
31643
|
parseErrorAt(range.pos, range.end, message, arg0);
|
|
@@ -31906,6 +31910,19 @@ var ts;
|
|
|
31906
31910
|
parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
|
|
31907
31911
|
return false;
|
|
31908
31912
|
}
|
|
31913
|
+
function parseExpectedMatchingBrackets(openKind, closeKind, openParsed, openPosition) {
|
|
31914
|
+
if (token() === closeKind) {
|
|
31915
|
+
nextToken();
|
|
31916
|
+
return;
|
|
31917
|
+
}
|
|
31918
|
+
var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind));
|
|
31919
|
+
if (!openParsed) {
|
|
31920
|
+
return;
|
|
31921
|
+
}
|
|
31922
|
+
if (lastError) {
|
|
31923
|
+
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openPosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, ts.tokenToString(openKind), ts.tokenToString(closeKind)));
|
|
31924
|
+
}
|
|
31925
|
+
}
|
|
31909
31926
|
function parseOptional(t) {
|
|
31910
31927
|
if (token() === t) {
|
|
31911
31928
|
nextToken();
|
|
@@ -33554,7 +33571,7 @@ var ts;
|
|
|
33554
33571
|
if (!parseExpected(19 /* CloseBraceToken */)) {
|
|
33555
33572
|
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
33556
33573
|
if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
|
|
33557
|
-
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.
|
|
33574
|
+
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}"));
|
|
33558
33575
|
}
|
|
33559
33576
|
}
|
|
33560
33577
|
return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
|
|
@@ -35364,10 +35381,11 @@ var ts;
|
|
|
35364
35381
|
}
|
|
35365
35382
|
function parseArrayLiteralExpression() {
|
|
35366
35383
|
var pos = getNodePos();
|
|
35367
|
-
|
|
35384
|
+
var openBracketPosition = scanner.getTokenPos();
|
|
35385
|
+
var openBracketParsed = parseExpected(22 /* OpenBracketToken */);
|
|
35368
35386
|
var multiLine = scanner.hasPrecedingLineBreak();
|
|
35369
35387
|
var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
|
|
35370
|
-
|
|
35388
|
+
parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition);
|
|
35371
35389
|
return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
|
|
35372
35390
|
}
|
|
35373
35391
|
function parseObjectLiteralElement() {
|
|
@@ -35424,15 +35442,10 @@ var ts;
|
|
|
35424
35442
|
function parseObjectLiteralExpression() {
|
|
35425
35443
|
var pos = getNodePos();
|
|
35426
35444
|
var openBracePosition = scanner.getTokenPos();
|
|
35427
|
-
parseExpected(18 /* OpenBraceToken */);
|
|
35445
|
+
var openBraceParsed = parseExpected(18 /* OpenBraceToken */);
|
|
35428
35446
|
var multiLine = scanner.hasPrecedingLineBreak();
|
|
35429
35447
|
var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
|
|
35430
|
-
|
|
35431
|
-
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
35432
|
-
if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
|
|
35433
|
-
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
|
|
35434
|
-
}
|
|
35435
|
-
}
|
|
35448
|
+
parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition);
|
|
35436
35449
|
return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
|
|
35437
35450
|
}
|
|
35438
35451
|
function parseFunctionExpression() {
|
|
@@ -35488,15 +35501,11 @@ var ts;
|
|
|
35488
35501
|
var pos = getNodePos();
|
|
35489
35502
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35490
35503
|
var openBracePosition = scanner.getTokenPos();
|
|
35491
|
-
|
|
35504
|
+
var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage);
|
|
35505
|
+
if (openBraceParsed || ignoreMissingOpenBrace) {
|
|
35492
35506
|
var multiLine = scanner.hasPrecedingLineBreak();
|
|
35493
35507
|
var statements = parseList(1 /* BlockStatements */, parseStatement);
|
|
35494
|
-
|
|
35495
|
-
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
35496
|
-
if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
|
|
35497
|
-
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
|
|
35498
|
-
}
|
|
35499
|
-
}
|
|
35508
|
+
parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition);
|
|
35500
35509
|
var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc);
|
|
35501
35510
|
if (token() === 63 /* EqualsToken */) {
|
|
35502
35511
|
parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses);
|
|
@@ -35541,9 +35550,10 @@ var ts;
|
|
|
35541
35550
|
var pos = getNodePos();
|
|
35542
35551
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35543
35552
|
parseExpected(99 /* IfKeyword */);
|
|
35544
|
-
|
|
35553
|
+
var openParenPosition = scanner.getTokenPos();
|
|
35554
|
+
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35545
35555
|
var expression = allowInAnd(parseExpression);
|
|
35546
|
-
|
|
35556
|
+
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35547
35557
|
var thenStatement = parseStatement();
|
|
35548
35558
|
var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined;
|
|
35549
35559
|
return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc);
|
|
@@ -35554,9 +35564,10 @@ var ts;
|
|
|
35554
35564
|
parseExpected(90 /* DoKeyword */);
|
|
35555
35565
|
var statement = parseStatement();
|
|
35556
35566
|
parseExpected(115 /* WhileKeyword */);
|
|
35557
|
-
|
|
35567
|
+
var openParenPosition = scanner.getTokenPos();
|
|
35568
|
+
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35558
35569
|
var expression = allowInAnd(parseExpression);
|
|
35559
|
-
|
|
35570
|
+
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35560
35571
|
// From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
|
|
35561
35572
|
// 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
|
|
35562
35573
|
// spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby
|
|
@@ -35568,9 +35579,10 @@ var ts;
|
|
|
35568
35579
|
var pos = getNodePos();
|
|
35569
35580
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35570
35581
|
parseExpected(115 /* WhileKeyword */);
|
|
35571
|
-
|
|
35582
|
+
var openParenPosition = scanner.getTokenPos();
|
|
35583
|
+
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35572
35584
|
var expression = allowInAnd(parseExpression);
|
|
35573
|
-
|
|
35585
|
+
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35574
35586
|
var statement = parseStatement();
|
|
35575
35587
|
return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc);
|
|
35576
35588
|
}
|
|
@@ -35637,9 +35649,10 @@ var ts;
|
|
|
35637
35649
|
var pos = getNodePos();
|
|
35638
35650
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35639
35651
|
parseExpected(116 /* WithKeyword */);
|
|
35640
|
-
|
|
35652
|
+
var openParenPosition = scanner.getTokenPos();
|
|
35653
|
+
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35641
35654
|
var expression = allowInAnd(parseExpression);
|
|
35642
|
-
|
|
35655
|
+
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35643
35656
|
var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
|
|
35644
35657
|
return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
|
|
35645
35658
|
}
|
|
@@ -36773,7 +36786,7 @@ var ts;
|
|
|
36773
36786
|
if (!parseExpected(19 /* CloseBraceToken */)) {
|
|
36774
36787
|
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
36775
36788
|
if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
|
|
36776
|
-
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.
|
|
36789
|
+
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}"));
|
|
36777
36790
|
}
|
|
36778
36791
|
}
|
|
36779
36792
|
return finishNode(factory.createAssertClause(elements, multiLine), pos);
|
|
@@ -37749,8 +37762,7 @@ var ts;
|
|
|
37749
37762
|
hasChildren = true;
|
|
37750
37763
|
if (child.kind === 342 /* JSDocTypeTag */) {
|
|
37751
37764
|
if (childTypeTag) {
|
|
37752
|
-
parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
|
|
37753
|
-
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
37765
|
+
var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
|
|
37754
37766
|
if (lastError) {
|
|
37755
37767
|
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here));
|
|
37756
37768
|
}
|
|
@@ -41078,7 +41090,10 @@ var ts;
|
|
|
41078
41090
|
* file to. e.g. outDir
|
|
41079
41091
|
*/
|
|
41080
41092
|
function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
|
|
41081
|
-
|
|
41093
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName });
|
|
41094
|
+
var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
|
|
41095
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
41096
|
+
return result;
|
|
41082
41097
|
}
|
|
41083
41098
|
ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
|
|
41084
41099
|
/*@internal*/
|
|
@@ -58488,8 +58503,10 @@ var ts;
|
|
|
58488
58503
|
return type;
|
|
58489
58504
|
}
|
|
58490
58505
|
function isMappedTypeGenericIndexedAccess(type) {
|
|
58491
|
-
|
|
58492
|
-
|
|
58506
|
+
var objectType;
|
|
58507
|
+
return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ &&
|
|
58508
|
+
!isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
|
|
58509
|
+
!objectType.declaration.questionToken && !objectType.declaration.nameType);
|
|
58493
58510
|
}
|
|
58494
58511
|
/**
|
|
58495
58512
|
* For a type parameter, return the base constraint of the type parameter. For the string, number,
|
|
@@ -59077,7 +59094,19 @@ var ts;
|
|
|
59077
59094
|
return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
|
|
59078
59095
|
});
|
|
59079
59096
|
var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */);
|
|
59080
|
-
|
|
59097
|
+
if (lastParamVariadicType) {
|
|
59098
|
+
// Parameter has effective annotation, lock in type
|
|
59099
|
+
syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type));
|
|
59100
|
+
}
|
|
59101
|
+
else {
|
|
59102
|
+
// Parameter has no annotation
|
|
59103
|
+
// By using a `DeferredType` symbol, we allow the type of this rest arg to be overriden by contextual type assignment so long as its type hasn't been
|
|
59104
|
+
// cached by `getTypeOfSymbol` yet.
|
|
59105
|
+
syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */;
|
|
59106
|
+
syntheticArgsSymbol.deferralParent = neverType;
|
|
59107
|
+
syntheticArgsSymbol.deferralConstituents = [anyArrayType];
|
|
59108
|
+
syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType];
|
|
59109
|
+
}
|
|
59081
59110
|
if (lastParamVariadicType) {
|
|
59082
59111
|
// Replace the last parameter with a rest parameter.
|
|
59083
59112
|
parameters.pop();
|
|
@@ -61674,7 +61703,7 @@ var ts;
|
|
|
61674
61703
|
// If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper
|
|
61675
61704
|
// that substitutes the index type for P. For example, for an index access { [P in K]: Box<T[P]> }[X], we
|
|
61676
61705
|
// construct the type Box<T[X]>.
|
|
61677
|
-
if (isGenericMappedType(objectType)) {
|
|
61706
|
+
if (isGenericMappedType(objectType) && !objectType.declaration.nameType) {
|
|
61678
61707
|
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
|
|
61679
61708
|
}
|
|
61680
61709
|
return type[cache] = type;
|
|
@@ -63747,7 +63776,7 @@ var ts;
|
|
|
63747
63776
|
var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
|
|
63748
63777
|
: target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
|
|
63749
63778
|
: getReturnTypeOfSignature(target);
|
|
63750
|
-
if (targetReturnType === voidType) {
|
|
63779
|
+
if (targetReturnType === voidType || targetReturnType === anyType) {
|
|
63751
63780
|
return result;
|
|
63752
63781
|
}
|
|
63753
63782
|
var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
|
|
@@ -72036,7 +72065,7 @@ var ts;
|
|
|
72036
72065
|
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
72037
72066
|
return mapType(type, function (t) {
|
|
72038
72067
|
var _a;
|
|
72039
|
-
if (isGenericMappedType(t)) {
|
|
72068
|
+
if (isGenericMappedType(t) && !t.declaration.nameType) {
|
|
72040
72069
|
var constraint = getConstraintTypeFromMappedType(t);
|
|
72041
72070
|
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
72042
72071
|
var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
|
|
@@ -76964,7 +76993,11 @@ var ts;
|
|
|
76964
76993
|
if (signatureHasRestParameter(signature)) {
|
|
76965
76994
|
// parameter might be a transient symbol generated by use of `arguments` in the function body.
|
|
76966
76995
|
var parameter = ts.last(signature.parameters);
|
|
76967
|
-
if (
|
|
76996
|
+
if (parameter.valueDeclaration
|
|
76997
|
+
? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)
|
|
76998
|
+
// a declarationless parameter may still have a `.type` already set by its construction logic
|
|
76999
|
+
// (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type
|
|
77000
|
+
: !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) {
|
|
76968
77001
|
var contextualParameterType = getRestTypeAtPosition(context, len);
|
|
76969
77002
|
assignParameterType(parameter, contextualParameterType);
|
|
76970
77003
|
}
|
|
@@ -76983,8 +77016,8 @@ var ts;
|
|
|
76983
77016
|
var links = getSymbolLinks(parameter);
|
|
76984
77017
|
if (!links.type) {
|
|
76985
77018
|
var declaration = parameter.valueDeclaration;
|
|
76986
|
-
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
|
|
76987
|
-
if (declaration.name.kind !== 79 /* Identifier */) {
|
|
77019
|
+
links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter));
|
|
77020
|
+
if (declaration && declaration.name.kind !== 79 /* Identifier */) {
|
|
76988
77021
|
// if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
|
|
76989
77022
|
if (links.type === unknownType) {
|
|
76990
77023
|
links.type = getTypeFromBindingPattern(declaration.name);
|
|
@@ -80797,20 +80830,31 @@ var ts;
|
|
|
80797
80830
|
* marked as referenced to prevent import elision.
|
|
80798
80831
|
*/
|
|
80799
80832
|
function markTypeNodeAsReferenced(node) {
|
|
80800
|
-
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
|
|
80833
|
+
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node), /*forDecoratorMetadata*/ false);
|
|
80801
80834
|
}
|
|
80802
|
-
function markEntityNameOrEntityExpressionAsReference(typeName) {
|
|
80835
|
+
function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
|
|
80803
80836
|
if (!typeName)
|
|
80804
80837
|
return;
|
|
80805
80838
|
var rootName = ts.getFirstIdentifier(typeName);
|
|
80806
80839
|
var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
|
|
80807
80840
|
var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true);
|
|
80808
|
-
if (rootSymbol
|
|
80809
|
-
|
|
80810
|
-
|
|
80811
|
-
|
|
80812
|
-
|
|
80813
|
-
|
|
80841
|
+
if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) {
|
|
80842
|
+
if (symbolIsValue(rootSymbol)
|
|
80843
|
+
&& !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
|
|
80844
|
+
&& !getTypeOnlyAliasDeclaration(rootSymbol)) {
|
|
80845
|
+
markAliasSymbolAsReferenced(rootSymbol);
|
|
80846
|
+
}
|
|
80847
|
+
else if (forDecoratorMetadata
|
|
80848
|
+
&& compilerOptions.isolatedModules
|
|
80849
|
+
&& ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015
|
|
80850
|
+
&& !symbolIsValue(rootSymbol)
|
|
80851
|
+
&& !ts.some(rootSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration)) {
|
|
80852
|
+
var diag = error(typeName, ts.Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled);
|
|
80853
|
+
var aliasDeclaration = ts.find(rootSymbol.declarations || ts.emptyArray, isAliasSymbolDeclaration);
|
|
80854
|
+
if (aliasDeclaration) {
|
|
80855
|
+
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(aliasDeclaration, ts.Diagnostics._0_was_imported_here, ts.idText(rootName)));
|
|
80856
|
+
}
|
|
80857
|
+
}
|
|
80814
80858
|
}
|
|
80815
80859
|
}
|
|
80816
80860
|
/**
|
|
@@ -80823,7 +80867,7 @@ var ts;
|
|
|
80823
80867
|
function markDecoratorMedataDataTypeNodeAsReferenced(node) {
|
|
80824
80868
|
var entityName = getEntityNameForDecoratorMetadata(node);
|
|
80825
80869
|
if (entityName && ts.isEntityName(entityName)) {
|
|
80826
|
-
markEntityNameOrEntityExpressionAsReference(entityName);
|
|
80870
|
+
markEntityNameOrEntityExpressionAsReference(entityName, /*forDecoratorMetadata*/ true);
|
|
80827
80871
|
}
|
|
80828
80872
|
}
|
|
80829
80873
|
function getEntityNameForDecoratorMetadata(node) {
|
|
@@ -84475,7 +84519,7 @@ var ts;
|
|
|
84475
84519
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
84476
84520
|
return;
|
|
84477
84521
|
}
|
|
84478
|
-
if (!checkGrammarDecoratorsAndModifiers(node) && ts.
|
|
84522
|
+
if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) {
|
|
84479
84523
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
84480
84524
|
}
|
|
84481
84525
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
@@ -87652,10 +87696,9 @@ var ts;
|
|
|
87652
87696
|
}
|
|
87653
87697
|
var parent = ts.walkUpParenthesizedTypes(node.parent);
|
|
87654
87698
|
if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
|
|
87655
|
-
|
|
87656
|
-
if (
|
|
87657
|
-
|
|
87658
|
-
parent = parent.parent.parent;
|
|
87699
|
+
var host_2 = ts.getJSDocHost(parent);
|
|
87700
|
+
if (host_2) {
|
|
87701
|
+
parent = ts.getSingleVariableOfVariableStatement(host_2) || host_2;
|
|
87659
87702
|
}
|
|
87660
87703
|
}
|
|
87661
87704
|
switch (parent.kind) {
|
|
@@ -130890,14 +130933,15 @@ var ts;
|
|
|
130890
130933
|
SortText["SuggestedClassMembers"] = "14";
|
|
130891
130934
|
SortText["GlobalsOrKeywords"] = "15";
|
|
130892
130935
|
SortText["AutoImportSuggestions"] = "16";
|
|
130893
|
-
SortText["
|
|
130894
|
-
SortText["
|
|
130895
|
-
SortText["
|
|
130896
|
-
SortText["
|
|
130897
|
-
SortText["
|
|
130898
|
-
SortText["
|
|
130899
|
-
SortText["
|
|
130900
|
-
SortText["
|
|
130936
|
+
SortText["ClassMemberSnippets"] = "17";
|
|
130937
|
+
SortText["JavascriptIdentifiers"] = "18";
|
|
130938
|
+
SortText["DeprecatedLocalDeclarationPriority"] = "19";
|
|
130939
|
+
SortText["DeprecatedLocationPriority"] = "20";
|
|
130940
|
+
SortText["DeprecatedOptionalMember"] = "21";
|
|
130941
|
+
SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "22";
|
|
130942
|
+
SortText["DeprecatedSuggestedClassMembers"] = "23";
|
|
130943
|
+
SortText["DeprecatedGlobalsOrKeywords"] = "24";
|
|
130944
|
+
SortText["DeprecatedAutoImportSuggestions"] = "25";
|
|
130901
130945
|
})(SortText = Completions.SortText || (Completions.SortText = {}));
|
|
130902
130946
|
var SortTextId;
|
|
130903
130947
|
(function (SortTextId) {
|
|
@@ -130909,10 +130953,10 @@ var ts;
|
|
|
130909
130953
|
SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
|
|
130910
130954
|
SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
|
|
130911
130955
|
// Don't use these directly.
|
|
130912
|
-
SortTextId[SortTextId["_JavaScriptIdentifiers"] =
|
|
130913
|
-
SortTextId[SortTextId["_DeprecatedStart"] =
|
|
130956
|
+
SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
|
|
130957
|
+
SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
|
|
130914
130958
|
SortTextId[SortTextId["_First"] = 10] = "_First";
|
|
130915
|
-
SortTextId[SortTextId["DeprecatedOffset"] =
|
|
130959
|
+
SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
|
|
130916
130960
|
})(SortTextId || (SortTextId = {}));
|
|
130917
130961
|
/**
|
|
130918
130962
|
* Special values for `CompletionInfo['source']` used to disambiguate
|
|
@@ -131393,6 +131437,7 @@ var ts;
|
|
|
131393
131437
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
131394
131438
|
var importAdder = void 0;
|
|
131395
131439
|
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
|
|
131440
|
+
sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
131396
131441
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
131397
131442
|
hasAction = true;
|
|
131398
131443
|
source = CompletionSource.ClassMemberSnippet;
|
|
@@ -131756,7 +131801,7 @@ var ts;
|
|
|
131756
131801
|
}
|
|
131757
131802
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
131758
131803
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
131759
|
-
var sortText = (isDeprecated(symbol, typeChecker) ?
|
|
131804
|
+
var sortText = (isDeprecated(symbol, typeChecker) ? 9 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
131760
131805
|
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
131761
131806
|
if (!entry) {
|
|
131762
131807
|
continue;
|
|
@@ -141668,6 +141713,41 @@ var ts;
|
|
|
141668
141713
|
if (ts.scanner.getToken() === 1 /* EndOfFileToken */) {
|
|
141669
141714
|
break;
|
|
141670
141715
|
}
|
|
141716
|
+
if (ts.scanner.getToken() === 15 /* TemplateHead */) {
|
|
141717
|
+
var stack = [ts.scanner.getToken()];
|
|
141718
|
+
var token = ts.scanner.scan();
|
|
141719
|
+
loop: while (ts.length(stack)) {
|
|
141720
|
+
switch (token) {
|
|
141721
|
+
case 1 /* EndOfFileToken */:
|
|
141722
|
+
break loop;
|
|
141723
|
+
case 100 /* ImportKeyword */:
|
|
141724
|
+
tryConsumeImport();
|
|
141725
|
+
break;
|
|
141726
|
+
case 15 /* TemplateHead */:
|
|
141727
|
+
stack.push(token);
|
|
141728
|
+
break;
|
|
141729
|
+
case 18 /* OpenBraceToken */:
|
|
141730
|
+
if (ts.length(stack)) {
|
|
141731
|
+
stack.push(token);
|
|
141732
|
+
}
|
|
141733
|
+
break;
|
|
141734
|
+
case 19 /* CloseBraceToken */:
|
|
141735
|
+
if (ts.length(stack)) {
|
|
141736
|
+
if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) {
|
|
141737
|
+
if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) {
|
|
141738
|
+
stack.pop();
|
|
141739
|
+
}
|
|
141740
|
+
}
|
|
141741
|
+
else {
|
|
141742
|
+
stack.pop();
|
|
141743
|
+
}
|
|
141744
|
+
}
|
|
141745
|
+
break;
|
|
141746
|
+
}
|
|
141747
|
+
token = ts.scanner.scan();
|
|
141748
|
+
}
|
|
141749
|
+
nextToken();
|
|
141750
|
+
}
|
|
141671
141751
|
// check if at least one of alternative have moved scanner forward
|
|
141672
141752
|
if (tryConsumeDeclare() ||
|
|
141673
141753
|
tryConsumeImport() ||
|
|
@@ -142961,7 +143041,7 @@ var ts;
|
|
|
142961
143041
|
if (!typeDisplayString) {
|
|
142962
143042
|
continue;
|
|
142963
143043
|
}
|
|
142964
|
-
addTypeHints(typeDisplayString, param.name.end);
|
|
143044
|
+
addTypeHints(typeDisplayString, param.questionToken ? param.questionToken.end : param.name.end);
|
|
142965
143045
|
}
|
|
142966
143046
|
}
|
|
142967
143047
|
function getParameterDeclarationTypeDisplayString(symbol) {
|
|
@@ -154140,6 +154220,74 @@ var ts;
|
|
|
154140
154220
|
})(ts || (ts = {}));
|
|
154141
154221
|
/* @internal */
|
|
154142
154222
|
var ts;
|
|
154223
|
+
(function (ts) {
|
|
154224
|
+
var codefix;
|
|
154225
|
+
(function (codefix) {
|
|
154226
|
+
var fixId = "fixUnreferenceableDecoratorMetadata";
|
|
154227
|
+
var errorCodes = [ts.Diagnostics.A_type_referenced_in_a_decorated_signature_must_be_imported_with_import_type_or_a_namespace_import_when_isolatedModules_and_emitDecoratorMetadata_are_enabled.code];
|
|
154228
|
+
codefix.registerCodeFix({
|
|
154229
|
+
errorCodes: errorCodes,
|
|
154230
|
+
getCodeActions: function (context) {
|
|
154231
|
+
var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
154232
|
+
if (!importDeclaration)
|
|
154233
|
+
return;
|
|
154234
|
+
var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 269 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); });
|
|
154235
|
+
var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); });
|
|
154236
|
+
var actions;
|
|
154237
|
+
if (namespaceChanges.length) {
|
|
154238
|
+
actions = ts.append(actions, codefix.createCodeFixActionWithoutFixAll(fixId, namespaceChanges, ts.Diagnostics.Convert_named_imports_to_namespace_import));
|
|
154239
|
+
}
|
|
154240
|
+
if (typeOnlyChanges.length) {
|
|
154241
|
+
actions = ts.append(actions, codefix.createCodeFixActionWithoutFixAll(fixId, typeOnlyChanges, ts.Diagnostics.Convert_to_type_only_import));
|
|
154242
|
+
}
|
|
154243
|
+
return actions;
|
|
154244
|
+
},
|
|
154245
|
+
fixIds: [fixId],
|
|
154246
|
+
});
|
|
154247
|
+
function getImportDeclaration(sourceFile, program, start) {
|
|
154248
|
+
var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier);
|
|
154249
|
+
if (!identifier || identifier.parent.kind !== 177 /* TypeReference */)
|
|
154250
|
+
return;
|
|
154251
|
+
var checker = program.getTypeChecker();
|
|
154252
|
+
var symbol = checker.getSymbolAtLocation(identifier);
|
|
154253
|
+
return ts.find((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, ts.or(ts.isImportClause, ts.isImportSpecifier, ts.isImportEqualsDeclaration));
|
|
154254
|
+
}
|
|
154255
|
+
// Converts the import declaration of the offending import to a type-only import,
|
|
154256
|
+
// only if it can be done without affecting other imported names. If the conversion
|
|
154257
|
+
// cannot be done cleanly, we could offer to *extract* the offending import to a
|
|
154258
|
+
// new type-only import declaration, but honestly I doubt anyone will ever use this
|
|
154259
|
+
// codefix at all, so it's probably not worth the lines of code.
|
|
154260
|
+
function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) {
|
|
154261
|
+
if (importDeclaration.kind === 264 /* ImportEqualsDeclaration */) {
|
|
154262
|
+
changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, importDeclaration.name);
|
|
154263
|
+
return;
|
|
154264
|
+
}
|
|
154265
|
+
var importClause = importDeclaration.kind === 266 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent;
|
|
154266
|
+
if (importClause.name && importClause.namedBindings) {
|
|
154267
|
+
// Cannot convert an import with a default import and named bindings to type-only
|
|
154268
|
+
// (it's a grammar error).
|
|
154269
|
+
return;
|
|
154270
|
+
}
|
|
154271
|
+
var checker = program.getTypeChecker();
|
|
154272
|
+
var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) {
|
|
154273
|
+
if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */)
|
|
154274
|
+
return true;
|
|
154275
|
+
});
|
|
154276
|
+
if (importsValue) {
|
|
154277
|
+
// Assume that if someone wrote a non-type-only import that includes some values,
|
|
154278
|
+
// they intend to use those values in value positions, even if they haven't yet.
|
|
154279
|
+
// Don't convert it to type-only.
|
|
154280
|
+
return;
|
|
154281
|
+
}
|
|
154282
|
+
changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, importClause);
|
|
154283
|
+
}
|
|
154284
|
+
function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) {
|
|
154285
|
+
ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent);
|
|
154286
|
+
}
|
|
154287
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
154288
|
+
})(ts || (ts = {}));
|
|
154289
|
+
/* @internal */
|
|
154290
|
+
var ts;
|
|
154143
154291
|
(function (ts) {
|
|
154144
154292
|
var codefix;
|
|
154145
154293
|
(function (codefix) {
|
|
@@ -156707,6 +156855,7 @@ var ts;
|
|
|
156707
156855
|
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
|
|
156708
156856
|
}
|
|
156709
156857
|
function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
|
|
156858
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156710
156859
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
|
|
156711
156860
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156712
156861
|
}
|
|
@@ -156736,6 +156885,7 @@ var ts;
|
|
|
156736
156885
|
return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
|
|
156737
156886
|
}
|
|
156738
156887
|
function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
|
|
156888
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156739
156889
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
|
|
156740
156890
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156741
156891
|
}
|
|
@@ -157659,20 +157809,22 @@ var ts;
|
|
|
157659
157809
|
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
157660
157810
|
return { convertTo: 0 /* Named */, import: importClause.namedBindings };
|
|
157661
157811
|
}
|
|
157662
|
-
var
|
|
157663
|
-
var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
|
|
157664
|
-
&& isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
|
|
157812
|
+
var shouldUseDefault = getShouldUseDefault(context.program, importClause);
|
|
157665
157813
|
return shouldUseDefault
|
|
157666
157814
|
? { convertTo: 1 /* Default */, import: importClause.namedBindings }
|
|
157667
157815
|
: { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
|
|
157668
157816
|
}
|
|
157817
|
+
function getShouldUseDefault(program, importClause) {
|
|
157818
|
+
return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())
|
|
157819
|
+
&& isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
|
|
157820
|
+
}
|
|
157669
157821
|
function doChange(sourceFile, program, changes, info) {
|
|
157670
157822
|
var checker = program.getTypeChecker();
|
|
157671
157823
|
if (info.convertTo === 0 /* Named */) {
|
|
157672
157824
|
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
157673
157825
|
}
|
|
157674
157826
|
else {
|
|
157675
|
-
doChangeNamedToNamespaceOrDefault(sourceFile,
|
|
157827
|
+
doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */);
|
|
157676
157828
|
}
|
|
157677
157829
|
}
|
|
157678
157830
|
function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
|
|
@@ -157722,7 +157874,9 @@ var ts;
|
|
|
157722
157874
|
function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
|
|
157723
157875
|
return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
|
|
157724
157876
|
}
|
|
157725
|
-
function doChangeNamedToNamespaceOrDefault(sourceFile,
|
|
157877
|
+
function doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, toConvert, shouldUseDefault) {
|
|
157878
|
+
if (shouldUseDefault === void 0) { shouldUseDefault = getShouldUseDefault(program, toConvert.parent); }
|
|
157879
|
+
var checker = program.getTypeChecker();
|
|
157726
157880
|
var importDecl = toConvert.parent.parent;
|
|
157727
157881
|
var moduleSpecifier = importDecl.moduleSpecifier;
|
|
157728
157882
|
var toConvertSymbols = new ts.Set();
|
|
@@ -157783,6 +157937,7 @@ var ts;
|
|
|
157783
157937
|
changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
|
|
157784
157938
|
}
|
|
157785
157939
|
}
|
|
157940
|
+
refactor.doChangeNamedToNamespaceOrDefault = doChangeNamedToNamespaceOrDefault;
|
|
157786
157941
|
function isExportEqualsModule(moduleSpecifier, checker) {
|
|
157787
157942
|
var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
|
|
157788
157943
|
if (!externalModule)
|
|
@@ -159183,7 +159338,9 @@ var ts;
|
|
|
159183
159338
|
var checker = context.program.getTypeChecker();
|
|
159184
159339
|
// Make a unique name for the extracted variable
|
|
159185
159340
|
var file = scope.getSourceFile();
|
|
159186
|
-
var localNameText = ts.
|
|
159341
|
+
var localNameText = ts.isPropertyAccessExpression(node) && !ts.isClassLike(scope) && !checker.resolveName(node.name.text, node, 111551 /* Value */, /*excludeGlobals*/ false) && !ts.isPrivateIdentifier(node.name) && !ts.isKeyword(node.name.originalKeywordKind)
|
|
159342
|
+
? node.name.text
|
|
159343
|
+
: ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file);
|
|
159187
159344
|
var isJS = ts.isInJSFile(scope);
|
|
159188
159345
|
var variableType = isJS || !checker.isContextSensitive(node)
|
|
159189
159346
|
? undefined
|
|
@@ -162950,10 +163107,12 @@ var ts;
|
|
|
162950
163107
|
this.fileNameToEntry = new ts.Map();
|
|
162951
163108
|
// Initialize the list with the root file names
|
|
162952
163109
|
var rootFileNames = host.getScriptFileNames();
|
|
163110
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
|
|
162953
163111
|
for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
|
|
162954
163112
|
var fileName = rootFileNames_1[_i];
|
|
162955
163113
|
this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
|
|
162956
163114
|
}
|
|
163115
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
162957
163116
|
}
|
|
162958
163117
|
HostCache.prototype.createEntry = function (fileName, path) {
|
|
162959
163118
|
var entry;
|