typescript 5.5.0-dev.20240521 → 5.5.0-dev.20240523
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 +130 -101
- package/lib/typescript.d.ts +29 -0
- package/lib/typescript.js +430 -136
- package/package.json +4 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20240523`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -7508,6 +7508,8 @@ var Diagnostics = {
|
|
|
7508
7508
|
Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit: diag(9035, 1 /* Error */, "Add_satisfies_and_a_type_assertion_to_this_expression_satisfies_T_as_T_to_make_the_type_explicit_9035", "Add satisfies and a type assertion to this expression (satisfies T as T) to make the type explicit."),
|
|
7509
7509
|
Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it: diag(9036, 1 /* Error */, "Move_the_expression_in_default_export_to_a_variable_and_add_a_type_annotation_to_it_9036", "Move the expression in default export to a variable and add a type annotation to it."),
|
|
7510
7510
|
Default_exports_can_t_be_inferred_with_isolatedDeclarations: diag(9037, 1 /* Error */, "Default_exports_can_t_be_inferred_with_isolatedDeclarations_9037", "Default exports can't be inferred with --isolatedDeclarations."),
|
|
7511
|
+
Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations: diag(9038, 1 /* Error */, "Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations_9038", "Computed property names on class or object literals cannot be inferred with --isolatedDeclarations."),
|
|
7512
|
+
Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations: diag(9039, 1 /* Error */, "Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations_9039", "Type containing private name '{0}' can't be used with --isolatedDeclarations."),
|
|
7511
7513
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17e3, 1 /* Error */, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
|
|
7512
7514
|
JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, 1 /* Error */, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."),
|
|
7513
7515
|
Expected_corresponding_JSX_closing_tag_for_0: diag(17002, 1 /* Error */, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."),
|
|
@@ -11521,7 +11523,7 @@ function getTextOfJSDocComment(comment) {
|
|
|
11521
11523
|
function formatJSDocLink(link) {
|
|
11522
11524
|
const kind = link.kind === 324 /* JSDocLink */ ? "link" : link.kind === 325 /* JSDocLinkCode */ ? "linkcode" : "linkplain";
|
|
11523
11525
|
const name = link.name ? entityNameToString(link.name) : "";
|
|
11524
|
-
const space = link.name && link.text.startsWith("://") ? "" : " ";
|
|
11526
|
+
const space = link.name && (link.text === "" || link.text.startsWith("://")) ? "" : " ";
|
|
11525
11527
|
return `{@${kind} ${name}${space}${link.text}}`;
|
|
11526
11528
|
}
|
|
11527
11529
|
function getEffectiveTypeParameterDeclarations(node) {
|
|
@@ -16877,6 +16879,9 @@ function getDeclarationModifierFlagsFromSymbol(s, isWrite = false) {
|
|
|
16877
16879
|
}
|
|
16878
16880
|
return 0;
|
|
16879
16881
|
}
|
|
16882
|
+
function skipAlias(symbol, checker) {
|
|
16883
|
+
return symbol.flags & 2097152 /* Alias */ ? checker.getAliasedSymbol(symbol) : symbol;
|
|
16884
|
+
}
|
|
16880
16885
|
function getCombinedLocalAndExportSymbolFlags(symbol) {
|
|
16881
16886
|
return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
|
|
16882
16887
|
}
|
|
@@ -44085,7 +44090,7 @@ function tryGetModuleSpecifiersFromCacheWorker(moduleSymbol, importingSourceFile
|
|
|
44085
44090
|
}
|
|
44086
44091
|
const cache = (_a = host.getModuleSpecifierCache) == null ? void 0 : _a.call(host);
|
|
44087
44092
|
const cached = cache == null ? void 0 : cache.get(importingSourceFile.path, moduleSourceFile.path, userPreferences, options);
|
|
44088
|
-
return [cached == null ? void 0 : cached.moduleSpecifiers, moduleSourceFile, cached == null ? void 0 : cached.modulePaths, cache];
|
|
44093
|
+
return [cached == null ? void 0 : cached.kind, cached == null ? void 0 : cached.moduleSpecifiers, moduleSourceFile, cached == null ? void 0 : cached.modulePaths, cache];
|
|
44089
44094
|
}
|
|
44090
44095
|
function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}) {
|
|
44091
44096
|
return getModuleSpecifiersWithCacheInfo(
|
|
@@ -44103,16 +44108,16 @@ function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSo
|
|
|
44103
44108
|
function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
|
|
44104
44109
|
let computedWithoutCache = false;
|
|
44105
44110
|
const ambient = tryGetModuleNameFromAmbientModule(moduleSymbol, checker);
|
|
44106
|
-
if (ambient) return { moduleSpecifiers: [ambient], computedWithoutCache };
|
|
44107
|
-
let [specifiers, moduleSourceFile, modulePaths, cache] = tryGetModuleSpecifiersFromCacheWorker(
|
|
44111
|
+
if (ambient) return { kind: "ambient", moduleSpecifiers: [ambient], computedWithoutCache };
|
|
44112
|
+
let [kind, specifiers, moduleSourceFile, modulePaths, cache] = tryGetModuleSpecifiersFromCacheWorker(
|
|
44108
44113
|
moduleSymbol,
|
|
44109
44114
|
importingSourceFile,
|
|
44110
44115
|
host,
|
|
44111
44116
|
userPreferences,
|
|
44112
44117
|
options
|
|
44113
44118
|
);
|
|
44114
|
-
if (specifiers) return { moduleSpecifiers: specifiers, computedWithoutCache };
|
|
44115
|
-
if (!moduleSourceFile) return { moduleSpecifiers: emptyArray, computedWithoutCache };
|
|
44119
|
+
if (specifiers) return { kind, moduleSpecifiers: specifiers, computedWithoutCache };
|
|
44120
|
+
if (!moduleSourceFile) return { kind: void 0, moduleSpecifiers: emptyArray, computedWithoutCache };
|
|
44116
44121
|
computedWithoutCache = true;
|
|
44117
44122
|
modulePaths || (modulePaths = getAllModulePathsWorker(getInfo(importingSourceFile.fileName, host), moduleSourceFile.originalFileName, host, compilerOptions, options));
|
|
44118
44123
|
const result = computeModuleSpecifiers(
|
|
@@ -44124,8 +44129,8 @@ function getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions
|
|
|
44124
44129
|
options,
|
|
44125
44130
|
forAutoImport
|
|
44126
44131
|
);
|
|
44127
|
-
cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, modulePaths, result);
|
|
44128
|
-
return
|
|
44132
|
+
cache == null ? void 0 : cache.set(importingSourceFile.path, moduleSourceFile.path, userPreferences, options, result.kind, modulePaths, result.moduleSpecifiers);
|
|
44133
|
+
return result;
|
|
44129
44134
|
}
|
|
44130
44135
|
function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFile, host, userPreferences, options = {}, forAutoImport) {
|
|
44131
44136
|
const info = getInfo(importingSourceFile.fileName, host);
|
|
@@ -44144,8 +44149,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
|
|
|
44144
44149
|
}
|
|
44145
44150
|
));
|
|
44146
44151
|
if (existingSpecifier) {
|
|
44147
|
-
|
|
44148
|
-
return moduleSpecifiers;
|
|
44152
|
+
return { kind: void 0, moduleSpecifiers: [existingSpecifier], computedWithoutCache: true };
|
|
44149
44153
|
}
|
|
44150
44154
|
const importedFileIsInNodeModules = some(modulePaths, (p) => p.isInNodeModules);
|
|
44151
44155
|
let nodeModulesSpecifiers;
|
|
@@ -44166,7 +44170,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
|
|
|
44166
44170
|
) : void 0;
|
|
44167
44171
|
nodeModulesSpecifiers = append(nodeModulesSpecifiers, specifier);
|
|
44168
44172
|
if (specifier && modulePath.isRedirect) {
|
|
44169
|
-
return nodeModulesSpecifiers;
|
|
44173
|
+
return { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true };
|
|
44170
44174
|
}
|
|
44171
44175
|
if (!specifier) {
|
|
44172
44176
|
const local = getLocalModuleSpecifier(
|
|
@@ -44195,7 +44199,7 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
|
|
|
44195
44199
|
}
|
|
44196
44200
|
}
|
|
44197
44201
|
}
|
|
44198
|
-
return (pathsSpecifiers == null ? void 0 : pathsSpecifiers.length) ? pathsSpecifiers : (redirectPathsSpecifiers == null ? void 0 : redirectPathsSpecifiers.length) ? redirectPathsSpecifiers : (nodeModulesSpecifiers == null ? void 0 : nodeModulesSpecifiers.length) ? nodeModulesSpecifiers : Debug.checkDefined(relativeSpecifiers);
|
|
44202
|
+
return (pathsSpecifiers == null ? void 0 : pathsSpecifiers.length) ? { kind: "paths", moduleSpecifiers: pathsSpecifiers, computedWithoutCache: true } : (redirectPathsSpecifiers == null ? void 0 : redirectPathsSpecifiers.length) ? { kind: "redirect", moduleSpecifiers: redirectPathsSpecifiers, computedWithoutCache: true } : (nodeModulesSpecifiers == null ? void 0 : nodeModulesSpecifiers.length) ? { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true } : { kind: "relative", moduleSpecifiers: Debug.checkDefined(relativeSpecifiers), computedWithoutCache: true };
|
|
44199
44203
|
}
|
|
44200
44204
|
function getInfo(importingSourceFileName, host) {
|
|
44201
44205
|
importingSourceFileName = getNormalizedAbsolutePath(importingSourceFileName, host.getCurrentDirectory());
|
|
@@ -45051,7 +45055,6 @@ function createTypeChecker(host) {
|
|
|
45051
45055
|
var syntacticNodeBuilder = createSyntacticTypeNodeBuilder(compilerOptions, {
|
|
45052
45056
|
isEntityNameVisible,
|
|
45053
45057
|
isExpandoFunctionDeclaration,
|
|
45054
|
-
isNonNarrowedBindableName,
|
|
45055
45058
|
getAllAccessorDeclarations: getAllAccessorDeclarationsForDeclaration,
|
|
45056
45059
|
requiresAddingImplicitUndefined,
|
|
45057
45060
|
isUndefinedIdentifierExpression(node) {
|
|
@@ -46090,8 +46093,8 @@ function createTypeChecker(host) {
|
|
|
46090
46093
|
void 0
|
|
46091
46094
|
);
|
|
46092
46095
|
}
|
|
46093
|
-
function getEmitResolver(sourceFile, cancellationToken2) {
|
|
46094
|
-
getDiagnostics(sourceFile, cancellationToken2);
|
|
46096
|
+
function getEmitResolver(sourceFile, cancellationToken2, skipDiagnostics) {
|
|
46097
|
+
if (!skipDiagnostics) getDiagnostics(sourceFile, cancellationToken2);
|
|
46095
46098
|
return emitResolver;
|
|
46096
46099
|
}
|
|
46097
46100
|
function lookupOrIssueError(location, message, ...args) {
|
|
@@ -49019,8 +49022,15 @@ function createTypeChecker(host) {
|
|
|
49019
49022
|
).accessibility === 0 /* Accessible */) {
|
|
49020
49023
|
return { accessibility: 0 /* Accessible */ };
|
|
49021
49024
|
}
|
|
49022
|
-
|
|
49023
|
-
|
|
49025
|
+
if (!symbol) {
|
|
49026
|
+
return {
|
|
49027
|
+
accessibility: 3 /* NotResolved */,
|
|
49028
|
+
errorSymbolName: getTextOfNode(firstIdentifier),
|
|
49029
|
+
errorNode: firstIdentifier
|
|
49030
|
+
};
|
|
49031
|
+
}
|
|
49032
|
+
return hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) || {
|
|
49033
|
+
accessibility: 1 /* NotAccessible */,
|
|
49024
49034
|
errorSymbolName: getTextOfNode(firstIdentifier),
|
|
49025
49035
|
errorNode: firstIdentifier
|
|
49026
49036
|
};
|
|
@@ -49219,6 +49229,7 @@ function createTypeChecker(host) {
|
|
|
49219
49229
|
return result;
|
|
49220
49230
|
}
|
|
49221
49231
|
}
|
|
49232
|
+
context.tracker.reportInferenceFallback(existing);
|
|
49222
49233
|
return void 0;
|
|
49223
49234
|
}
|
|
49224
49235
|
function symbolToNode(symbol, context, meaning) {
|
|
@@ -51254,6 +51265,9 @@ function createTypeChecker(host) {
|
|
|
51254
51265
|
symAtLocation === void 0 && sym !== void 0 || // If the symbol is found both in declaration scope and in current scope then it shoudl point to the same reference
|
|
51255
51266
|
symAtLocation && sym && !getSymbolIfSameReference(getExportSymbolOfValueSymbolIfExported(symAtLocation), sym)
|
|
51256
51267
|
) {
|
|
51268
|
+
if (symAtLocation !== unknownSymbol) {
|
|
51269
|
+
context.tracker.reportInferenceFallback(node);
|
|
51270
|
+
}
|
|
51257
51271
|
introducesError = true;
|
|
51258
51272
|
return { introducesError, node, sym };
|
|
51259
51273
|
}
|
|
@@ -51272,6 +51286,7 @@ function createTypeChecker(host) {
|
|
|
51272
51286
|
/*shouldComputeAliasesToMakeVisible*/
|
|
51273
51287
|
false
|
|
51274
51288
|
).accessibility !== 0 /* Accessible */) {
|
|
51289
|
+
context.tracker.reportInferenceFallback(node);
|
|
51275
51290
|
introducesError = true;
|
|
51276
51291
|
} else {
|
|
51277
51292
|
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
|
@@ -84966,22 +84981,6 @@ function createTypeChecker(host) {
|
|
|
84966
84981
|
}
|
|
84967
84982
|
return false;
|
|
84968
84983
|
}
|
|
84969
|
-
function isNonNarrowedBindableName(node) {
|
|
84970
|
-
if (!hasBindableName(node.parent)) {
|
|
84971
|
-
return false;
|
|
84972
|
-
}
|
|
84973
|
-
const expression = node.expression;
|
|
84974
|
-
if (!isEntityNameExpression(expression)) {
|
|
84975
|
-
return true;
|
|
84976
|
-
}
|
|
84977
|
-
const type = getTypeOfExpression(expression);
|
|
84978
|
-
const symbol = getSymbolAtLocation(expression);
|
|
84979
|
-
if (!symbol) {
|
|
84980
|
-
return false;
|
|
84981
|
-
}
|
|
84982
|
-
const declaredType = getTypeOfSymbol(symbol);
|
|
84983
|
-
return declaredType === type;
|
|
84984
|
-
}
|
|
84985
84984
|
function literalTypeToNode(type, enclosing, tracker) {
|
|
84986
84985
|
const enumResult = type.flags & 1056 /* EnumLike */ ? nodeBuilder.symbolToExpression(
|
|
84987
84986
|
type.symbol,
|
|
@@ -85100,7 +85099,6 @@ function createTypeChecker(host) {
|
|
|
85100
85099
|
return node && getExternalModuleFileFromDeclaration(node);
|
|
85101
85100
|
},
|
|
85102
85101
|
isLiteralConstDeclaration,
|
|
85103
|
-
isNonNarrowedBindableName,
|
|
85104
85102
|
isLateBound: (nodeIn) => {
|
|
85105
85103
|
const node = getParseTreeNode(nodeIn, isDeclaration);
|
|
85106
85104
|
const symbol = node && getSymbolOfDeclaration(node);
|
|
@@ -110020,7 +110018,7 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110020
110018
|
[260 /* VariableDeclaration */]: Diagnostics.Variable_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
110021
110019
|
[172 /* PropertyDeclaration */]: Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
110022
110020
|
[171 /* PropertySignature */]: Diagnostics.Property_must_have_an_explicit_type_annotation_with_isolatedDeclarations,
|
|
110023
|
-
[167 /* ComputedPropertyName */]: Diagnostics.
|
|
110021
|
+
[167 /* ComputedPropertyName */]: Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations,
|
|
110024
110022
|
[305 /* SpreadAssignment */]: Diagnostics.Objects_that_contain_spread_assignments_can_t_be_inferred_with_isolatedDeclarations,
|
|
110025
110023
|
[304 /* ShorthandPropertyAssignment */]: Diagnostics.Objects_that_contain_shorthand_properties_can_t_be_inferred_with_isolatedDeclarations,
|
|
110026
110024
|
[209 /* ArrayLiteralExpression */]: Diagnostics.Only_const_arrays_can_be_inferred_with_isolatedDeclarations,
|
|
@@ -110033,6 +110031,9 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110033
110031
|
if (heritageClause) {
|
|
110034
110032
|
return createDiagnosticForNode(node, Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations);
|
|
110035
110033
|
}
|
|
110034
|
+
if ((isPartOfTypeNode(node) || isTypeQueryNode(node.parent)) && (isEntityName(node) || isEntityNameExpression(node))) {
|
|
110035
|
+
return createEntityInTypeNodeError(node);
|
|
110036
|
+
}
|
|
110036
110037
|
Debug.type(node);
|
|
110037
110038
|
switch (node.kind) {
|
|
110038
110039
|
case 177 /* GetAccessor */:
|
|
@@ -110068,8 +110069,13 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110068
110069
|
}
|
|
110069
110070
|
}
|
|
110070
110071
|
function findNearestDeclaration(node) {
|
|
110071
|
-
const result = findAncestor(node, (n) => isExportAssignment(n) ||
|
|
110072
|
-
return
|
|
110072
|
+
const result = findAncestor(node, (n) => isExportAssignment(n) || isStatement(n) || isVariableDeclaration(n) || isPropertyDeclaration(n) || isParameter(n));
|
|
110073
|
+
if (!result) return void 0;
|
|
110074
|
+
if (isExportAssignment(result)) return result;
|
|
110075
|
+
if (isReturnStatement(result)) {
|
|
110076
|
+
return findAncestor(result, (n) => isFunctionLikeDeclaration(n) && !isConstructorDeclaration(n));
|
|
110077
|
+
}
|
|
110078
|
+
return isStatement(result) ? void 0 : result;
|
|
110073
110079
|
}
|
|
110074
110080
|
function createAccessorTypeError(node) {
|
|
110075
110081
|
const { getAccessor, setAccessor } = getAllAccessorDeclarations(node.symbol.declarations, node);
|
|
@@ -110083,11 +110089,10 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110083
110089
|
}
|
|
110084
110090
|
return diag2;
|
|
110085
110091
|
}
|
|
110086
|
-
function
|
|
110087
|
-
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110092
|
+
function addParentDeclarationRelatedInfo(node, diag2) {
|
|
110088
110093
|
const parentDeclaration = findNearestDeclaration(node);
|
|
110089
110094
|
if (parentDeclaration) {
|
|
110090
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110095
|
+
const targetStr = isExportAssignment(parentDeclaration) || !parentDeclaration.name ? "" : getTextOfNode(
|
|
110091
110096
|
parentDeclaration.name,
|
|
110092
110097
|
/*includeTrivia*/
|
|
110093
110098
|
false
|
|
@@ -110096,30 +110101,19 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110096
110101
|
}
|
|
110097
110102
|
return diag2;
|
|
110098
110103
|
}
|
|
110104
|
+
function createObjectLiteralError(node) {
|
|
110105
|
+
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110106
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
110107
|
+
return diag2;
|
|
110108
|
+
}
|
|
110099
110109
|
function createArrayLiteralError(node) {
|
|
110100
110110
|
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110101
|
-
|
|
110102
|
-
if (parentDeclaration) {
|
|
110103
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110104
|
-
parentDeclaration.name,
|
|
110105
|
-
/*includeTrivia*/
|
|
110106
|
-
false
|
|
110107
|
-
);
|
|
110108
|
-
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
110109
|
-
}
|
|
110111
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
110110
110112
|
return diag2;
|
|
110111
110113
|
}
|
|
110112
110114
|
function createReturnTypeError(node) {
|
|
110113
110115
|
const diag2 = createDiagnosticForNode(node, errorByDeclarationKind[node.kind]);
|
|
110114
|
-
|
|
110115
|
-
if (parentDeclaration) {
|
|
110116
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110117
|
-
parentDeclaration.name,
|
|
110118
|
-
/*includeTrivia*/
|
|
110119
|
-
false
|
|
110120
|
-
);
|
|
110121
|
-
addRelatedInfo(diag2, createDiagnosticForNode(parentDeclaration, relatedSuggestionByDeclarationKind[parentDeclaration.kind], targetStr));
|
|
110122
|
-
}
|
|
110116
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
110123
110117
|
addRelatedInfo(diag2, createDiagnosticForNode(node, relatedSuggestionByDeclarationKind[node.kind]));
|
|
110124
110118
|
return diag2;
|
|
110125
110119
|
}
|
|
@@ -110157,11 +110151,20 @@ function createGetIsolatedDeclarationErrors(resolver) {
|
|
|
110157
110151
|
function createClassExpressionError(node) {
|
|
110158
110152
|
return createExpressionError(node, Diagnostics.Inference_from_class_expressions_is_not_supported_with_isolatedDeclarations);
|
|
110159
110153
|
}
|
|
110154
|
+
function createEntityInTypeNodeError(node) {
|
|
110155
|
+
const diag2 = createDiagnosticForNode(node, Diagnostics.Type_containing_private_name_0_can_t_be_used_with_isolatedDeclarations, getTextOfNode(
|
|
110156
|
+
node,
|
|
110157
|
+
/*includeTrivia*/
|
|
110158
|
+
false
|
|
110159
|
+
));
|
|
110160
|
+
addParentDeclarationRelatedInfo(node, diag2);
|
|
110161
|
+
return diag2;
|
|
110162
|
+
}
|
|
110160
110163
|
function createExpressionError(node, diagnosticMessage) {
|
|
110161
110164
|
const parentDeclaration = findNearestDeclaration(node);
|
|
110162
110165
|
let diag2;
|
|
110163
110166
|
if (parentDeclaration) {
|
|
110164
|
-
const targetStr = isExportAssignment(parentDeclaration) ? "" : getTextOfNode(
|
|
110167
|
+
const targetStr = isExportAssignment(parentDeclaration) || !parentDeclaration.name ? "" : getTextOfNode(
|
|
110165
110168
|
parentDeclaration.name,
|
|
110166
110169
|
/*includeTrivia*/
|
|
110167
110170
|
false
|
|
@@ -110886,8 +110889,11 @@ function transformDeclarations(context) {
|
|
|
110886
110889
|
if (shouldStripInternal(input)) return;
|
|
110887
110890
|
if (isDeclaration(input)) {
|
|
110888
110891
|
if (isDeclarationAndNotVisible(input)) return;
|
|
110889
|
-
if (hasDynamicName(input)
|
|
110890
|
-
if (isolatedDeclarations && isClassDeclaration(input.parent)
|
|
110892
|
+
if (hasDynamicName(input)) {
|
|
110893
|
+
if (isolatedDeclarations && (isClassDeclaration(input.parent) || isObjectLiteralExpression(input.parent))) {
|
|
110894
|
+
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_property_names_on_class_or_object_literals_cannot_be_inferred_with_isolatedDeclarations));
|
|
110895
|
+
}
|
|
110896
|
+
if (isolatedDeclarations && (isInterfaceDeclaration(input.parent) || isTypeLiteralNode(input.parent)) && !isEntityNameExpression(input.name.expression)) {
|
|
110891
110897
|
context.addDiagnostic(createDiagnosticForNode(input, Diagnostics.Computed_properties_must_be_number_or_string_literals_variables_or_dotted_expressions_with_isolatedDeclarations));
|
|
110892
110898
|
}
|
|
110893
110899
|
if (!isEntityNameExpression(input.name.expression)) {
|
|
@@ -112460,6 +112466,9 @@ function getFirstProjectOutput(configFile, ignoreCase) {
|
|
|
112460
112466
|
if (buildInfoPath) return buildInfoPath;
|
|
112461
112467
|
return Debug.fail(`project ${configFile.options.configFilePath} expected to have at least one output`);
|
|
112462
112468
|
}
|
|
112469
|
+
function emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit) {
|
|
112470
|
+
return !!forceDtsEmit && !!emitOnly;
|
|
112471
|
+
}
|
|
112463
112472
|
function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, declarationTransformers }, emitOnly, onlyBuildInfo, forceDtsEmit) {
|
|
112464
112473
|
var compilerOptions = host.getCompilerOptions();
|
|
112465
112474
|
var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap || getAreDeclarationMapsEnabled(compilerOptions) ? [] : void 0;
|
|
@@ -112577,7 +112586,7 @@ function emitFiles(resolver, host, targetSourceFile, { scriptTransformers, decla
|
|
|
112577
112586
|
const sourceFiles = isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
|
|
112578
112587
|
const filesForEmit = forceDtsEmit ? sourceFiles : filter(sourceFiles, isSourceFileNotJson);
|
|
112579
112588
|
const inputListOrBundle = compilerOptions.outFile ? [factory.createBundle(filesForEmit)] : filesForEmit;
|
|
112580
|
-
if (emitOnly && !getEmitDeclarations(compilerOptions) || compilerOptions.noCheck) {
|
|
112589
|
+
if (emitOnly && !getEmitDeclarations(compilerOptions) || compilerOptions.noCheck || emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit)) {
|
|
112581
112590
|
filesForEmit.forEach(collectLinkedAliases);
|
|
112582
112591
|
}
|
|
112583
112592
|
const declarationTransform = transformNodes(
|
|
@@ -112817,7 +112826,6 @@ var notImplementedResolver = {
|
|
|
112817
112826
|
isArgumentsLocalBinding: notImplemented,
|
|
112818
112827
|
getExternalModuleFileFromDeclaration: notImplemented,
|
|
112819
112828
|
isLiteralConstDeclaration: notImplemented,
|
|
112820
|
-
isNonNarrowedBindableName: notImplemented,
|
|
112821
112829
|
getJsxFactoryEntity: notImplemented,
|
|
112822
112830
|
getJsxFragmentFactoryEntity: notImplemented,
|
|
112823
112831
|
isBindingCapturedByNode: notImplemented,
|
|
@@ -119513,17 +119521,25 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119513
119521
|
const result = handleNoEmitOptions(program2, sourceFile, writeFileCallback, cancellationToken);
|
|
119514
119522
|
if (result) return result;
|
|
119515
119523
|
}
|
|
119516
|
-
const
|
|
119524
|
+
const typeChecker2 = getTypeChecker();
|
|
119525
|
+
const emitResolver = typeChecker2.getEmitResolver(
|
|
119526
|
+
options.outFile ? void 0 : sourceFile,
|
|
119527
|
+
cancellationToken,
|
|
119528
|
+
emitResolverSkipsTypeChecking(emitOnly, forceDtsEmit)
|
|
119529
|
+
);
|
|
119517
119530
|
mark("beforeEmit");
|
|
119518
|
-
const emitResult =
|
|
119519
|
-
|
|
119520
|
-
|
|
119521
|
-
|
|
119522
|
-
|
|
119523
|
-
|
|
119524
|
-
|
|
119525
|
-
|
|
119526
|
-
|
|
119531
|
+
const emitResult = typeChecker2.runWithCancellationToken(
|
|
119532
|
+
cancellationToken,
|
|
119533
|
+
() => emitFiles(
|
|
119534
|
+
emitResolver,
|
|
119535
|
+
getEmitHost(writeFileCallback),
|
|
119536
|
+
sourceFile,
|
|
119537
|
+
getTransformers(options, customTransformers, emitOnly),
|
|
119538
|
+
emitOnly,
|
|
119539
|
+
/*onlyBuildInfo*/
|
|
119540
|
+
false,
|
|
119541
|
+
forceDtsEmit
|
|
119542
|
+
)
|
|
119527
119543
|
);
|
|
119528
119544
|
mark("afterEmit");
|
|
119529
119545
|
measure("Emit", "beforeEmit", "afterEmit");
|
|
@@ -122474,7 +122490,7 @@ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken
|
|
|
122474
122490
|
host
|
|
122475
122491
|
);
|
|
122476
122492
|
}
|
|
122477
|
-
function handleDtsMayChangeOf(state, path, cancellationToken, host) {
|
|
122493
|
+
function handleDtsMayChangeOf(state, path, invalidateJsFiles, cancellationToken, host) {
|
|
122478
122494
|
removeSemanticDiagnosticsOf(state, path);
|
|
122479
122495
|
if (!state.changedFilesSet.has(path)) {
|
|
122480
122496
|
const program = Debug.checkDefined(state.program);
|
|
@@ -122489,7 +122505,9 @@ function handleDtsMayChangeOf(state, path, cancellationToken, host) {
|
|
|
122489
122505
|
/*useFileVersionAsSignature*/
|
|
122490
122506
|
true
|
|
122491
122507
|
);
|
|
122492
|
-
if (
|
|
122508
|
+
if (invalidateJsFiles) {
|
|
122509
|
+
addToAffectedFilesPendingEmit(state, path, getBuilderFileEmit(state.compilerOptions));
|
|
122510
|
+
} else if (getEmitDeclarations(state.compilerOptions)) {
|
|
122493
122511
|
addToAffectedFilesPendingEmit(state, path, state.compilerOptions.declarationMap ? 24 /* AllDts */ : 8 /* Dts */);
|
|
122494
122512
|
}
|
|
122495
122513
|
}
|
|
@@ -122508,7 +122526,7 @@ function isChangedSignature(state, path) {
|
|
|
122508
122526
|
const newSignature = Debug.checkDefined(state.fileInfos.get(path)).signature;
|
|
122509
122527
|
return newSignature !== oldSignature;
|
|
122510
122528
|
}
|
|
122511
|
-
function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host) {
|
|
122529
|
+
function handleDtsMayChangeOfGlobalScope(state, filePath, invalidateJsFiles, cancellationToken, host) {
|
|
122512
122530
|
var _a;
|
|
122513
122531
|
if (!((_a = state.fileInfos.get(filePath)) == null ? void 0 : _a.affectsGlobalScope)) return false;
|
|
122514
122532
|
BuilderState.getAllFilesExcludingDefaultLibraryFile(
|
|
@@ -122520,6 +122538,7 @@ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, hos
|
|
|
122520
122538
|
(file) => handleDtsMayChangeOf(
|
|
122521
122539
|
state,
|
|
122522
122540
|
file.resolvedPath,
|
|
122541
|
+
invalidateJsFiles,
|
|
122523
122542
|
cancellationToken,
|
|
122524
122543
|
host
|
|
122525
122544
|
)
|
|
@@ -122528,7 +122547,7 @@ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, hos
|
|
|
122528
122547
|
return true;
|
|
122529
122548
|
}
|
|
122530
122549
|
function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, host) {
|
|
122531
|
-
var _a;
|
|
122550
|
+
var _a, _b;
|
|
122532
122551
|
if (!state.referencedMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) return;
|
|
122533
122552
|
if (!isChangedSignature(state, affectedFile.resolvedPath)) return;
|
|
122534
122553
|
if (getIsolatedModules(state.compilerOptions)) {
|
|
@@ -122539,8 +122558,22 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
|
|
|
122539
122558
|
const currentPath = queue.pop();
|
|
122540
122559
|
if (!seenFileNamesMap.has(currentPath)) {
|
|
122541
122560
|
seenFileNamesMap.set(currentPath, true);
|
|
122542
|
-
if (handleDtsMayChangeOfGlobalScope(
|
|
122543
|
-
|
|
122561
|
+
if (handleDtsMayChangeOfGlobalScope(
|
|
122562
|
+
state,
|
|
122563
|
+
currentPath,
|
|
122564
|
+
/*invalidateJsFiles*/
|
|
122565
|
+
false,
|
|
122566
|
+
cancellationToken,
|
|
122567
|
+
host
|
|
122568
|
+
)) return;
|
|
122569
|
+
handleDtsMayChangeOf(
|
|
122570
|
+
state,
|
|
122571
|
+
currentPath,
|
|
122572
|
+
/*invalidateJsFiles*/
|
|
122573
|
+
false,
|
|
122574
|
+
cancellationToken,
|
|
122575
|
+
host
|
|
122576
|
+
);
|
|
122544
122577
|
if (isChangedSignature(state, currentPath)) {
|
|
122545
122578
|
const currentSourceFile = Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
|
|
122546
122579
|
queue.push(...BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
|
|
@@ -122549,27 +122582,38 @@ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile
|
|
|
122549
122582
|
}
|
|
122550
122583
|
}
|
|
122551
122584
|
const seenFileAndExportsOfFile = /* @__PURE__ */ new Set();
|
|
122552
|
-
(_a =
|
|
122553
|
-
|
|
122585
|
+
const invalidateJsFiles = !!((_a = affectedFile.symbol) == null ? void 0 : _a.exports) && !!forEachEntry(
|
|
122586
|
+
affectedFile.symbol.exports,
|
|
122587
|
+
(exported) => {
|
|
122588
|
+
if ((exported.flags & 128 /* ConstEnum */) !== 0) return true;
|
|
122589
|
+
const aliased = skipAlias(exported, state.program.getTypeChecker());
|
|
122590
|
+
if (aliased === exported) return false;
|
|
122591
|
+
return (aliased.flags & 128 /* ConstEnum */) !== 0 && some(aliased.declarations, (d) => getSourceFileOfNode(d) === affectedFile);
|
|
122592
|
+
}
|
|
122593
|
+
);
|
|
122594
|
+
(_b = state.referencedMap.getKeys(affectedFile.resolvedPath)) == null ? void 0 : _b.forEach((exportedFromPath) => {
|
|
122595
|
+
if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, invalidateJsFiles, cancellationToken, host)) return true;
|
|
122554
122596
|
const references = state.referencedMap.getKeys(exportedFromPath);
|
|
122555
122597
|
return references && forEachKey(references, (filePath) => handleDtsMayChangeOfFileAndExportsOfFile(
|
|
122556
122598
|
state,
|
|
122557
122599
|
filePath,
|
|
122600
|
+
invalidateJsFiles,
|
|
122558
122601
|
seenFileAndExportsOfFile,
|
|
122559
122602
|
cancellationToken,
|
|
122560
122603
|
host
|
|
122561
122604
|
));
|
|
122562
122605
|
});
|
|
122563
122606
|
}
|
|
122564
|
-
function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, host) {
|
|
122607
|
+
function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, invalidateJsFiles, seenFileAndExportsOfFile, cancellationToken, host) {
|
|
122565
122608
|
var _a;
|
|
122566
122609
|
if (!tryAddToSet(seenFileAndExportsOfFile, filePath)) return void 0;
|
|
122567
|
-
if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, host)) return true;
|
|
122568
|
-
handleDtsMayChangeOf(state, filePath, cancellationToken, host);
|
|
122610
|
+
if (handleDtsMayChangeOfGlobalScope(state, filePath, invalidateJsFiles, cancellationToken, host)) return true;
|
|
122611
|
+
handleDtsMayChangeOf(state, filePath, invalidateJsFiles, cancellationToken, host);
|
|
122569
122612
|
(_a = state.referencedMap.getKeys(filePath)) == null ? void 0 : _a.forEach(
|
|
122570
122613
|
(referencingFilePath) => handleDtsMayChangeOfFileAndExportsOfFile(
|
|
122571
122614
|
state,
|
|
122572
122615
|
referencingFilePath,
|
|
122616
|
+
invalidateJsFiles,
|
|
122573
122617
|
seenFileAndExportsOfFile,
|
|
122574
122618
|
cancellationToken,
|
|
122575
122619
|
host
|
|
@@ -129062,7 +129106,7 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
129062
129106
|
expression,
|
|
129063
129107
|
/*includeBigInt*/
|
|
129064
129108
|
false
|
|
129065
|
-
)
|
|
129109
|
+
)) {
|
|
129066
129110
|
context.tracker.reportInferenceFallback(prop.name);
|
|
129067
129111
|
result = false;
|
|
129068
129112
|
}
|
|
@@ -129076,21 +129120,6 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
129076
129120
|
for (const prop of objectLiteral.properties) {
|
|
129077
129121
|
Debug.assert(!isShorthandPropertyAssignment(prop) && !isSpreadAssignment(prop));
|
|
129078
129122
|
const name = prop.name;
|
|
129079
|
-
if (prop.name.kind === 167 /* ComputedPropertyName */) {
|
|
129080
|
-
if (!resolver.isNonNarrowedBindableName(prop.name)) {
|
|
129081
|
-
context.tracker.reportInferenceFallback(prop.name);
|
|
129082
|
-
} else if (isEntityNameExpression(prop.name.expression)) {
|
|
129083
|
-
const visibilityResult = resolver.isEntityNameVisible(
|
|
129084
|
-
prop.name.expression,
|
|
129085
|
-
context.enclosingDeclaration,
|
|
129086
|
-
/*shouldComputeAliasToMakeVisible*/
|
|
129087
|
-
false
|
|
129088
|
-
);
|
|
129089
|
-
if (visibilityResult.accessibility !== 0 /* Accessible */) {
|
|
129090
|
-
context.tracker.reportInferenceFallback(prop.name);
|
|
129091
|
-
}
|
|
129092
|
-
}
|
|
129093
|
-
}
|
|
129094
129123
|
switch (prop.kind) {
|
|
129095
129124
|
case 174 /* MethodDeclaration */:
|
|
129096
129125
|
canInferObjectLiteral = !!typeFromObjectLiteralMethod(prop, name, context) && canInferObjectLiteral;
|
package/lib/typescript.d.ts
CHANGED
|
@@ -121,6 +121,7 @@ declare namespace ts {
|
|
|
121
121
|
ProvideCallHierarchyOutgoingCalls = "provideCallHierarchyOutgoingCalls",
|
|
122
122
|
ProvideInlayHints = "provideInlayHints",
|
|
123
123
|
WatchChange = "watchChange",
|
|
124
|
+
MapCode = "mapCode",
|
|
124
125
|
}
|
|
125
126
|
/**
|
|
126
127
|
* A TypeScript Server message
|
|
@@ -1769,6 +1770,33 @@ declare namespace ts {
|
|
|
1769
1770
|
export interface InlayHintsResponse extends Response {
|
|
1770
1771
|
body?: InlayHintItem[];
|
|
1771
1772
|
}
|
|
1773
|
+
export interface MapCodeRequestArgs extends FileRequestArgs {
|
|
1774
|
+
/**
|
|
1775
|
+
* The files and changes to try and apply/map.
|
|
1776
|
+
*/
|
|
1777
|
+
mapping: MapCodeRequestDocumentMapping;
|
|
1778
|
+
}
|
|
1779
|
+
export interface MapCodeRequestDocumentMapping {
|
|
1780
|
+
/**
|
|
1781
|
+
* The specific code to map/insert/replace in the file.
|
|
1782
|
+
*/
|
|
1783
|
+
contents: string[];
|
|
1784
|
+
/**
|
|
1785
|
+
* Areas of "focus" to inform the code mapper with. For example, cursor
|
|
1786
|
+
* location, current selection, viewport, etc. Nested arrays denote
|
|
1787
|
+
* priority: toplevel arrays are more important than inner arrays, and
|
|
1788
|
+
* inner array priorities are based on items within that array. Items
|
|
1789
|
+
* earlier in the arrays have higher priority.
|
|
1790
|
+
*/
|
|
1791
|
+
focusLocations?: TextSpan[][];
|
|
1792
|
+
}
|
|
1793
|
+
export interface MapCodeRequest extends FileRequest {
|
|
1794
|
+
command: CommandTypes.MapCode;
|
|
1795
|
+
arguments: MapCodeRequestArgs;
|
|
1796
|
+
}
|
|
1797
|
+
export interface MapCodeResponse extends Response {
|
|
1798
|
+
body: readonly FileCodeEdits[];
|
|
1799
|
+
}
|
|
1772
1800
|
/**
|
|
1773
1801
|
* Synchronous request for semantic diagnostics of one file.
|
|
1774
1802
|
*/
|
|
@@ -3468,6 +3496,7 @@ declare namespace ts {
|
|
|
3468
3496
|
private getLinkedEditingRange;
|
|
3469
3497
|
private getDocumentHighlights;
|
|
3470
3498
|
private provideInlayHints;
|
|
3499
|
+
private mapCode;
|
|
3471
3500
|
private setCompilerOptionsForInferredProjects;
|
|
3472
3501
|
private getProjectInfo;
|
|
3473
3502
|
private getProjectInfoWorker;
|