typescript 4.7.0-dev.20220317 → 4.7.0-dev.20220320
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/tsserverlibrary.js
CHANGED
|
@@ -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.20220320";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -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."),
|
|
@@ -41089,7 +41090,10 @@ var ts;
|
|
|
41089
41090
|
* file to. e.g. outDir
|
|
41090
41091
|
*/
|
|
41091
41092
|
function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
|
|
41092
|
-
|
|
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;
|
|
41093
41097
|
}
|
|
41094
41098
|
ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
|
|
41095
41099
|
/*@internal*/
|
|
@@ -80826,20 +80830,31 @@ var ts;
|
|
|
80826
80830
|
* marked as referenced to prevent import elision.
|
|
80827
80831
|
*/
|
|
80828
80832
|
function markTypeNodeAsReferenced(node) {
|
|
80829
|
-
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
|
|
80833
|
+
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node), /*forDecoratorMetadata*/ false);
|
|
80830
80834
|
}
|
|
80831
|
-
function markEntityNameOrEntityExpressionAsReference(typeName) {
|
|
80835
|
+
function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
|
|
80832
80836
|
if (!typeName)
|
|
80833
80837
|
return;
|
|
80834
80838
|
var rootName = ts.getFirstIdentifier(typeName);
|
|
80835
80839
|
var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
|
|
80836
80840
|
var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true);
|
|
80837
|
-
if (rootSymbol
|
|
80838
|
-
|
|
80839
|
-
|
|
80840
|
-
|
|
80841
|
-
|
|
80842
|
-
|
|
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
|
+
}
|
|
80843
80858
|
}
|
|
80844
80859
|
}
|
|
80845
80860
|
/**
|
|
@@ -80852,7 +80867,7 @@ var ts;
|
|
|
80852
80867
|
function markDecoratorMedataDataTypeNodeAsReferenced(node) {
|
|
80853
80868
|
var entityName = getEntityNameForDecoratorMetadata(node);
|
|
80854
80869
|
if (entityName && ts.isEntityName(entityName)) {
|
|
80855
|
-
markEntityNameOrEntityExpressionAsReference(entityName);
|
|
80870
|
+
markEntityNameOrEntityExpressionAsReference(entityName, /*forDecoratorMetadata*/ true);
|
|
80856
80871
|
}
|
|
80857
80872
|
}
|
|
80858
80873
|
function getEntityNameForDecoratorMetadata(node) {
|
|
@@ -84504,7 +84519,7 @@ var ts;
|
|
|
84504
84519
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
84505
84520
|
return;
|
|
84506
84521
|
}
|
|
84507
|
-
if (!checkGrammarDecoratorsAndModifiers(node) && ts.
|
|
84522
|
+
if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) {
|
|
84508
84523
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
84509
84524
|
}
|
|
84510
84525
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
@@ -154205,6 +154220,74 @@ var ts;
|
|
|
154205
154220
|
})(ts || (ts = {}));
|
|
154206
154221
|
/* @internal */
|
|
154207
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;
|
|
154208
154291
|
(function (ts) {
|
|
154209
154292
|
var codefix;
|
|
154210
154293
|
(function (codefix) {
|
|
@@ -156772,6 +156855,7 @@ var ts;
|
|
|
156772
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);
|
|
156773
156856
|
}
|
|
156774
156857
|
function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
|
|
156858
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156775
156859
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
|
|
156776
156860
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156777
156861
|
}
|
|
@@ -156801,6 +156885,7 @@ var ts;
|
|
|
156801
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);
|
|
156802
156886
|
}
|
|
156803
156887
|
function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
|
|
156888
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156804
156889
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
|
|
156805
156890
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156806
156891
|
}
|
|
@@ -157724,20 +157809,22 @@ var ts;
|
|
|
157724
157809
|
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
157725
157810
|
return { convertTo: 0 /* Named */, import: importClause.namedBindings };
|
|
157726
157811
|
}
|
|
157727
|
-
var
|
|
157728
|
-
var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
|
|
157729
|
-
&& isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
|
|
157812
|
+
var shouldUseDefault = getShouldUseDefault(context.program, importClause);
|
|
157730
157813
|
return shouldUseDefault
|
|
157731
157814
|
? { convertTo: 1 /* Default */, import: importClause.namedBindings }
|
|
157732
157815
|
: { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
|
|
157733
157816
|
}
|
|
157817
|
+
function getShouldUseDefault(program, importClause) {
|
|
157818
|
+
return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())
|
|
157819
|
+
&& isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
|
|
157820
|
+
}
|
|
157734
157821
|
function doChange(sourceFile, program, changes, info) {
|
|
157735
157822
|
var checker = program.getTypeChecker();
|
|
157736
157823
|
if (info.convertTo === 0 /* Named */) {
|
|
157737
157824
|
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
157738
157825
|
}
|
|
157739
157826
|
else {
|
|
157740
|
-
doChangeNamedToNamespaceOrDefault(sourceFile,
|
|
157827
|
+
doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */);
|
|
157741
157828
|
}
|
|
157742
157829
|
}
|
|
157743
157830
|
function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
|
|
@@ -157787,7 +157874,9 @@ var ts;
|
|
|
157787
157874
|
function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
|
|
157788
157875
|
return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
|
|
157789
157876
|
}
|
|
157790
|
-
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();
|
|
157791
157880
|
var importDecl = toConvert.parent.parent;
|
|
157792
157881
|
var moduleSpecifier = importDecl.moduleSpecifier;
|
|
157793
157882
|
var toConvertSymbols = new ts.Set();
|
|
@@ -157848,6 +157937,7 @@ var ts;
|
|
|
157848
157937
|
changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
|
|
157849
157938
|
}
|
|
157850
157939
|
}
|
|
157940
|
+
refactor.doChangeNamedToNamespaceOrDefault = doChangeNamedToNamespaceOrDefault;
|
|
157851
157941
|
function isExportEqualsModule(moduleSpecifier, checker) {
|
|
157852
157942
|
var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
|
|
157853
157943
|
if (!externalModule)
|
|
@@ -159248,7 +159338,9 @@ var ts;
|
|
|
159248
159338
|
var checker = context.program.getTypeChecker();
|
|
159249
159339
|
// Make a unique name for the extracted variable
|
|
159250
159340
|
var file = scope.getSourceFile();
|
|
159251
|
-
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);
|
|
159252
159344
|
var isJS = ts.isInJSFile(scope);
|
|
159253
159345
|
var variableType = isJS || !checker.isContextSensitive(node)
|
|
159254
159346
|
? undefined
|
|
@@ -163015,10 +163107,12 @@ var ts;
|
|
|
163015
163107
|
this.fileNameToEntry = new ts.Map();
|
|
163016
163108
|
// Initialize the list with the root file names
|
|
163017
163109
|
var rootFileNames = host.getScriptFileNames();
|
|
163110
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
|
|
163018
163111
|
for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
|
|
163019
163112
|
var fileName = rootFileNames_1[_i];
|
|
163020
163113
|
this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
|
|
163021
163114
|
}
|
|
163115
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
163022
163116
|
}
|
|
163023
163117
|
HostCache.prototype.createEntry = function (fileName, path) {
|
|
163024
163118
|
var entry;
|
|
@@ -168089,6 +168183,7 @@ var ts;
|
|
|
168089
168183
|
*/
|
|
168090
168184
|
Project.prototype.updateGraph = function () {
|
|
168091
168185
|
var _a;
|
|
168186
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "updateGraph", { name: this.projectName, kind: ProjectKind[this.projectKind] });
|
|
168092
168187
|
ts.perfLogger.logStartUpdateGraph();
|
|
168093
168188
|
this.resolutionCache.startRecordingFilesWithChangedResolutions();
|
|
168094
168189
|
var hasNewProgram = this.updateGraphWorker();
|
|
@@ -168132,6 +168227,7 @@ var ts;
|
|
|
168132
168227
|
this.getPackageJsonAutoImportProvider();
|
|
168133
168228
|
}
|
|
168134
168229
|
ts.perfLogger.logStopUpdateGraph();
|
|
168230
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168135
168231
|
return !hasNewProgram;
|
|
168136
168232
|
};
|
|
168137
168233
|
/*@internal*/
|
|
@@ -168164,7 +168260,9 @@ var ts;
|
|
|
168164
168260
|
this.resolutionCache.startCachingPerDirectoryResolution();
|
|
168165
168261
|
this.program = this.languageService.getProgram(); // TODO: GH#18217
|
|
168166
168262
|
this.dirty = false;
|
|
168263
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "finishCachingPerDirectoryResolution");
|
|
168167
168264
|
this.resolutionCache.finishCachingPerDirectoryResolution();
|
|
168265
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168168
168266
|
ts.Debug.assert(oldProgram === undefined || this.program !== undefined);
|
|
168169
168267
|
// bump up the version if
|
|
168170
168268
|
// - oldProgram is not set - this is a first time updateGraph is called
|
|
@@ -168712,13 +168810,16 @@ var ts;
|
|
|
168712
168810
|
}
|
|
168713
168811
|
var dependencySelection = this.includePackageJsonAutoImports();
|
|
168714
168812
|
if (dependencySelection) {
|
|
168813
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getPackageJsonAutoImportProvider");
|
|
168715
168814
|
var start = ts.timestamp();
|
|
168716
168815
|
this.autoImportProviderHost = AutoImportProviderProject.create(dependencySelection, this, this.getModuleResolutionHostForAutoImportProvider(), this.documentRegistry);
|
|
168717
168816
|
if (this.autoImportProviderHost) {
|
|
168718
168817
|
server.updateProjectIfDirty(this.autoImportProviderHost);
|
|
168719
168818
|
this.sendPerformanceEvent("CreatePackageJsonAutoImportProvider", ts.timestamp() - start);
|
|
168819
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168720
168820
|
return this.autoImportProviderHost.getCurrentProgram();
|
|
168721
168821
|
}
|
|
168822
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168722
168823
|
}
|
|
168723
168824
|
};
|
|
168724
168825
|
/*@internal*/
|
|
@@ -168738,10 +168839,14 @@ var ts;
|
|
|
168738
168839
|
}());
|
|
168739
168840
|
server.Project = Project;
|
|
168740
168841
|
function getUnresolvedImports(program, cachedUnresolvedImportsPerFile) {
|
|
168842
|
+
var sourceFiles = program.getSourceFiles();
|
|
168843
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "getUnresolvedImports", { count: sourceFiles.length });
|
|
168741
168844
|
var ambientModules = program.getTypeChecker().getAmbientModules().map(function (mod) { return ts.stripQuotes(mod.getName()); });
|
|
168742
|
-
|
|
168845
|
+
var result = ts.sortAndDeduplicate(ts.flatMap(sourceFiles, function (sourceFile) {
|
|
168743
168846
|
return extractUnresolvedImportsFromSourceFile(sourceFile, ambientModules, cachedUnresolvedImportsPerFile);
|
|
168744
168847
|
}));
|
|
168848
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
168849
|
+
return result;
|
|
168745
168850
|
}
|
|
168746
168851
|
function extractUnresolvedImportsFromSourceFile(file, ambientModules, cachedUnresolvedImportsPerFile) {
|
|
168747
168852
|
return ts.getOrUpdate(cachedUnresolvedImportsPerFile, file.path, function () {
|
|
@@ -170815,6 +170920,7 @@ var ts;
|
|
|
170815
170920
|
};
|
|
170816
170921
|
/* @internal */
|
|
170817
170922
|
ProjectService.prototype.createConfiguredProject = function (configFileName) {
|
|
170923
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "createConfiguredProject", { configFilePath: configFileName });
|
|
170818
170924
|
this.logger.info("Creating configuration project " + configFileName);
|
|
170819
170925
|
var canonicalConfigFilePath = server.asNormalizedPath(this.toCanonicalFileName(configFileName));
|
|
170820
170926
|
var configFileExistenceInfo = this.configFileExistenceInfoCache.get(canonicalConfigFilePath);
|
|
@@ -170863,6 +170969,7 @@ var ts;
|
|
|
170863
170969
|
/* @internal */
|
|
170864
170970
|
ProjectService.prototype.loadConfiguredProject = function (project, reason) {
|
|
170865
170971
|
var _this = this;
|
|
170972
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "loadConfiguredProject", { configFilePath: project.canonicalConfigFilePath });
|
|
170866
170973
|
this.sendProjectLoadingStartEvent(project, reason);
|
|
170867
170974
|
// Read updated contents from disk
|
|
170868
170975
|
var configFilename = server.asNormalizedPath(ts.normalizePath(project.getConfigFilePath()));
|
|
@@ -170898,6 +171005,7 @@ var ts;
|
|
|
170898
171005
|
project.enablePluginsWithOptions(compilerOptions, this.currentPluginConfigOverrides);
|
|
170899
171006
|
var filesToAdd = parsedCommandLine.fileNames.concat(project.getExternalFiles());
|
|
170900
171007
|
this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave, parsedCommandLine.watchOptions);
|
|
171008
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
170901
171009
|
};
|
|
170902
171010
|
/*@internal*/
|
|
170903
171011
|
ProjectService.prototype.ensureParsedConfigUptoDate = function (configFilename, canonicalConfigFilePath, configFileExistenceInfo, forProject) {
|
|
@@ -173946,7 +174054,6 @@ var ts;
|
|
|
173946
174054
|
this.host.write(msgText);
|
|
173947
174055
|
};
|
|
173948
174056
|
Session.prototype.event = function (body, eventName) {
|
|
173949
|
-
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("session" /* Session */, "event", { eventName: eventName });
|
|
173950
174057
|
this.send(toEvent(eventName, body));
|
|
173951
174058
|
};
|
|
173952
174059
|
// For backwards-compatibility only.
|
|
@@ -173995,16 +174102,22 @@ var ts;
|
|
|
173995
174102
|
this.send(res);
|
|
173996
174103
|
};
|
|
173997
174104
|
Session.prototype.semanticCheck = function (file, project) {
|
|
174105
|
+
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
|
|
173998
174106
|
var diags = isDeclarationFileInJSOnlyNonConfiguredProject(project, file)
|
|
173999
174107
|
? server.emptyArray
|
|
174000
174108
|
: project.getLanguageService().getSemanticDiagnostics(file).filter(function (d) { return !!d.file; });
|
|
174001
174109
|
this.sendDiagnosticsEvent(file, project, diags, "semanticDiag");
|
|
174110
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
174002
174111
|
};
|
|
174003
174112
|
Session.prototype.syntacticCheck = function (file, project) {
|
|
174113
|
+
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
|
|
174004
174114
|
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSyntacticDiagnostics(file), "syntaxDiag");
|
|
174115
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
174005
174116
|
};
|
|
174006
174117
|
Session.prototype.suggestionCheck = function (file, project) {
|
|
174118
|
+
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
|
|
174007
174119
|
this.sendDiagnosticsEvent(file, project, project.getLanguageService().getSuggestionDiagnostics(file), "suggestionDiag");
|
|
174120
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
174008
174121
|
};
|
|
174009
174122
|
Session.prototype.sendDiagnosticsEvent = function (file, project, diagnostics, kind) {
|
|
174010
174123
|
try {
|
package/lib/typescript.js
CHANGED
|
@@ -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.20220320";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -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."),
|
|
@@ -41089,7 +41090,10 @@ var ts;
|
|
|
41089
41090
|
* file to. e.g. outDir
|
|
41090
41091
|
*/
|
|
41091
41092
|
function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
|
|
41092
|
-
|
|
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;
|
|
41093
41097
|
}
|
|
41094
41098
|
ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
|
|
41095
41099
|
/*@internal*/
|
|
@@ -80826,20 +80830,31 @@ var ts;
|
|
|
80826
80830
|
* marked as referenced to prevent import elision.
|
|
80827
80831
|
*/
|
|
80828
80832
|
function markTypeNodeAsReferenced(node) {
|
|
80829
|
-
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
|
|
80833
|
+
markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node), /*forDecoratorMetadata*/ false);
|
|
80830
80834
|
}
|
|
80831
|
-
function markEntityNameOrEntityExpressionAsReference(typeName) {
|
|
80835
|
+
function markEntityNameOrEntityExpressionAsReference(typeName, forDecoratorMetadata) {
|
|
80832
80836
|
if (!typeName)
|
|
80833
80837
|
return;
|
|
80834
80838
|
var rootName = ts.getFirstIdentifier(typeName);
|
|
80835
80839
|
var meaning = (typeName.kind === 79 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */;
|
|
80836
80840
|
var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isReference*/ true);
|
|
80837
|
-
if (rootSymbol
|
|
80838
|
-
|
|
80839
|
-
|
|
80840
|
-
|
|
80841
|
-
|
|
80842
|
-
|
|
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
|
+
}
|
|
80843
80858
|
}
|
|
80844
80859
|
}
|
|
80845
80860
|
/**
|
|
@@ -80852,7 +80867,7 @@ var ts;
|
|
|
80852
80867
|
function markDecoratorMedataDataTypeNodeAsReferenced(node) {
|
|
80853
80868
|
var entityName = getEntityNameForDecoratorMetadata(node);
|
|
80854
80869
|
if (entityName && ts.isEntityName(entityName)) {
|
|
80855
|
-
markEntityNameOrEntityExpressionAsReference(entityName);
|
|
80870
|
+
markEntityNameOrEntityExpressionAsReference(entityName, /*forDecoratorMetadata*/ true);
|
|
80856
80871
|
}
|
|
80857
80872
|
}
|
|
80858
80873
|
function getEntityNameForDecoratorMetadata(node) {
|
|
@@ -84504,7 +84519,7 @@ var ts;
|
|
|
84504
84519
|
// If we hit an export in an illegal context, just bail out to avoid cascading errors.
|
|
84505
84520
|
return;
|
|
84506
84521
|
}
|
|
84507
|
-
if (!checkGrammarDecoratorsAndModifiers(node) && ts.
|
|
84522
|
+
if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasSyntacticModifiers(node)) {
|
|
84508
84523
|
grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
|
|
84509
84524
|
}
|
|
84510
84525
|
if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0 /* ES3 */) {
|
|
@@ -154205,6 +154220,74 @@ var ts;
|
|
|
154205
154220
|
})(ts || (ts = {}));
|
|
154206
154221
|
/* @internal */
|
|
154207
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;
|
|
154208
154291
|
(function (ts) {
|
|
154209
154292
|
var codefix;
|
|
154210
154293
|
(function (codefix) {
|
|
@@ -156772,6 +156855,7 @@ var ts;
|
|
|
156772
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);
|
|
156773
156856
|
}
|
|
156774
156857
|
function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
|
|
156858
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156775
156859
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
|
|
156776
156860
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156777
156861
|
}
|
|
@@ -156801,6 +156885,7 @@ var ts;
|
|
|
156801
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);
|
|
156802
156886
|
}
|
|
156803
156887
|
function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
|
|
156888
|
+
ts.suppressLeadingAndTrailingTrivia(propertyDeclaration);
|
|
156804
156889
|
var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
|
|
156805
156890
|
changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
|
|
156806
156891
|
}
|
|
@@ -157724,20 +157809,22 @@ var ts;
|
|
|
157724
157809
|
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
157725
157810
|
return { convertTo: 0 /* Named */, import: importClause.namedBindings };
|
|
157726
157811
|
}
|
|
157727
|
-
var
|
|
157728
|
-
var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
|
|
157729
|
-
&& isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
|
|
157812
|
+
var shouldUseDefault = getShouldUseDefault(context.program, importClause);
|
|
157730
157813
|
return shouldUseDefault
|
|
157731
157814
|
? { convertTo: 1 /* Default */, import: importClause.namedBindings }
|
|
157732
157815
|
: { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
|
|
157733
157816
|
}
|
|
157817
|
+
function getShouldUseDefault(program, importClause) {
|
|
157818
|
+
return ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())
|
|
157819
|
+
&& isExportEqualsModule(importClause.parent.moduleSpecifier, program.getTypeChecker());
|
|
157820
|
+
}
|
|
157734
157821
|
function doChange(sourceFile, program, changes, info) {
|
|
157735
157822
|
var checker = program.getTypeChecker();
|
|
157736
157823
|
if (info.convertTo === 0 /* Named */) {
|
|
157737
157824
|
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
157738
157825
|
}
|
|
157739
157826
|
else {
|
|
157740
|
-
doChangeNamedToNamespaceOrDefault(sourceFile,
|
|
157827
|
+
doChangeNamedToNamespaceOrDefault(sourceFile, program, changes, info.import, info.convertTo === 1 /* Default */);
|
|
157741
157828
|
}
|
|
157742
157829
|
}
|
|
157743
157830
|
function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
|
|
@@ -157787,7 +157874,9 @@ var ts;
|
|
|
157787
157874
|
function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
|
|
157788
157875
|
return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
|
|
157789
157876
|
}
|
|
157790
|
-
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();
|
|
157791
157880
|
var importDecl = toConvert.parent.parent;
|
|
157792
157881
|
var moduleSpecifier = importDecl.moduleSpecifier;
|
|
157793
157882
|
var toConvertSymbols = new ts.Set();
|
|
@@ -157848,6 +157937,7 @@ var ts;
|
|
|
157848
157937
|
changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
|
|
157849
157938
|
}
|
|
157850
157939
|
}
|
|
157940
|
+
refactor.doChangeNamedToNamespaceOrDefault = doChangeNamedToNamespaceOrDefault;
|
|
157851
157941
|
function isExportEqualsModule(moduleSpecifier, checker) {
|
|
157852
157942
|
var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
|
|
157853
157943
|
if (!externalModule)
|
|
@@ -159248,7 +159338,9 @@ var ts;
|
|
|
159248
159338
|
var checker = context.program.getTypeChecker();
|
|
159249
159339
|
// Make a unique name for the extracted variable
|
|
159250
159340
|
var file = scope.getSourceFile();
|
|
159251
|
-
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);
|
|
159252
159344
|
var isJS = ts.isInJSFile(scope);
|
|
159253
159345
|
var variableType = isJS || !checker.isContextSensitive(node)
|
|
159254
159346
|
? undefined
|
|
@@ -163015,10 +163107,12 @@ var ts;
|
|
|
163015
163107
|
this.fileNameToEntry = new ts.Map();
|
|
163016
163108
|
// Initialize the list with the root file names
|
|
163017
163109
|
var rootFileNames = host.getScriptFileNames();
|
|
163110
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("session" /* Session */, "initializeHostCache", { count: rootFileNames.length });
|
|
163018
163111
|
for (var _i = 0, rootFileNames_1 = rootFileNames; _i < rootFileNames_1.length; _i++) {
|
|
163019
163112
|
var fileName = rootFileNames_1[_i];
|
|
163020
163113
|
this.createEntry(fileName, ts.toPath(fileName, this.currentDirectory, getCanonicalFileName));
|
|
163021
163114
|
}
|
|
163115
|
+
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
163022
163116
|
}
|
|
163023
163117
|
HostCache.prototype.createEntry = function (fileName, path) {
|
|
163024
163118
|
var entry;
|