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
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220318";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -8034,7 +8034,7 @@ var ts;
|
|
|
8034
8034
|
Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
|
|
8035
8035
|
_0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
|
|
8036
8036
|
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."),
|
|
8037
|
-
|
|
8037
|
+
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."),
|
|
8038
8038
|
Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
|
|
8039
8039
|
Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
|
|
8040
8040
|
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."),
|
|
@@ -8250,6 +8250,7 @@ var ts;
|
|
|
8250
8250
|
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."),
|
|
8251
8251
|
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}'."),
|
|
8252
8252
|
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'."),
|
|
8253
|
+
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."),
|
|
8253
8254
|
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."),
|
|
8254
8255
|
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."),
|
|
8255
8256
|
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."),
|
|
@@ -31426,20 +31427,23 @@ var ts;
|
|
|
31426
31427
|
return inContext(32768 /* AwaitContext */);
|
|
31427
31428
|
}
|
|
31428
31429
|
function parseErrorAtCurrentToken(message, arg0) {
|
|
31429
|
-
parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
|
|
31430
|
+
return parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
|
|
31430
31431
|
}
|
|
31431
31432
|
function parseErrorAtPosition(start, length, message, arg0) {
|
|
31432
31433
|
// Don't report another error if it would just be at the same position as the last error.
|
|
31433
31434
|
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
31435
|
+
var result;
|
|
31434
31436
|
if (!lastError || start !== lastError.start) {
|
|
31435
|
-
|
|
31437
|
+
result = ts.createDetachedDiagnostic(fileName, start, length, message, arg0);
|
|
31438
|
+
parseDiagnostics.push(result);
|
|
31436
31439
|
}
|
|
31437
31440
|
// Mark that we've encountered an error. We'll set an appropriate bit on the next
|
|
31438
31441
|
// node we finish so that it can't be reused incrementally.
|
|
31439
31442
|
parseErrorBeforeNextFinishedNode = true;
|
|
31443
|
+
return result;
|
|
31440
31444
|
}
|
|
31441
31445
|
function parseErrorAt(start, end, message, arg0) {
|
|
31442
|
-
parseErrorAtPosition(start, end - start, message, arg0);
|
|
31446
|
+
return parseErrorAtPosition(start, end - start, message, arg0);
|
|
31443
31447
|
}
|
|
31444
31448
|
function parseErrorAtRange(range, message, arg0) {
|
|
31445
31449
|
parseErrorAt(range.pos, range.end, message, arg0);
|
|
@@ -31712,6 +31716,19 @@ var ts;
|
|
|
31712
31716
|
parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
|
|
31713
31717
|
return false;
|
|
31714
31718
|
}
|
|
31719
|
+
function parseExpectedMatchingBrackets(openKind, closeKind, openParsed, openPosition) {
|
|
31720
|
+
if (token() === closeKind) {
|
|
31721
|
+
nextToken();
|
|
31722
|
+
return;
|
|
31723
|
+
}
|
|
31724
|
+
var lastError = parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(closeKind));
|
|
31725
|
+
if (!openParsed) {
|
|
31726
|
+
return;
|
|
31727
|
+
}
|
|
31728
|
+
if (lastError) {
|
|
31729
|
+
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)));
|
|
31730
|
+
}
|
|
31731
|
+
}
|
|
31715
31732
|
function parseOptional(t) {
|
|
31716
31733
|
if (token() === t) {
|
|
31717
31734
|
nextToken();
|
|
@@ -33360,7 +33377,7 @@ var ts;
|
|
|
33360
33377
|
if (!parseExpected(19 /* CloseBraceToken */)) {
|
|
33361
33378
|
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
33362
33379
|
if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
|
|
33363
|
-
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.
|
|
33380
|
+
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}"));
|
|
33364
33381
|
}
|
|
33365
33382
|
}
|
|
33366
33383
|
return finishNode(factory.createImportTypeAssertionContainer(clause, multiLine), pos);
|
|
@@ -35170,10 +35187,11 @@ var ts;
|
|
|
35170
35187
|
}
|
|
35171
35188
|
function parseArrayLiteralExpression() {
|
|
35172
35189
|
var pos = getNodePos();
|
|
35173
|
-
|
|
35190
|
+
var openBracketPosition = scanner.getTokenPos();
|
|
35191
|
+
var openBracketParsed = parseExpected(22 /* OpenBracketToken */);
|
|
35174
35192
|
var multiLine = scanner.hasPrecedingLineBreak();
|
|
35175
35193
|
var elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement);
|
|
35176
|
-
|
|
35194
|
+
parseExpectedMatchingBrackets(22 /* OpenBracketToken */, 23 /* CloseBracketToken */, openBracketParsed, openBracketPosition);
|
|
35177
35195
|
return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
|
|
35178
35196
|
}
|
|
35179
35197
|
function parseObjectLiteralElement() {
|
|
@@ -35230,15 +35248,10 @@ var ts;
|
|
|
35230
35248
|
function parseObjectLiteralExpression() {
|
|
35231
35249
|
var pos = getNodePos();
|
|
35232
35250
|
var openBracePosition = scanner.getTokenPos();
|
|
35233
|
-
parseExpected(18 /* OpenBraceToken */);
|
|
35251
|
+
var openBraceParsed = parseExpected(18 /* OpenBraceToken */);
|
|
35234
35252
|
var multiLine = scanner.hasPrecedingLineBreak();
|
|
35235
35253
|
var properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true);
|
|
35236
|
-
|
|
35237
|
-
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
35238
|
-
if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
|
|
35239
|
-
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
|
|
35240
|
-
}
|
|
35241
|
-
}
|
|
35254
|
+
parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition);
|
|
35242
35255
|
return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
|
|
35243
35256
|
}
|
|
35244
35257
|
function parseFunctionExpression() {
|
|
@@ -35294,15 +35307,11 @@ var ts;
|
|
|
35294
35307
|
var pos = getNodePos();
|
|
35295
35308
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35296
35309
|
var openBracePosition = scanner.getTokenPos();
|
|
35297
|
-
|
|
35310
|
+
var openBraceParsed = parseExpected(18 /* OpenBraceToken */, diagnosticMessage);
|
|
35311
|
+
if (openBraceParsed || ignoreMissingOpenBrace) {
|
|
35298
35312
|
var multiLine = scanner.hasPrecedingLineBreak();
|
|
35299
35313
|
var statements = parseList(1 /* BlockStatements */, parseStatement);
|
|
35300
|
-
|
|
35301
|
-
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
35302
|
-
if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
|
|
35303
|
-
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
|
|
35304
|
-
}
|
|
35305
|
-
}
|
|
35314
|
+
parseExpectedMatchingBrackets(18 /* OpenBraceToken */, 19 /* CloseBraceToken */, openBraceParsed, openBracePosition);
|
|
35306
35315
|
var result = withJSDoc(finishNode(factory.createBlock(statements, multiLine), pos), hasJSDoc);
|
|
35307
35316
|
if (token() === 63 /* EqualsToken */) {
|
|
35308
35317
|
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);
|
|
@@ -35347,9 +35356,10 @@ var ts;
|
|
|
35347
35356
|
var pos = getNodePos();
|
|
35348
35357
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35349
35358
|
parseExpected(99 /* IfKeyword */);
|
|
35350
|
-
|
|
35359
|
+
var openParenPosition = scanner.getTokenPos();
|
|
35360
|
+
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35351
35361
|
var expression = allowInAnd(parseExpression);
|
|
35352
|
-
|
|
35362
|
+
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35353
35363
|
var thenStatement = parseStatement();
|
|
35354
35364
|
var elseStatement = parseOptional(91 /* ElseKeyword */) ? parseStatement() : undefined;
|
|
35355
35365
|
return withJSDoc(finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos), hasJSDoc);
|
|
@@ -35360,9 +35370,10 @@ var ts;
|
|
|
35360
35370
|
parseExpected(90 /* DoKeyword */);
|
|
35361
35371
|
var statement = parseStatement();
|
|
35362
35372
|
parseExpected(115 /* WhileKeyword */);
|
|
35363
|
-
|
|
35373
|
+
var openParenPosition = scanner.getTokenPos();
|
|
35374
|
+
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35364
35375
|
var expression = allowInAnd(parseExpression);
|
|
35365
|
-
|
|
35376
|
+
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35366
35377
|
// From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html
|
|
35367
35378
|
// 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in
|
|
35368
35379
|
// spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby
|
|
@@ -35374,9 +35385,10 @@ var ts;
|
|
|
35374
35385
|
var pos = getNodePos();
|
|
35375
35386
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35376
35387
|
parseExpected(115 /* WhileKeyword */);
|
|
35377
|
-
|
|
35388
|
+
var openParenPosition = scanner.getTokenPos();
|
|
35389
|
+
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35378
35390
|
var expression = allowInAnd(parseExpression);
|
|
35379
|
-
|
|
35391
|
+
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35380
35392
|
var statement = parseStatement();
|
|
35381
35393
|
return withJSDoc(finishNode(factory.createWhileStatement(expression, statement), pos), hasJSDoc);
|
|
35382
35394
|
}
|
|
@@ -35443,9 +35455,10 @@ var ts;
|
|
|
35443
35455
|
var pos = getNodePos();
|
|
35444
35456
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35445
35457
|
parseExpected(116 /* WithKeyword */);
|
|
35446
|
-
|
|
35458
|
+
var openParenPosition = scanner.getTokenPos();
|
|
35459
|
+
var openParenParsed = parseExpected(20 /* OpenParenToken */);
|
|
35447
35460
|
var expression = allowInAnd(parseExpression);
|
|
35448
|
-
|
|
35461
|
+
parseExpectedMatchingBrackets(20 /* OpenParenToken */, 21 /* CloseParenToken */, openParenParsed, openParenPosition);
|
|
35449
35462
|
var statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement);
|
|
35450
35463
|
return withJSDoc(finishNode(factory.createWithStatement(expression, statement), pos), hasJSDoc);
|
|
35451
35464
|
}
|
|
@@ -36579,7 +36592,7 @@ var ts;
|
|
|
36579
36592
|
if (!parseExpected(19 /* CloseBraceToken */)) {
|
|
36580
36593
|
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
36581
36594
|
if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
|
|
36582
|
-
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.
|
|
36595
|
+
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_1_to_match_the_0_token_here, "{", "}"));
|
|
36583
36596
|
}
|
|
36584
36597
|
}
|
|
36585
36598
|
return finishNode(factory.createAssertClause(elements, multiLine), pos);
|
|
@@ -37555,8 +37568,7 @@ var ts;
|
|
|
37555
37568
|
hasChildren = true;
|
|
37556
37569
|
if (child.kind === 342 /* JSDocTypeTag */) {
|
|
37557
37570
|
if (childTypeTag) {
|
|
37558
|
-
parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
|
|
37559
|
-
var lastError = ts.lastOrUndefined(parseDiagnostics);
|
|
37571
|
+
var lastError = parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
|
|
37560
37572
|
if (lastError) {
|
|
37561
37573
|
ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here));
|
|
37562
37574
|
}
|
|
@@ -40884,7 +40896,10 @@ var ts;
|
|
|
40884
40896
|
* file to. e.g. outDir
|
|
40885
40897
|
*/
|
|
40886
40898
|
function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
|
|
40887
|
-
|
|
40899
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName });
|
|
40900
|
+
var result = parseJsonConfigFileContentWorker(/*json*/ undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
|
|
40901
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
40902
|
+
return result;
|
|
40888
40903
|
}
|
|
40889
40904
|
ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
|
|
40890
40905
|
/*@internal*/
|
|
@@ -58294,8 +58309,10 @@ var ts;
|
|
|
58294
58309
|
return type;
|
|
58295
58310
|
}
|
|
58296
58311
|
function isMappedTypeGenericIndexedAccess(type) {
|
|
58297
|
-
|
|
58298
|
-
|
|
58312
|
+
var objectType;
|
|
58313
|
+
return !!(type.flags & 8388608 /* IndexedAccess */ && ts.getObjectFlags(objectType = type.objectType) & 32 /* Mapped */ &&
|
|
58314
|
+
!isGenericMappedType(objectType) && isGenericIndexType(type.indexType) &&
|
|
58315
|
+
!objectType.declaration.questionToken && !objectType.declaration.nameType);
|
|
58299
58316
|
}
|
|
58300
58317
|
/**
|
|
58301
58318
|
* For a type parameter, return the base constraint of the type parameter. For the string, number,
|
|
@@ -58883,7 +58900,19 @@ var ts;
|
|
|
58883
58900
|
return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
|
|
58884
58901
|
});
|
|
58885
58902
|
var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args", 32768 /* RestParameter */);
|
|
58886
|
-
|
|
58903
|
+
if (lastParamVariadicType) {
|
|
58904
|
+
// Parameter has effective annotation, lock in type
|
|
58905
|
+
syntheticArgsSymbol.type = createArrayType(getTypeFromTypeNode(lastParamVariadicType.type));
|
|
58906
|
+
}
|
|
58907
|
+
else {
|
|
58908
|
+
// Parameter has no annotation
|
|
58909
|
+
// 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
|
|
58910
|
+
// cached by `getTypeOfSymbol` yet.
|
|
58911
|
+
syntheticArgsSymbol.checkFlags |= 65536 /* DeferredType */;
|
|
58912
|
+
syntheticArgsSymbol.deferralParent = neverType;
|
|
58913
|
+
syntheticArgsSymbol.deferralConstituents = [anyArrayType];
|
|
58914
|
+
syntheticArgsSymbol.deferralWriteConstituents = [anyArrayType];
|
|
58915
|
+
}
|
|
58887
58916
|
if (lastParamVariadicType) {
|
|
58888
58917
|
// Replace the last parameter with a rest parameter.
|
|
58889
58918
|
parameters.pop();
|
|
@@ -61480,7 +61509,7 @@ var ts;
|
|
|
61480
61509
|
// If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper
|
|
61481
61510
|
// that substitutes the index type for P. For example, for an index access { [P in K]: Box<T[P]> }[X], we
|
|
61482
61511
|
// construct the type Box<T[X]>.
|
|
61483
|
-
if (isGenericMappedType(objectType)) {
|
|
61512
|
+
if (isGenericMappedType(objectType) && !objectType.declaration.nameType) {
|
|
61484
61513
|
return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
|
|
61485
61514
|
}
|
|
61486
61515
|
return type[cache] = type;
|
|
@@ -63553,7 +63582,7 @@ var ts;
|
|
|
63553
63582
|
var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
|
|
63554
63583
|
: target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
|
|
63555
63584
|
: getReturnTypeOfSignature(target);
|
|
63556
|
-
if (targetReturnType === voidType) {
|
|
63585
|
+
if (targetReturnType === voidType || targetReturnType === anyType) {
|
|
63557
63586
|
return result;
|
|
63558
63587
|
}
|
|
63559
63588
|
var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
|
|
@@ -71842,7 +71871,7 @@ var ts;
|
|
|
71842
71871
|
function getTypeOfPropertyOfContextualType(type, name, nameType) {
|
|
71843
71872
|
return mapType(type, function (t) {
|
|
71844
71873
|
var _a;
|
|
71845
|
-
if (isGenericMappedType(t)) {
|
|
71874
|
+
if (isGenericMappedType(t) && !t.declaration.nameType) {
|
|
71846
71875
|
var constraint = getConstraintTypeFromMappedType(t);
|
|
71847
71876
|
var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
71848
71877
|
var propertyNameType = nameType || getStringLiteralType(ts.unescapeLeadingUnderscores(name));
|
|
@@ -76770,7 +76799,11 @@ var ts;
|
|
|
76770
76799
|
if (signatureHasRestParameter(signature)) {
|
|
76771
76800
|
// parameter might be a transient symbol generated by use of `arguments` in the function body.
|
|
76772
76801
|
var parameter = ts.last(signature.parameters);
|
|
76773
|
-
if (
|
|
76802
|
+
if (parameter.valueDeclaration
|
|
76803
|
+
? !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)
|
|
76804
|
+
// a declarationless parameter may still have a `.type` already set by its construction logic
|
|
76805
|
+
// (which may pull a type from a jsdoc) - only allow fixing on `DeferredType` parameters with a fallback type
|
|
76806
|
+
: !!(ts.getCheckFlags(parameter) & 65536 /* DeferredType */)) {
|
|
76774
76807
|
var contextualParameterType = getRestTypeAtPosition(context, len);
|
|
76775
76808
|
assignParameterType(parameter, contextualParameterType);
|
|
76776
76809
|
}
|
|
@@ -76789,8 +76822,8 @@ var ts;
|
|
|
76789
76822
|
var links = getSymbolLinks(parameter);
|
|
76790
76823
|
if (!links.type) {
|
|
76791
76824
|
var declaration = parameter.valueDeclaration;
|
|
76792
|
-
links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true);
|
|
76793
|
-
if (declaration.name.kind !== 79 /* Identifier */) {
|
|
76825
|
+
links.type = type || (declaration ? getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true) : getTypeOfSymbol(parameter));
|
|
76826
|
+
if (declaration && declaration.name.kind !== 79 /* Identifier */) {
|
|
76794
76827
|
// if inference didn't come up with anything but unknown, fall back to the binding pattern if present.
|
|
76795
76828
|
if (links.type === unknownType) {
|
|
76796
76829
|
links.type = getTypeFromBindingPattern(declaration.name);
|
|
@@ -80603,20 +80636,31 @@ var ts;
|
|
|
80603
80636
|
* marked as referenced to prevent import elision.
|
|
80604
80637
|
*/
|
|
80605
80638
|
function markTypeNodeAsReferenced(node) {
|
|
80606
|
-
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
|
|
80639
|
+
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node), /*forDecoratorMetadata*/ false);
|
|
80607
80640
|
}
|
|
80608
|
-
function markEntityNameOrEntityExpressionAsReference(typeName) {
|
|
80641
|
+
function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
|
|
80609
80642
|
if (!typeName)
|
|
80610
80643
|
return;
|
|
80611
80644
|
var rootName = ts.getFirstIdentifier(typeName);
|
|
80612
80645
|
var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
|
|
80613
80646
|
var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true);
|
|
80614
|
-
if (rootSymbol
|
|
80615
|
-
|
|
80616
|
-
|
|
80617
|
-
|
|
80618
|
-
|
|
80619
|
-
|
|
80647
|
+
if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */) {
|
|
80648
|
+
if (symbolIsValue(rootSymbol)
|
|
80649
|
+
&& !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
|
|
80650
|
+
&& !getTypeOnlyAliasDeclaration(rootSymbol)) {
|
|
80651
|
+
markAliasSymbolAsReferenced(rootSymbol);
|
|
80652
|
+
}
|
|
80653
|
+
else if (forDecoratorMetadata
|
|
80654
|
+
&& compilerOptions.isolatedModules
|
|
80655
|
+
&& ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015
|
|
80656
|
+
&& !symbolIsValue(rootSymbol)
|
|
80657
|
+
&& !ts.some(rootSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration)) {
|
|
80658
|
+
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);
|
|
80659
|
+
var aliasDeclaration = ts.find(rootSymbol.declarations || ts.emptyArray, isAliasSymbolDeclaration);
|
|
80660
|
+
if (aliasDeclaration) {
|
|
80661
|
+
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(aliasDeclaration, ts.Diagnostics._0_was_imported_here, ts.idText(rootName)));
|
|
80662
|
+
}
|
|
80663
|
+
}
|
|
80620
80664
|
}
|
|
80621
80665
|
}
|
|
80622
80666
|
/**
|
|
@@ -80629,7 +80673,7 @@ var ts;
|
|
|
80629
80673
|
function markDecoratorMedataDataTypeNodeAsReferenced(node) {
|
|
80630
80674
|
var entityName = getEntityNameForDecoratorMetadata(node);
|
|
80631
80675
|
if (entityName && ts.isEntityName(entityName)) {
|
|
80632
|
-
markEntityNameOrEntityExpressionAsReference(entityName);
|
|
80676
|
+
markEntityNameOrEntityExpressionAsReference(entityName, /*forDecoratorMetadata*/ true);
|
|
80633
80677
|
}
|
|
80634
80678
|
}
|
|
80635
80679
|
function getEntityNameForDecoratorMetadata(node) {
|
|
@@ -84281,7 +84325,7 @@ var ts;
|
|
|
84281
84325
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
84282
84326
|
return;
|
|
84283
84327
|
}
|
|
84284
|
-
if (!checkGrammarDecoratorsAndModifiers(node) && ts.
|
|
84328
|
+
if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) {
|
|
84285
84329
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
84286
84330
|
}
|
|
84287
84331
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
@@ -87458,10 +87502,9 @@ var ts;
|
|
|
87458
87502
|
}
|
|
87459
87503
|
var parent = ts.walkUpParenthesizedTypes(node.parent);
|
|
87460
87504
|
if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
|
|
87461
|
-
|
|
87462
|
-
if (
|
|
87463
|
-
|
|
87464
|
-
parent = parent.parent.parent;
|
|
87505
|
+
var host_2 = ts.getJSDocHost(parent);
|
|
87506
|
+
if (host_2) {
|
|
87507
|
+
parent = ts.getSingleVariableOfVariableStatement(host_2) || host_2;
|
|
87465
87508
|
}
|
|
87466
87509
|
}
|
|
87467
87510
|
switch (parent.kind) {
|
|
@@ -130279,14 +130322,15 @@ var ts;
|
|
|
130279
130322
|
SortText["SuggestedClassMembers"] = "14";
|
|
130280
130323
|
SortText["GlobalsOrKeywords"] = "15";
|
|
130281
130324
|
SortText["AutoImportSuggestions"] = "16";
|
|
130282
|
-
SortText["
|
|
130283
|
-
SortText["
|
|
130284
|
-
SortText["
|
|
130285
|
-
SortText["
|
|
130286
|
-
SortText["
|
|
130287
|
-
SortText["
|
|
130288
|
-
SortText["
|
|
130289
|
-
SortText["
|
|
130325
|
+
SortText["ClassMemberSnippets"] = "17";
|
|
130326
|
+
SortText["JavascriptIdentifiers"] = "18";
|
|
130327
|
+
SortText["DeprecatedLocalDeclarationPriority"] = "19";
|
|
130328
|
+
SortText["DeprecatedLocationPriority"] = "20";
|
|
130329
|
+
SortText["DeprecatedOptionalMember"] = "21";
|
|
130330
|
+
SortText["DeprecatedMemberDeclaredBySpreadAssignment"] = "22";
|
|
130331
|
+
SortText["DeprecatedSuggestedClassMembers"] = "23";
|
|
130332
|
+
SortText["DeprecatedGlobalsOrKeywords"] = "24";
|
|
130333
|
+
SortText["DeprecatedAutoImportSuggestions"] = "25";
|
|
130290
130334
|
})(SortText = Completions.SortText || (Completions.SortText = {}));
|
|
130291
130335
|
var SortTextId;
|
|
130292
130336
|
(function (SortTextId) {
|
|
@@ -130298,10 +130342,10 @@ var ts;
|
|
|
130298
130342
|
SortTextId[SortTextId["GlobalsOrKeywords"] = 15] = "GlobalsOrKeywords";
|
|
130299
130343
|
SortTextId[SortTextId["AutoImportSuggestions"] = 16] = "AutoImportSuggestions";
|
|
130300
130344
|
// Don't use these directly.
|
|
130301
|
-
SortTextId[SortTextId["_JavaScriptIdentifiers"] =
|
|
130302
|
-
SortTextId[SortTextId["_DeprecatedStart"] =
|
|
130345
|
+
SortTextId[SortTextId["_JavaScriptIdentifiers"] = 18] = "_JavaScriptIdentifiers";
|
|
130346
|
+
SortTextId[SortTextId["_DeprecatedStart"] = 19] = "_DeprecatedStart";
|
|
130303
130347
|
SortTextId[SortTextId["_First"] = 10] = "_First";
|
|
130304
|
-
SortTextId[SortTextId["DeprecatedOffset"] =
|
|
130348
|
+
SortTextId[SortTextId["DeprecatedOffset"] = 9] = "DeprecatedOffset";
|
|
130305
130349
|
})(SortTextId || (SortTextId = {}));
|
|
130306
130350
|
/**
|
|
130307
130351
|
* Special values for `CompletionInfo['source']` used to disambiguate
|
|
@@ -130782,6 +130826,7 @@ var ts;
|
|
|
130782
130826
|
isClassLikeMemberCompletion(symbol, location)) {
|
|
130783
130827
|
var importAdder = void 0;
|
|
130784
130828
|
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
|
|
130829
|
+
sortText = SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
130785
130830
|
if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
|
|
130786
130831
|
hasAction = true;
|
|
130787
130832
|
source = CompletionSource.ClassMemberSnippet;
|
|
@@ -131145,7 +131190,7 @@ var ts;
|
|
|
131145
131190
|
}
|
|
131146
131191
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
131147
131192
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
131148
|
-
var sortText = (isDeprecated(symbol, typeChecker) ?
|
|
131193
|
+
var sortText = (isDeprecated(symbol, typeChecker) ? 9 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
131149
131194
|
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);
|
|
131150
131195
|
if (!entry) {
|
|
131151
131196
|
continue;
|
|
@@ -141057,6 +141102,41 @@ var ts;
|
|
|
141057
141102
|
if (ts.scanner.getToken() === 1 /* EndOfFileToken */) {
|
|
141058
141103
|
break;
|
|
141059
141104
|
}
|
|
141105
|
+
if (ts.scanner.getToken() === 15 /* TemplateHead */) {
|
|
141106
|
+
var stack = [ts.scanner.getToken()];
|
|
141107
|
+
var token = ts.scanner.scan();
|
|
141108
|
+
loop: while (ts.length(stack)) {
|
|
141109
|
+
switch (token) {
|
|
141110
|
+
case 1 /* EndOfFileToken */:
|
|
141111
|
+
break loop;
|
|
141112
|
+
case 100 /* ImportKeyword */:
|
|
141113
|
+
tryConsumeImport();
|
|
141114
|
+
break;
|
|
141115
|
+
case 15 /* TemplateHead */:
|
|
141116
|
+
stack.push(token);
|
|
141117
|
+
break;
|
|
141118
|
+
case 18 /* OpenBraceToken */:
|
|
141119
|
+
if (ts.length(stack)) {
|
|
141120
|
+
stack.push(token);
|
|
141121
|
+
}
|
|
141122
|
+
break;
|
|
141123
|
+
case 19 /* CloseBraceToken */:
|
|
141124
|
+
if (ts.length(stack)) {
|
|
141125
|
+
if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) {
|
|
141126
|
+
if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) {
|
|
141127
|
+
stack.pop();
|
|
141128
|
+
}
|
|
141129
|
+
}
|
|
141130
|
+
else {
|
|
141131
|
+
stack.pop();
|
|
141132
|
+
}
|
|
141133
|
+
}
|
|
141134
|
+
break;
|
|
141135
|
+
}
|
|
141136
|
+
token = ts.scanner.scan();
|
|
141137
|
+
}
|
|
141138
|
+
nextToken();
|
|
141139
|
+
}
|
|
141060
141140
|
// check if at least one of alternative have moved scanner forward
|
|
141061
141141
|
if (tryConsumeDeclare() ||
|
|
141062
141142
|
tryConsumeImport() ||
|
|
@@ -142350,7 +142430,7 @@ var ts;
|
|
|
142350
142430
|
if (!typeDisplayString) {
|
|
142351
142431
|
continue;
|
|
142352
142432
|
}
|
|
142353
|
-
addTypeHints(typeDisplayString, param.name.end);
|
|
142433
|
+
addTypeHints(typeDisplayString, param.questionToken ? param.questionToken.end : param.name.end);
|
|
142354
142434
|
}
|
|
142355
142435
|
}
|
|
142356
142436
|
function getParameterDeclarationTypeDisplayString(symbol) {
|
|
@@ -153529,6 +153609,74 @@ var ts;
|
|
|
153529
153609
|
})(ts || (ts = {}));
|
|
153530
153610
|
/* @internal */
|
|
153531
153611
|
var ts;
|
|
153612
|
+
(function (ts) {
|
|
153613
|
+
var codefix;
|
|
153614
|
+
(function (codefix) {
|
|
153615
|
+
var fixId = "fixUnreferenceableDecoratorMetadata";
|
|
153616
|
+
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];
|
|
153617
|
+
codefix.registerCodeFix({
|
|
153618
|
+
errorCodes: errorCodes,
|
|
153619
|
+
getCodeActions: function (context) {
|
|
153620
|
+
var importDeclaration = getImportDeclaration(context.sourceFile, context.program, context.span.start);
|
|
153621
|
+
if (!importDeclaration)
|
|
153622
|
+
return;
|
|
153623
|
+
var namespaceChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return importDeclaration.kind === 269 /* ImportSpecifier */ && doNamespaceImportChange(t, context.sourceFile, importDeclaration, context.program); });
|
|
153624
|
+
var typeOnlyChanges = ts.textChanges.ChangeTracker.with(context, function (t) { return doTypeOnlyImportChange(t, context.sourceFile, importDeclaration, context.program); });
|
|
153625
|
+
var actions;
|
|
153626
|
+
if (namespaceChanges.length) {
|
|
153627
|
+
actions = ts.append(actions, codefix.createCodeFixActionWithoutFixAll(fixId, namespaceChanges, ts.Diagnostics.Convert_named_imports_to_namespace_import));
|
|
153628
|
+
}
|
|
153629
|
+
if (typeOnlyChanges.length) {
|
|
153630
|
+
actions = ts.append(actions, codefix.createCodeFixActionWithoutFixAll(fixId, typeOnlyChanges, ts.Diagnostics.Convert_to_type_only_import));
|
|
153631
|
+
}
|
|
153632
|
+
return actions;
|
|
153633
|
+
},
|
|
153634
|
+
fixIds: [fixId],
|
|
153635
|
+
});
|
|
153636
|
+
function getImportDeclaration(sourceFile, program, start) {
|
|
153637
|
+
var identifier = ts.tryCast(ts.getTokenAtPosition(sourceFile, start), ts.isIdentifier);
|
|
153638
|
+
if (!identifier || identifier.parent.kind !== 177 /* TypeReference */)
|
|
153639
|
+
return;
|
|
153640
|
+
var checker = program.getTypeChecker();
|
|
153641
|
+
var symbol = checker.getSymbolAtLocation(identifier);
|
|
153642
|
+
return ts.find((symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray, ts.or(ts.isImportClause, ts.isImportSpecifier, ts.isImportEqualsDeclaration));
|
|
153643
|
+
}
|
|
153644
|
+
// Converts the import declaration of the offending import to a type-only import,
|
|
153645
|
+
// only if it can be done without affecting other imported names. If the conversion
|
|
153646
|
+
// cannot be done cleanly, we could offer to *extract* the offending import to a
|
|
153647
|
+
// new type-only import declaration, but honestly I doubt anyone will ever use this
|
|
153648
|
+
// codefix at all, so it's probably not worth the lines of code.
|
|
153649
|
+
function doTypeOnlyImportChange(changes, sourceFile, importDeclaration, program) {
|
|
153650
|
+
if (importDeclaration.kind === 264 /* ImportEqualsDeclaration */) {
|
|
153651
|
+
changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, importDeclaration.name);
|
|
153652
|
+
return;
|
|
153653
|
+
}
|
|
153654
|
+
var importClause = importDeclaration.kind === 266 /* ImportClause */ ? importDeclaration : importDeclaration.parent.parent;
|
|
153655
|
+
if (importClause.name && importClause.namedBindings) {
|
|
153656
|
+
// Cannot convert an import with a default import and named bindings to type-only
|
|
153657
|
+
// (it's a grammar error).
|
|
153658
|
+
return;
|
|
153659
|
+
}
|
|
153660
|
+
var checker = program.getTypeChecker();
|
|
153661
|
+
var importsValue = !!ts.forEachImportClauseDeclaration(importClause, function (decl) {
|
|
153662
|
+
if (ts.skipAlias(decl.symbol, checker).flags & 111551 /* Value */)
|
|
153663
|
+
return true;
|
|
153664
|
+
});
|
|
153665
|
+
if (importsValue) {
|
|
153666
|
+
// Assume that if someone wrote a non-type-only import that includes some values,
|
|
153667
|
+
// they intend to use those values in value positions, even if they haven't yet.
|
|
153668
|
+
// Don't convert it to type-only.
|
|
153669
|
+
return;
|
|
153670
|
+
}
|
|
153671
|
+
changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, importClause);
|
|
153672
|
+
}
|
|
153673
|
+
function doNamespaceImportChange(changes, sourceFile, importDeclaration, program) {
|
|
153674
|
+
ts.refactor.doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, importDeclaration.parent);
|
|
153675
|
+
}
|
|
153676
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
153677
|
+
})(ts || (ts = {}));
|
|
153678
|
+
/* @internal */
|
|
153679
|
+
var ts;
|
|
153532
153680
|
(function (ts) {
|
|
153533
153681
|
var codefix;
|
|
153534
153682
|
(function (codefix) {
|
|
@@ -156096,6 +156244,7 @@ var ts;
|
|
|
156096
156244
|
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);
|
|
156097
156245
|
}
|
|
156098
156246
|
function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
|
|
156247
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156099
156248
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
|
|
156100
156249
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156101
156250
|
}
|
|
@@ -156125,6 +156274,7 @@ var ts;
|
|
|
156125
156274
|
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);
|
|
156126
156275
|
}
|
|
156127
156276
|
function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
|
|
156277
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156128
156278
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
|
|
156129
156279
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156130
156280
|
}
|
|
@@ -157048,20 +157198,22 @@ var ts;
|
|
|
157048
157198
|
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
157049
157199
|
return { convertTo: 0 /* Named */, import: importClause.namedBindings };
|
|
157050
157200
|
}
|
|
157051
|
-
var
|
|
157052
|
-
var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
|
|
157053
|
-
&& isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
|
|
157201
|
+
var shouldUseDefault = getShouldUseDefault(context.program, importClause);
|
|
157054
157202
|
return shouldUseDefault
|
|
157055
157203
|
? { convertTo: 1 /* Default */, import: importClause.namedBindings }
|
|
157056
157204
|
: { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
|
|
157057
157205
|
}
|
|
157206
|
+
function getShouldUseDefault(program, importClause) {
|
|
157207
|
+
return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())
|
|
157208
|
+
&& isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
|
|
157209
|
+
}
|
|
157058
157210
|
function doChange(sourceFile, program, changes, info) {
|
|
157059
157211
|
var checker = program.getTypeChecker();
|
|
157060
157212
|
if (info.convertTo === 0 /* Named */) {
|
|
157061
157213
|
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
157062
157214
|
}
|
|
157063
157215
|
else {
|
|
157064
|
-
doChangeNamedToNamespaceOrDefault(sourceFile,
|
|
157216
|
+
doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */);
|
|
157065
157217
|
}
|
|
157066
157218
|
}
|
|
157067
157219
|
function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
|
|
@@ -157111,7 +157263,9 @@ var ts;
|
|
|
157111
157263
|
function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
|
|
157112
157264
|
return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
|
|
157113
157265
|
}
|
|
157114
|
-
function doChangeNamedToNamespaceOrDefault(sourceFile,
|
|
157266
|
+
function doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, toConvert, shouldUseDefault) {
|
|
157267
|
+
if (shouldUseDefault === void 0) { shouldUseDefault = getShouldUseDefault(program, toConvert.parent); }
|
|
157268
|
+
var checker = program.getTypeChecker();
|
|
157115
157269
|
var importDecl = toConvert.parent.parent;
|
|
157116
157270
|
var moduleSpecifier = importDecl.moduleSpecifier;
|
|
157117
157271
|
var toConvertSymbols = new ts.Set();
|
|
@@ -157172,6 +157326,7 @@ var ts;
|
|
|
157172
157326
|
changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
|
|
157173
157327
|
}
|
|
157174
157328
|
}
|
|
157329
|
+
refactor.doChangeNamedToNamespaceOrDefault = doChangeNamedToNamespaceOrDefault;
|
|
157175
157330
|
function isExportEqualsModule(moduleSpecifier, checker) {
|
|
157176
157331
|
var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
|
|
157177
157332
|
if (!externalModule)
|
|
@@ -158572,7 +158727,9 @@ var ts;
|
|
|
158572
158727
|
var checker = context.program.getTypeChecker();
|
|
158573
158728
|
// Make a unique name for the extracted variable
|
|
158574
158729
|
var file = scope.getSourceFile();
|
|
158575
|
-
var localNameText = ts.
|
|
158730
|
+
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)
|
|
158731
|
+
? node.name.text
|
|
158732
|
+
: ts.getUniqueName(ts.isClassLike(scope) ? "newProperty" : "newLocal", file);
|
|
158576
158733
|
var isJS = ts.isInJSFile(scope);
|
|
158577
158734
|
var variableType = isJS || !checker.isContextSensitive(node)
|
|
158578
158735
|
? undefined
|
|
@@ -162339,10 +162496,12 @@ var ts;
|
|
|
162339
162496
|
this.fileNameToEntry = new ts.Map();
|
|
162340
162497
|
// Initialize the list with the root file names
|
|
162341
162498
|
var rootFileNames = host.getScriptFileNames();
|
|
162499
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
|
|
162342
162500
|
for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
|
|
162343
162501
|
var fileName = rootFileNames_1[_i];
|
|
162344
162502
|
this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
|
|
162345
162503
|
}
|
|
162504
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
162346
162505
|
}
|
|
162347
162506
|
HostCache.prototype.createEntry = function (fileName, path) {
|
|
162348
162507
|
var entry;
|
|
@@ -167830,6 +167989,7 @@ var ts;
|
|
|
167830
167989
|
*/
|
|
167831
167990
|
Project.prototype.updateGraph = function () {
|
|
167832
167991
|
var _a;
|
|
167992
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] });
|
|
167833
167993
|
ts.perfLogger.logStartUpdateGraph();
|
|
167834
167994
|
this.resolutionCache.startRecordingFilesWithChangedResolutions();
|
|
167835
167995
|
var hasNewProgram = this.updateGraphWorker();
|
|
@@ -167873,6 +168033,7 @@ var ts;
|
|
|
167873
168033
|
this.getPackageJsonAutoImportProvider();
|
|
167874
168034
|
}
|
|
167875
168035
|
ts.perfLogger.logStopUpdateGraph();
|
|
168036
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
167876
168037
|
return !hasNewProgram;
|
|
167877
168038
|
};
|
|
167878
168039
|
/*@internal*/
|
|
@@ -167905,7 +168066,9 @@ var ts;
|
|
|
167905
168066
|
this.resolutionCache.startCachingPerDirectoryResolution();
|
|
167906
168067
|
this.program = this.languageService.getProgram(); // TODO: GH#18217
|
|
167907
168068
|
this.dirty = false;
|
|
168069
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution");
|
|
167908
168070
|
this.resolutionCache.finishCachingPerDirectoryResolution();
|
|
168071
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
167909
168072
|
ts.Debug.assert(oldProgram === undefined || this.program !== undefined);
|
|
167910
168073
|
// bump up the version if
|
|
167911
168074
|
// - oldProgram is not set - this is a first time updateGraph is called
|
|
@@ -168453,13 +168616,16 @@ var ts;
|
|
|
168453
168616
|
}
|
|
168454
168617
|
var dependencySelection = this.includePackageJsonAutoImports();
|
|
168455
168618
|
if (dependencySelection) {
|
|
168619
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getPackageJsonAutoImportProvider");
|
|
168456
168620
|
var start = ts.timestamp();
|
|
168457
168621
|
this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getModuleResolutionHostForAutoImportProvider(), this.documentRegistry);
|
|
168458
168622
|
if (this.autoImportProviderHost) {
|
|
168459
168623
|
server.updateProjectIfDirty(this.autoImportProviderHost);
|
|
168460
168624
|
this.sendPerformanceEvent("CreatePackageJsonAutoImportProvider", ts.timestamp() - start);
|
|
168625
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168461
168626
|
return this.autoImportProviderHost.getCurrentProgram();
|
|
168462
168627
|
}
|
|
168628
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168463
168629
|
}
|
|
168464
168630
|
};
|
|
168465
168631
|
/*@internal*/
|
|
@@ -168479,10 +168645,14 @@ var ts;
|
|
|
168479
168645
|
}());
|
|
168480
168646
|
server.Project = Project;
|
|
168481
168647
|
function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) {
|
|
168648
|
+
var sourceFiles = program.getSourceFiles();
|
|
168649
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getUnresolvedImports", { count: sourceFiles.length });
|
|
168482
168650
|
var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); });
|
|
168483
|
-
|
|
168651
|
+
var result = ts.sortAndDeduplicate(ts.flatMap(sourceFiles, function (sourceFile) {
|
|
168484
168652
|
return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile);
|
|
168485
168653
|
}));
|
|
168654
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168655
|
+
return result;
|
|
168486
168656
|
}
|
|
168487
168657
|
function extractUnresolvedImportsFromSourceFile(file, ambientModules, cachedUnresolvedImportsPerFile) {
|
|
168488
168658
|
return ts.getOrUpdate(cachedUnresolvedImportsPerFile, file.path, function () {
|
|
@@ -170556,6 +170726,7 @@ var ts;
|
|
|
170556
170726
|
};
|
|
170557
170727
|
/* @internal */
|
|
170558
170728
|
ProjectService.prototype.createConfiguredProject = function (configFileName) {
|
|
170729
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "createConfiguredProject", { configFilePath: configFileName });
|
|
170559
170730
|
this.logger.info("Creating configuration project " + configFileName);
|
|
170560
170731
|
var canonicalConfigFilePath = server.asNormalizedPath(this.toCanonicalFileName(configFileName));
|
|
170561
170732
|
var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath);
|
|
@@ -170604,6 +170775,7 @@ var ts;
|
|
|
170604
170775
|
/* @internal */
|
|
170605
170776
|
ProjectService.prototype.loadConfiguredProject = function (project, reason) {
|
|
170606
170777
|
var _this = this;
|
|
170778
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath });
|
|
170607
170779
|
this.sendProjectLoadingStartEvent(project, reason);
|
|
170608
170780
|
// Read updated contents from disk
|
|
170609
170781
|
var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath()));
|
|
@@ -170639,6 +170811,7 @@ var ts;
|
|
|
170639
170811
|
project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides);
|
|
170640
170812
|
var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles());
|
|
170641
170813
|
this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave, parsedCommandLine.watchOptions);
|
|
170814
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
170642
170815
|
};
|
|
170643
170816
|
/*@internal*/
|
|
170644
170817
|
ProjectService.prototype.ensureParsedConfigUptoDate = function (configFilename, canonicalConfigFilePath, configFileExistenceInfo, forProject) {
|
|
@@ -173687,7 +173860,6 @@ var ts;
|
|
|
173687
173860
|
this.host.write(msgText);
|
|
173688
173861
|
};
|
|
173689
173862
|
Session.prototype.event = function (body, eventName) {
|
|
173690
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "event", { eventName: eventName });
|
|
173691
173863
|
this.send(toEvent(eventName, body));
|
|
173692
173864
|
};
|
|
173693
173865
|
// For backwards-compatibility only.
|
|
@@ -173736,16 +173908,22 @@ var ts;
|
|
|
173736
173908
|
this.send(res);
|
|
173737
173909
|
};
|
|
173738
173910
|
Session.prototype.semanticCheck = function (file, project) {
|
|
173911
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "semanticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails
|
|
173739
173912
|
var diags = isDeclarationFileInJSOnlyNonConfiguredProject(project, file)
|
|
173740
173913
|
? server.emptyArray
|
|
173741
173914
|
: project.getLanguageService().getSemanticDiagnostics(file).filter(function (d) { return !!d.file; });
|
|
173742
173915
|
this.sendDiagnosticsEvent(file, project, diags, "semanticDiag");
|
|
173916
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
173743
173917
|
};
|
|
173744
173918
|
Session.prototype.syntacticCheck = function (file, project) {
|
|
173919
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "syntacticCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails
|
|
173745
173920
|
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag");
|
|
173921
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
173746
173922
|
};
|
|
173747
173923
|
Session.prototype.suggestionCheck = function (file, project) {
|
|
173924
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "suggestionCheck", { file: file, configFilePath: project.canonicalConfigFilePath }); // undefined is fine if the cast fails
|
|
173748
173925
|
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag");
|
|
173926
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
173749
173927
|
};
|
|
173750
173928
|
Session.prototype.sendDiagnosticsEvent = function (file, project, diagnostics, kind) {
|
|
173751
173929
|
try {
|