typescript 4.7.0-dev.20220317 → 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 +27 -12
- package/lib/tsserver.js +133 -20
- package/lib/tsserverlibrary.js +133 -20
- package/lib/typescript.js +112 -18
- package/lib/typescriptServices.js +112 -18
- package/lib/typingsInstaller.js +27 -12
- package/package.json +1 -1
package/lib/tsc.js
CHANGED
|
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
var ts;
|
|
70
70
|
(function (ts) {
|
|
71
71
|
ts.versionMajorMinor = "4.7";
|
|
72
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
72
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220318";
|
|
73
73
|
var NativeCollections;
|
|
74
74
|
(function (NativeCollections) {
|
|
75
75
|
var globals = typeof globalThis !== "undefined" ? globalThis :
|
|
@@ -5437,6 +5437,7 @@ var ts;
|
|
|
5437
5437
|
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."),
|
|
5438
5438
|
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}'."),
|
|
5439
5439
|
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'."),
|
|
5440
|
+
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."),
|
|
5440
5441
|
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."),
|
|
5441
5442
|
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."),
|
|
5442
5443
|
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."),
|
|
@@ -33318,7 +33319,10 @@ var ts;
|
|
|
33318
33319
|
}
|
|
33319
33320
|
ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
|
|
33320
33321
|
function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
|
|
33321
|
-
|
|
33322
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse", "parseJsonSourceFileConfigFileContent", { path: sourceFile.fileName });
|
|
33323
|
+
var result = parseJsonConfigFileContentWorker(undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
|
|
33324
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
33325
|
+
return result;
|
|
33322
33326
|
}
|
|
33323
33327
|
ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
|
|
33324
33328
|
function setConfigFileInOptions(options, configFile) {
|
|
@@ -67537,26 +67541,37 @@ var ts;
|
|
|
67537
67541
|
checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage);
|
|
67538
67542
|
}
|
|
67539
67543
|
function markTypeNodeAsReferenced(node) {
|
|
67540
|
-
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
|
|
67544
|
+
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node), false);
|
|
67541
67545
|
}
|
|
67542
|
-
function markEntityNameOrEntityExpressionAsReference(typeName) {
|
|
67546
|
+
function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
|
|
67543
67547
|
if (!typeName)
|
|
67544
67548
|
return;
|
|
67545
67549
|
var rootName = ts.getFirstIdentifier(typeName);
|
|
67546
67550
|
var meaning = (typeName.kind === 79 ? 788968 : 1920) | 2097152;
|
|
67547
67551
|
var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true);
|
|
67548
|
-
if (rootSymbol
|
|
67549
|
-
|
|
67550
|
-
|
|
67551
|
-
|
|
67552
|
-
|
|
67553
|
-
|
|
67552
|
+
if (rootSymbol && rootSymbol.flags & 2097152) {
|
|
67553
|
+
if (symbolIsValue(rootSymbol)
|
|
67554
|
+
&& !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
|
|
67555
|
+
&& !getTypeOnlyAliasDeclaration(rootSymbol)) {
|
|
67556
|
+
markAliasSymbolAsReferenced(rootSymbol);
|
|
67557
|
+
}
|
|
67558
|
+
else if (forDecoratorMetadata
|
|
67559
|
+
&& compilerOptions.isolatedModules
|
|
67560
|
+
&& ts.getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015
|
|
67561
|
+
&& !symbolIsValue(rootSymbol)
|
|
67562
|
+
&& !ts.some(rootSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration)) {
|
|
67563
|
+
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);
|
|
67564
|
+
var aliasDeclaration = ts.find(rootSymbol.declarations || ts.emptyArray, isAliasSymbolDeclaration);
|
|
67565
|
+
if (aliasDeclaration) {
|
|
67566
|
+
ts.addRelatedInfo(diag, ts.createDiagnosticForNode(aliasDeclaration, ts.Diagnostics._0_was_imported_here, ts.idText(rootName)));
|
|
67567
|
+
}
|
|
67568
|
+
}
|
|
67554
67569
|
}
|
|
67555
67570
|
}
|
|
67556
67571
|
function markDecoratorMedataDataTypeNodeAsReferenced(node) {
|
|
67557
67572
|
var entityName = getEntityNameForDecoratorMetadata(node);
|
|
67558
67573
|
if (entityName && ts.isEntityName(entityName)) {
|
|
67559
|
-
markEntityNameOrEntityExpressionAsReference(entityName);
|
|
67574
|
+
markEntityNameOrEntityExpressionAsReference(entityName, true);
|
|
67560
67575
|
}
|
|
67561
67576
|
}
|
|
67562
67577
|
function getEntityNameForDecoratorMetadata(node) {
|
|
@@ -70667,7 +70682,7 @@ var ts;
|
|
|
70667
70682
|
if (checkGrammarModuleElementContext(node, ts.isInJSFile(node) ? ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_module : ts.Diagnostics.An_export_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
70668
70683
|
return;
|
|
70669
70684
|
}
|
|
70670
|
-
if (!checkGrammarDecoratorsAndModifiers(node) && ts.
|
|
70685
|
+
if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) {
|
|
70671
70686
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
70672
70687
|
}
|
|
70673
70688
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0) {
|
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) {
|
|
@@ -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."),
|
|
@@ -40895,7 +40896,10 @@ var ts;
|
|
|
40895
40896
|
* file to. e.g. outDir
|
|
40896
40897
|
*/
|
|
40897
40898
|
function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
|
|
40898
|
-
|
|
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;
|
|
40899
40903
|
}
|
|
40900
40904
|
ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
|
|
40901
40905
|
/*@internal*/
|
|
@@ -80632,20 +80636,31 @@ var ts;
|
|
|
80632
80636
|
* marked as referenced to prevent import elision.
|
|
80633
80637
|
*/
|
|
80634
80638
|
function markTypeNodeAsReferenced(node) {
|
|
80635
|
-
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
|
|
80639
|
+
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node), /*forDecoratorMetadata*/ false);
|
|
80636
80640
|
}
|
|
80637
|
-
function markEntityNameOrEntityExpressionAsReference(typeName) {
|
|
80641
|
+
function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
|
|
80638
80642
|
if (!typeName)
|
|
80639
80643
|
return;
|
|
80640
80644
|
var rootName = ts.getFirstIdentifier(typeName);
|
|
80641
80645
|
var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
|
|
80642
80646
|
var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true);
|
|
80643
|
-
if (rootSymbol
|
|
80644
|
-
|
|
80645
|
-
|
|
80646
|
-
|
|
80647
|
-
|
|
80648
|
-
|
|
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
|
+
}
|
|
80649
80664
|
}
|
|
80650
80665
|
}
|
|
80651
80666
|
/**
|
|
@@ -80658,7 +80673,7 @@ var ts;
|
|
|
80658
80673
|
function markDecoratorMedataDataTypeNodeAsReferenced(node) {
|
|
80659
80674
|
var entityName = getEntityNameForDecoratorMetadata(node);
|
|
80660
80675
|
if (entityName && ts.isEntityName(entityName)) {
|
|
80661
|
-
markEntityNameOrEntityExpressionAsReference(entityName);
|
|
80676
|
+
markEntityNameOrEntityExpressionAsReference(entityName, /*forDecoratorMetadata*/ true);
|
|
80662
80677
|
}
|
|
80663
80678
|
}
|
|
80664
80679
|
function getEntityNameForDecoratorMetadata(node) {
|
|
@@ -84310,7 +84325,7 @@ var ts;
|
|
|
84310
84325
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
84311
84326
|
return;
|
|
84312
84327
|
}
|
|
84313
|
-
if (!checkGrammarDecoratorsAndModifiers(node) && ts.
|
|
84328
|
+
if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) {
|
|
84314
84329
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
84315
84330
|
}
|
|
84316
84331
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
@@ -153594,6 +153609,74 @@ var ts;
|
|
|
153594
153609
|
})(ts || (ts = {}));
|
|
153595
153610
|
/* @internal */
|
|
153596
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;
|
|
153597
153680
|
(function (ts) {
|
|
153598
153681
|
var codefix;
|
|
153599
153682
|
(function (codefix) {
|
|
@@ -156161,6 +156244,7 @@ var ts;
|
|
|
156161
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);
|
|
156162
156245
|
}
|
|
156163
156246
|
function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
|
|
156247
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156164
156248
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
|
|
156165
156249
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156166
156250
|
}
|
|
@@ -156190,6 +156274,7 @@ var ts;
|
|
|
156190
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);
|
|
156191
156275
|
}
|
|
156192
156276
|
function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
|
|
156277
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156193
156278
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
|
|
156194
156279
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156195
156280
|
}
|
|
@@ -157113,20 +157198,22 @@ var ts;
|
|
|
157113
157198
|
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
157114
157199
|
return { convertTo: 0 /* Named */, import: importClause.namedBindings };
|
|
157115
157200
|
}
|
|
157116
|
-
var
|
|
157117
|
-
var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
|
|
157118
|
-
&& isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
|
|
157201
|
+
var shouldUseDefault = getShouldUseDefault(context.program, importClause);
|
|
157119
157202
|
return shouldUseDefault
|
|
157120
157203
|
? { convertTo: 1 /* Default */, import: importClause.namedBindings }
|
|
157121
157204
|
: { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
|
|
157122
157205
|
}
|
|
157206
|
+
function getShouldUseDefault(program, importClause) {
|
|
157207
|
+
return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())
|
|
157208
|
+
&& isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
|
|
157209
|
+
}
|
|
157123
157210
|
function doChange(sourceFile, program, changes, info) {
|
|
157124
157211
|
var checker = program.getTypeChecker();
|
|
157125
157212
|
if (info.convertTo === 0 /* Named */) {
|
|
157126
157213
|
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
157127
157214
|
}
|
|
157128
157215
|
else {
|
|
157129
|
-
doChangeNamedToNamespaceOrDefault(sourceFile,
|
|
157216
|
+
doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */);
|
|
157130
157217
|
}
|
|
157131
157218
|
}
|
|
157132
157219
|
function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
|
|
@@ -157176,7 +157263,9 @@ var ts;
|
|
|
157176
157263
|
function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
|
|
157177
157264
|
return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
|
|
157178
157265
|
}
|
|
157179
|
-
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();
|
|
157180
157269
|
var importDecl = toConvert.parent.parent;
|
|
157181
157270
|
var moduleSpecifier = importDecl.moduleSpecifier;
|
|
157182
157271
|
var toConvertSymbols = new ts.Set();
|
|
@@ -157237,6 +157326,7 @@ var ts;
|
|
|
157237
157326
|
changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
|
|
157238
157327
|
}
|
|
157239
157328
|
}
|
|
157329
|
+
refactor.doChangeNamedToNamespaceOrDefault = doChangeNamedToNamespaceOrDefault;
|
|
157240
157330
|
function isExportEqualsModule(moduleSpecifier, checker) {
|
|
157241
157331
|
var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
|
|
157242
157332
|
if (!externalModule)
|
|
@@ -158637,7 +158727,9 @@ var ts;
|
|
|
158637
158727
|
var checker = context.program.getTypeChecker();
|
|
158638
158728
|
// Make a unique name for the extracted variable
|
|
158639
158729
|
var file = scope.getSourceFile();
|
|
158640
|
-
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);
|
|
158641
158733
|
var isJS = ts.isInJSFile(scope);
|
|
158642
158734
|
var variableType = isJS || !checker.isContextSensitive(node)
|
|
158643
158735
|
? undefined
|
|
@@ -162404,10 +162496,12 @@ var ts;
|
|
|
162404
162496
|
this.fileNameToEntry = new ts.Map();
|
|
162405
162497
|
// Initialize the list with the root file names
|
|
162406
162498
|
var rootFileNames = host.getScriptFileNames();
|
|
162499
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
|
|
162407
162500
|
for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
|
|
162408
162501
|
var fileName = rootFileNames_1[_i];
|
|
162409
162502
|
this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
|
|
162410
162503
|
}
|
|
162504
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
162411
162505
|
}
|
|
162412
162506
|
HostCache.prototype.createEntry = function (fileName, path) {
|
|
162413
162507
|
var entry;
|
|
@@ -167895,6 +167989,7 @@ var ts;
|
|
|
167895
167989
|
*/
|
|
167896
167990
|
Project.prototype.updateGraph = function () {
|
|
167897
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] });
|
|
167898
167993
|
ts.perfLogger.logStartUpdateGraph();
|
|
167899
167994
|
this.resolutionCache.startRecordingFilesWithChangedResolutions();
|
|
167900
167995
|
var hasNewProgram = this.updateGraphWorker();
|
|
@@ -167938,6 +168033,7 @@ var ts;
|
|
|
167938
168033
|
this.getPackageJsonAutoImportProvider();
|
|
167939
168034
|
}
|
|
167940
168035
|
ts.perfLogger.logStopUpdateGraph();
|
|
168036
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
167941
168037
|
return !hasNewProgram;
|
|
167942
168038
|
};
|
|
167943
168039
|
/*@internal*/
|
|
@@ -167970,7 +168066,9 @@ var ts;
|
|
|
167970
168066
|
this.resolutionCache.startCachingPerDirectoryResolution();
|
|
167971
168067
|
this.program = this.languageService.getProgram(); // TODO: GH#18217
|
|
167972
168068
|
this.dirty = false;
|
|
168069
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution");
|
|
167973
168070
|
this.resolutionCache.finishCachingPerDirectoryResolution();
|
|
168071
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
167974
168072
|
ts.Debug.assert(oldProgram === undefined || this.program !== undefined);
|
|
167975
168073
|
// bump up the version if
|
|
167976
168074
|
// - oldProgram is not set - this is a first time updateGraph is called
|
|
@@ -168518,13 +168616,16 @@ var ts;
|
|
|
168518
168616
|
}
|
|
168519
168617
|
var dependencySelection = this.includePackageJsonAutoImports();
|
|
168520
168618
|
if (dependencySelection) {
|
|
168619
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getPackageJsonAutoImportProvider");
|
|
168521
168620
|
var start = ts.timestamp();
|
|
168522
168621
|
this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getModuleResolutionHostForAutoImportProvider(), this.documentRegistry);
|
|
168523
168622
|
if (this.autoImportProviderHost) {
|
|
168524
168623
|
server.updateProjectIfDirty(this.autoImportProviderHost);
|
|
168525
168624
|
this.sendPerformanceEvent("CreatePackageJsonAutoImportProvider", ts.timestamp() - start);
|
|
168625
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168526
168626
|
return this.autoImportProviderHost.getCurrentProgram();
|
|
168527
168627
|
}
|
|
168628
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168528
168629
|
}
|
|
168529
168630
|
};
|
|
168530
168631
|
/*@internal*/
|
|
@@ -168544,10 +168645,14 @@ var ts;
|
|
|
168544
168645
|
}());
|
|
168545
168646
|
server.Project = Project;
|
|
168546
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 });
|
|
168547
168650
|
var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); });
|
|
168548
|
-
|
|
168651
|
+
var result = ts.sortAndDeduplicate(ts.flatMap(sourceFiles, function (sourceFile) {
|
|
168549
168652
|
return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile);
|
|
168550
168653
|
}));
|
|
168654
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168655
|
+
return result;
|
|
168551
168656
|
}
|
|
168552
168657
|
function extractUnresolvedImportsFromSourceFile(file, ambientModules, cachedUnresolvedImportsPerFile) {
|
|
168553
168658
|
return ts.getOrUpdate(cachedUnresolvedImportsPerFile, file.path, function () {
|
|
@@ -170621,6 +170726,7 @@ var ts;
|
|
|
170621
170726
|
};
|
|
170622
170727
|
/* @internal */
|
|
170623
170728
|
ProjectService.prototype.createConfiguredProject = function (configFileName) {
|
|
170729
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "createConfiguredProject", { configFilePath: configFileName });
|
|
170624
170730
|
this.logger.info("Creating configuration project " + configFileName);
|
|
170625
170731
|
var canonicalConfigFilePath = server.asNormalizedPath(this.toCanonicalFileName(configFileName));
|
|
170626
170732
|
var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath);
|
|
@@ -170669,6 +170775,7 @@ var ts;
|
|
|
170669
170775
|
/* @internal */
|
|
170670
170776
|
ProjectService.prototype.loadConfiguredProject = function (project, reason) {
|
|
170671
170777
|
var _this = this;
|
|
170778
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath });
|
|
170672
170779
|
this.sendProjectLoadingStartEvent(project, reason);
|
|
170673
170780
|
// Read updated contents from disk
|
|
170674
170781
|
var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath()));
|
|
@@ -170704,6 +170811,7 @@ var ts;
|
|
|
170704
170811
|
project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides);
|
|
170705
170812
|
var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles());
|
|
170706
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();
|
|
170707
170815
|
};
|
|
170708
170816
|
/*@internal*/
|
|
170709
170817
|
ProjectService.prototype.ensureParsedConfigUptoDate = function (configFilename, canonicalConfigFilePath, configFileExistenceInfo, forProject) {
|
|
@@ -173752,7 +173860,6 @@ var ts;
|
|
|
173752
173860
|
this.host.write(msgText);
|
|
173753
173861
|
};
|
|
173754
173862
|
Session.prototype.event = function (body, eventName) {
|
|
173755
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "event", { eventName: eventName });
|
|
173756
173863
|
this.send(toEvent(eventName, body));
|
|
173757
173864
|
};
|
|
173758
173865
|
// For backwards-compatibility only.
|
|
@@ -173801,16 +173908,22 @@ var ts;
|
|
|
173801
173908
|
this.send(res);
|
|
173802
173909
|
};
|
|
173803
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
|
|
173804
173912
|
var diags = isDeclarationFileInJSOnlyNonConfiguredProject(project, file)
|
|
173805
173913
|
? server.emptyArray
|
|
173806
173914
|
: project.getLanguageService().getSemanticDiagnostics(file).filter(function (d) { return !!d.file; });
|
|
173807
173915
|
this.sendDiagnosticsEvent(file, project, diags, "semanticDiag");
|
|
173916
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
173808
173917
|
};
|
|
173809
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
|
|
173810
173920
|
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag");
|
|
173921
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
173811
173922
|
};
|
|
173812
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
|
|
173813
173925
|
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag");
|
|
173926
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
173814
173927
|
};
|
|
173815
173928
|
Session.prototype.sendDiagnosticsEvent = function (file, project, diagnostics, kind) {
|
|
173816
173929
|
try {
|