typescript 4.7.0-dev.20220504 → 4.8.0-dev.20220507
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/lib.es2022.d.ts +1 -0
- package/lib/lib.es2022.intl.d.ts +111 -0
- package/lib/lib.es5.d.ts +2 -2
- package/lib/tsc.js +263 -91
- package/lib/tsserver.js +341 -129
- package/lib/tsserverlibrary.d.ts +1 -1
- package/lib/tsserverlibrary.js +341 -129
- package/lib/typescript.d.ts +1 -1
- package/lib/typescript.js +337 -126
- package/lib/typescriptServices.d.ts +1 -1
- package/lib/typescriptServices.js +337 -126
- package/lib/typingsInstaller.js +309 -108
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -85,11 +85,11 @@ var ts;
|
|
|
85
85
|
(function (ts) {
|
|
86
86
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
87
87
|
// If changing the text in this section, be sure to test `configurePrerelease` too.
|
|
88
|
-
ts.versionMajorMinor = "4.
|
|
88
|
+
ts.versionMajorMinor = "4.8";
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220507";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -8398,6 +8398,8 @@ var ts;
|
|
|
8398
8398
|
Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
|
|
8399
8399
|
The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
|
|
8400
8400
|
The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
|
|
8401
|
+
The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8402
|
+
The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8401
8403
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8402
8404
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
8403
8405
|
Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
@@ -8987,6 +8989,7 @@ var ts;
|
|
|
8987
8989
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
|
|
8988
8990
|
This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
|
|
8989
8991
|
Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
8992
|
+
Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4125, ts.DiagnosticCategory.Error, "Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_wi_4125", "Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
8990
8993
|
The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
|
|
8991
8994
|
Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
|
|
8992
8995
|
File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
|
|
@@ -17993,6 +17996,10 @@ var ts;
|
|
|
17993
17996
|
return indentStrings[1].length;
|
|
17994
17997
|
}
|
|
17995
17998
|
ts.getIndentSize = getIndentSize;
|
|
17999
|
+
function isNightly() {
|
|
18000
|
+
return ts.stringContains(ts.version, "-dev") || ts.stringContains(ts.version, "-insiders");
|
|
18001
|
+
}
|
|
18002
|
+
ts.isNightly = isNightly;
|
|
17996
18003
|
function createTextWriter(newLine) {
|
|
17997
18004
|
var output;
|
|
17998
18005
|
var indent;
|
|
@@ -18223,6 +18230,16 @@ var ts;
|
|
|
18223
18230
|
".d.ts" /* Dts */;
|
|
18224
18231
|
}
|
|
18225
18232
|
ts.getDeclarationEmitExtensionForPath = getDeclarationEmitExtensionForPath;
|
|
18233
|
+
/**
|
|
18234
|
+
* This function is an inverse of `getDeclarationEmitExtensionForPath`.
|
|
18235
|
+
*/
|
|
18236
|
+
function getPossibleOriginalInputExtensionForExtension(path) {
|
|
18237
|
+
return ts.fileExtensionIsOneOf(path, [".d.mts" /* Dmts */, ".mjs" /* Mjs */, ".mts" /* Mts */]) ? [".mts" /* Mts */, ".mjs" /* Mjs */] :
|
|
18238
|
+
ts.fileExtensionIsOneOf(path, [".d.cts" /* Dcts */, ".cjs" /* Cjs */, ".cts" /* Cts */]) ? [".cts" /* Cts */, ".cjs" /* Cjs */] :
|
|
18239
|
+
ts.fileExtensionIsOneOf(path, [".json.d.ts"]) ? [".json" /* Json */] :
|
|
18240
|
+
[".tsx" /* Tsx */, ".ts" /* Ts */, ".jsx" /* Jsx */, ".js" /* Js */];
|
|
18241
|
+
}
|
|
18242
|
+
ts.getPossibleOriginalInputExtensionForExtension = getPossibleOriginalInputExtensionForExtension;
|
|
18226
18243
|
function outFile(options) {
|
|
18227
18244
|
return options.outFile || options.out;
|
|
18228
18245
|
}
|
|
@@ -26172,7 +26189,7 @@ var ts;
|
|
|
26172
26189
|
return node;
|
|
26173
26190
|
}
|
|
26174
26191
|
function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
|
|
26175
|
-
var node = baseFactory.createBaseSourceFileNode(305 /* SourceFile */);
|
|
26192
|
+
var node = (source.redirectInfo ? Object.create(source.redirectInfo.redirectTarget) : baseFactory.createBaseSourceFileNode(305 /* SourceFile */));
|
|
26176
26193
|
for (var p in source) {
|
|
26177
26194
|
if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p))
|
|
26178
26195
|
continue;
|
|
@@ -31297,7 +31314,7 @@ var ts;
|
|
|
31297
31314
|
initializeState("", content, languageVersion, /*syntaxCursor*/ undefined, 1 /* JS */);
|
|
31298
31315
|
// Prime the scanner.
|
|
31299
31316
|
nextToken();
|
|
31300
|
-
var entityName = parseEntityName(/*allowReservedWords*/ true
|
|
31317
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true);
|
|
31301
31318
|
var isInvalid = token() === 1 /* EndOfFileToken */ && !parseDiagnostics.length;
|
|
31302
31319
|
clearState();
|
|
31303
31320
|
return isInvalid ? entityName : undefined;
|
|
@@ -32830,6 +32847,7 @@ var ts;
|
|
|
32830
32847
|
var startPos = scanner.getStartPos();
|
|
32831
32848
|
var result = parseListElement(kind, parseElement);
|
|
32832
32849
|
if (!result) {
|
|
32850
|
+
parsingContext = saveParsingContext;
|
|
32833
32851
|
return undefined;
|
|
32834
32852
|
}
|
|
32835
32853
|
list.push(result);
|
|
@@ -32897,7 +32915,7 @@ var ts;
|
|
|
32897
32915
|
}
|
|
32898
32916
|
return createMissingList();
|
|
32899
32917
|
}
|
|
32900
|
-
function parseEntityName(allowReservedWords,
|
|
32918
|
+
function parseEntityName(allowReservedWords, diagnosticMessage) {
|
|
32901
32919
|
var pos = getNodePos();
|
|
32902
32920
|
var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
|
|
32903
32921
|
var dotPos = getNodePos();
|
|
@@ -32908,7 +32926,7 @@ var ts;
|
|
|
32908
32926
|
break;
|
|
32909
32927
|
}
|
|
32910
32928
|
dotPos = getNodePos();
|
|
32911
|
-
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, allowPrivateIdentifiers)), pos);
|
|
32929
|
+
entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, /* allowPrivateIdentifiers */ false)), pos);
|
|
32912
32930
|
}
|
|
32913
32931
|
return entity;
|
|
32914
32932
|
}
|
|
@@ -33041,7 +33059,7 @@ var ts;
|
|
|
33041
33059
|
}
|
|
33042
33060
|
// TYPES
|
|
33043
33061
|
function parseEntityNameOfTypeReference() {
|
|
33044
|
-
return parseEntityName(/*allowReservedWords*/ true,
|
|
33062
|
+
return parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected);
|
|
33045
33063
|
}
|
|
33046
33064
|
function parseTypeArgumentsOfTypeReference() {
|
|
33047
33065
|
if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) {
|
|
@@ -33174,7 +33192,7 @@ var ts;
|
|
|
33174
33192
|
function parseTypeQuery() {
|
|
33175
33193
|
var pos = getNodePos();
|
|
33176
33194
|
parseExpected(112 /* TypeOfKeyword */);
|
|
33177
|
-
var entityName = parseEntityName(/*allowReservedWords*/ true
|
|
33195
|
+
var entityName = parseEntityName(/*allowReservedWords*/ true);
|
|
33178
33196
|
// Make sure we perform ASI to prevent parsing the next line's type arguments as part of an instantiation expression.
|
|
33179
33197
|
var typeArguments = !scanner.hasPrecedingLineBreak() ? tryParseTypeArguments() : undefined;
|
|
33180
33198
|
return finishNode(factory.createTypeQueryNode(entityName, typeArguments), pos);
|
|
@@ -34142,10 +34160,10 @@ var ts;
|
|
|
34142
34160
|
setDecoratorContext(/*val*/ false);
|
|
34143
34161
|
}
|
|
34144
34162
|
var pos = getNodePos();
|
|
34145
|
-
var expr = parseAssignmentExpressionOrHigher(
|
|
34163
|
+
var expr = parseAssignmentExpressionOrHigher();
|
|
34146
34164
|
var operatorToken;
|
|
34147
34165
|
while ((operatorToken = parseOptionalToken(27 /* CommaToken */))) {
|
|
34148
|
-
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(
|
|
34166
|
+
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
|
|
34149
34167
|
}
|
|
34150
34168
|
if (saveDecoratorContext) {
|
|
34151
34169
|
setDecoratorContext(/*val*/ true);
|
|
@@ -34153,9 +34171,9 @@ var ts;
|
|
|
34153
34171
|
return expr;
|
|
34154
34172
|
}
|
|
34155
34173
|
function parseInitializer() {
|
|
34156
|
-
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher(
|
|
34174
|
+
return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
|
|
34157
34175
|
}
|
|
34158
|
-
function parseAssignmentExpressionOrHigher(
|
|
34176
|
+
function parseAssignmentExpressionOrHigher() {
|
|
34159
34177
|
// AssignmentExpression[in,yield]:
|
|
34160
34178
|
// 1) ConditionalExpression[?in,?yield]
|
|
34161
34179
|
// 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
|
|
@@ -34181,7 +34199,7 @@ var ts;
|
|
|
34181
34199
|
// If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
|
|
34182
34200
|
// not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
|
|
34183
34201
|
// with AssignmentExpression if we see one.
|
|
34184
|
-
var arrowExpression = tryParseParenthesizedArrowFunctionExpression(
|
|
34202
|
+
var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
|
|
34185
34203
|
if (arrowExpression) {
|
|
34186
34204
|
return arrowExpression;
|
|
34187
34205
|
}
|
|
@@ -34200,7 +34218,7 @@ var ts;
|
|
|
34200
34218
|
// parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
|
|
34201
34219
|
// identifier and the current token is an arrow.
|
|
34202
34220
|
if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
|
|
34203
|
-
return parseSimpleArrowFunctionExpression(pos, expr,
|
|
34221
|
+
return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
|
|
34204
34222
|
}
|
|
34205
34223
|
// Now see if we might be in cases '2' or '3'.
|
|
34206
34224
|
// If the expression was a LHS expression, and we have an assignment operator, then
|
|
@@ -34209,7 +34227,7 @@ var ts;
|
|
|
34209
34227
|
// Note: we call reScanGreaterToken so that we get an appropriately merged token
|
|
34210
34228
|
// for cases like `> > =` becoming `>>=`
|
|
34211
34229
|
if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
|
|
34212
|
-
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(
|
|
34230
|
+
return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
|
|
34213
34231
|
}
|
|
34214
34232
|
// It wasn't an assignment or a lambda. This is a conditional expression:
|
|
34215
34233
|
return parseConditionalExpressionRest(expr, pos);
|
|
@@ -34252,7 +34270,7 @@ var ts;
|
|
|
34252
34270
|
nextToken();
|
|
34253
34271
|
if (!scanner.hasPrecedingLineBreak() &&
|
|
34254
34272
|
(token() === 41 /* AsteriskToken */ || isStartOfExpression())) {
|
|
34255
|
-
return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher(
|
|
34273
|
+
return finishNode(factory.createYieldExpression(parseOptionalToken(41 /* AsteriskToken */), parseAssignmentExpressionOrHigher()), pos);
|
|
34256
34274
|
}
|
|
34257
34275
|
else {
|
|
34258
34276
|
// if the next token is not on the same line as yield. or we don't have an '*' or
|
|
@@ -34260,7 +34278,7 @@ var ts;
|
|
|
34260
34278
|
return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
|
|
34261
34279
|
}
|
|
34262
34280
|
}
|
|
34263
|
-
function parseSimpleArrowFunctionExpression(pos, identifier,
|
|
34281
|
+
function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
|
|
34264
34282
|
ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
|
|
34265
34283
|
var parameter = factory.createParameterDeclaration(
|
|
34266
34284
|
/*decorators*/ undefined,
|
|
@@ -34272,11 +34290,11 @@ var ts;
|
|
|
34272
34290
|
finishNode(parameter, identifier.pos);
|
|
34273
34291
|
var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
|
|
34274
34292
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
34275
|
-
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier
|
|
34293
|
+
var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
|
|
34276
34294
|
var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
|
|
34277
34295
|
return addJSDocComment(finishNode(node, pos));
|
|
34278
34296
|
}
|
|
34279
|
-
function tryParseParenthesizedArrowFunctionExpression(
|
|
34297
|
+
function tryParseParenthesizedArrowFunctionExpression() {
|
|
34280
34298
|
var triState = isParenthesizedArrowFunctionExpression();
|
|
34281
34299
|
if (triState === 0 /* False */) {
|
|
34282
34300
|
// It's definitely not a parenthesized arrow function expression.
|
|
@@ -34287,8 +34305,8 @@ var ts;
|
|
|
34287
34305
|
// it out, but don't allow any ambiguity, and return 'undefined' if this could be an
|
|
34288
34306
|
// expression instead.
|
|
34289
34307
|
return triState === 1 /* True */ ?
|
|
34290
|
-
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true
|
|
34291
|
-
tryParse(
|
|
34308
|
+
parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
|
|
34309
|
+
tryParse(parsePossibleParenthesizedArrowFunctionExpression);
|
|
34292
34310
|
}
|
|
34293
34311
|
// True -> We definitely expect a parenthesized arrow function here.
|
|
34294
34312
|
// False -> There *cannot* be a parenthesized arrow function here.
|
|
@@ -34418,25 +34436,25 @@ var ts;
|
|
|
34418
34436
|
return 2 /* Unknown */;
|
|
34419
34437
|
}
|
|
34420
34438
|
}
|
|
34421
|
-
function parsePossibleParenthesizedArrowFunctionExpression(
|
|
34439
|
+
function parsePossibleParenthesizedArrowFunctionExpression() {
|
|
34422
34440
|
var tokenPos = scanner.getTokenPos();
|
|
34423
34441
|
if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
|
|
34424
34442
|
return undefined;
|
|
34425
34443
|
}
|
|
34426
|
-
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false
|
|
34444
|
+
var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
|
|
34427
34445
|
if (!result) {
|
|
34428
34446
|
(notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
|
|
34429
34447
|
}
|
|
34430
34448
|
return result;
|
|
34431
34449
|
}
|
|
34432
|
-
function tryParseAsyncSimpleArrowFunctionExpression(
|
|
34450
|
+
function tryParseAsyncSimpleArrowFunctionExpression() {
|
|
34433
34451
|
// We do a check here so that we won't be doing unnecessarily call to "lookAhead"
|
|
34434
34452
|
if (token() === 131 /* AsyncKeyword */) {
|
|
34435
34453
|
if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
|
|
34436
34454
|
var pos = getNodePos();
|
|
34437
34455
|
var asyncModifier = parseModifiersForArrowFunction();
|
|
34438
34456
|
var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
|
|
34439
|
-
return parseSimpleArrowFunctionExpression(pos, expr,
|
|
34457
|
+
return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
|
|
34440
34458
|
}
|
|
34441
34459
|
}
|
|
34442
34460
|
return undefined;
|
|
@@ -34460,7 +34478,7 @@ var ts;
|
|
|
34460
34478
|
}
|
|
34461
34479
|
return 0 /* False */;
|
|
34462
34480
|
}
|
|
34463
|
-
function parseParenthesizedArrowFunctionExpression(allowAmbiguity
|
|
34481
|
+
function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
|
|
34464
34482
|
var pos = getNodePos();
|
|
34465
34483
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
34466
34484
|
var modifiers = parseModifiersForArrowFunction();
|
|
@@ -34495,23 +34513,6 @@ var ts;
|
|
|
34495
34513
|
return undefined;
|
|
34496
34514
|
}
|
|
34497
34515
|
}
|
|
34498
|
-
// Given:
|
|
34499
|
-
// x ? y => ({ y }) : z => ({ z })
|
|
34500
|
-
// We try to parse the body of the first arrow function by looking at:
|
|
34501
|
-
// ({ y }) : z => ({ z })
|
|
34502
|
-
// This is a valid arrow function with "z" as the return type.
|
|
34503
|
-
//
|
|
34504
|
-
// But, if we're in the true side of a conditional expression, this colon
|
|
34505
|
-
// terminates the expression, so we cannot allow a return type if we aren't
|
|
34506
|
-
// certain whether or not the preceding text was parsed as a parameter list.
|
|
34507
|
-
//
|
|
34508
|
-
// For example,
|
|
34509
|
-
// a() ? (b: number, c?: string): void => d() : e
|
|
34510
|
-
// is determined by isParenthesizedArrowFunctionExpression to unambiguously
|
|
34511
|
-
// be an arrow expression, so we allow a return type.
|
|
34512
|
-
if (disallowReturnTypeInArrowFunction && token() === 58 /* ColonToken */) {
|
|
34513
|
-
return undefined;
|
|
34514
|
-
}
|
|
34515
34516
|
var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
|
|
34516
34517
|
if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
|
|
34517
34518
|
return undefined;
|
|
@@ -34540,12 +34541,12 @@ var ts;
|
|
|
34540
34541
|
var lastToken = token();
|
|
34541
34542
|
var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
|
|
34542
34543
|
var body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */)
|
|
34543
|
-
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier)
|
|
34544
|
+
? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
|
|
34544
34545
|
: parseIdentifier();
|
|
34545
34546
|
var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
|
|
34546
34547
|
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
|
34547
34548
|
}
|
|
34548
|
-
function parseArrowFunctionExpressionBody(isAsync
|
|
34549
|
+
function parseArrowFunctionExpressionBody(isAsync) {
|
|
34549
34550
|
if (token() === 18 /* OpenBraceToken */) {
|
|
34550
34551
|
return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
|
|
34551
34552
|
}
|
|
@@ -34573,8 +34574,8 @@ var ts;
|
|
|
34573
34574
|
var savedTopLevel = topLevel;
|
|
34574
34575
|
topLevel = false;
|
|
34575
34576
|
var node = isAsync
|
|
34576
|
-
? doInAwaitContext(
|
|
34577
|
-
: doOutsideOfAwaitContext(
|
|
34577
|
+
? doInAwaitContext(parseAssignmentExpressionOrHigher)
|
|
34578
|
+
: doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
|
|
34578
34579
|
topLevel = savedTopLevel;
|
|
34579
34580
|
return node;
|
|
34580
34581
|
}
|
|
@@ -34587,8 +34588,8 @@ var ts;
|
|
|
34587
34588
|
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
|
|
34588
34589
|
// we do not that for the 'whenFalse' part.
|
|
34589
34590
|
var colonToken;
|
|
34590
|
-
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext,
|
|
34591
|
-
? parseAssignmentExpressionOrHigher(
|
|
34591
|
+
return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
|
|
34592
|
+
? parseAssignmentExpressionOrHigher()
|
|
34592
34593
|
: createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
|
|
34593
34594
|
}
|
|
34594
34595
|
function parseBinaryExpressionOrHigher(precedence) {
|
|
@@ -35480,13 +35481,13 @@ var ts;
|
|
|
35480
35481
|
function parseSpreadElement() {
|
|
35481
35482
|
var pos = getNodePos();
|
|
35482
35483
|
parseExpected(25 /* DotDotDotToken */);
|
|
35483
|
-
var expression = parseAssignmentExpressionOrHigher(
|
|
35484
|
+
var expression = parseAssignmentExpressionOrHigher();
|
|
35484
35485
|
return finishNode(factory.createSpreadElement(expression), pos);
|
|
35485
35486
|
}
|
|
35486
35487
|
function parseArgumentOrArrayLiteralElement() {
|
|
35487
35488
|
return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() :
|
|
35488
35489
|
token() === 27 /* CommaToken */ ? finishNode(factory.createOmittedExpression(), getNodePos()) :
|
|
35489
|
-
parseAssignmentExpressionOrHigher(
|
|
35490
|
+
parseAssignmentExpressionOrHigher();
|
|
35490
35491
|
}
|
|
35491
35492
|
function parseArgumentExpression() {
|
|
35492
35493
|
return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
|
|
@@ -35504,7 +35505,7 @@ var ts;
|
|
|
35504
35505
|
var pos = getNodePos();
|
|
35505
35506
|
var hasJSDoc = hasPrecedingJSDocComment();
|
|
35506
35507
|
if (parseOptionalToken(25 /* DotDotDotToken */)) {
|
|
35507
|
-
var expression = parseAssignmentExpressionOrHigher(
|
|
35508
|
+
var expression = parseAssignmentExpressionOrHigher();
|
|
35508
35509
|
return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
|
|
35509
35510
|
}
|
|
35510
35511
|
var decorators = parseDecorators();
|
|
@@ -35533,7 +35534,7 @@ var ts;
|
|
|
35533
35534
|
var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */);
|
|
35534
35535
|
if (isShorthandPropertyAssignment) {
|
|
35535
35536
|
var equalsToken = parseOptionalToken(63 /* EqualsToken */);
|
|
35536
|
-
var objectAssignmentInitializer = equalsToken ? allowInAnd(
|
|
35537
|
+
var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
|
|
35537
35538
|
node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
|
|
35538
35539
|
// Save equals token for error reporting.
|
|
35539
35540
|
// TODO(rbuckton): Consider manufacturing this when we need to report an error as it is otherwise not useful.
|
|
@@ -35541,7 +35542,7 @@ var ts;
|
|
|
35541
35542
|
}
|
|
35542
35543
|
else {
|
|
35543
35544
|
parseExpected(58 /* ColonToken */);
|
|
35544
|
-
var initializer = allowInAnd(
|
|
35545
|
+
var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
35545
35546
|
node = factory.createPropertyAssignment(name, initializer);
|
|
35546
35547
|
}
|
|
35547
35548
|
// Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker
|
|
@@ -35715,7 +35716,7 @@ var ts;
|
|
|
35715
35716
|
}
|
|
35716
35717
|
var node;
|
|
35717
35718
|
if (awaitToken ? parseExpected(160 /* OfKeyword */) : parseOptional(160 /* OfKeyword */)) {
|
|
35718
|
-
var expression = allowInAnd(
|
|
35719
|
+
var expression = allowInAnd(parseAssignmentExpressionOrHigher);
|
|
35719
35720
|
parseExpected(21 /* CloseParenToken */);
|
|
35720
35721
|
node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
|
|
35721
35722
|
}
|
|
@@ -36883,7 +36884,7 @@ var ts;
|
|
|
36883
36884
|
var pos = getNodePos();
|
|
36884
36885
|
var name = ts.tokenIsIdentifierOrKeyword(token()) ? parseIdentifierName() : parseLiteralLikeNode(10 /* StringLiteral */);
|
|
36885
36886
|
parseExpected(58 /* ColonToken */);
|
|
36886
|
-
var value = parseAssignmentExpressionOrHigher(
|
|
36887
|
+
var value = parseAssignmentExpressionOrHigher();
|
|
36887
36888
|
return finishNode(factory.createAssertEntry(name, value), pos);
|
|
36888
36889
|
}
|
|
36889
36890
|
function parseAssertClause(skipAssertKeyword) {
|
|
@@ -36943,7 +36944,7 @@ var ts;
|
|
|
36943
36944
|
function parseModuleReference() {
|
|
36944
36945
|
return isExternalModuleReference()
|
|
36945
36946
|
? parseExternalModuleReference()
|
|
36946
|
-
: parseEntityName(/*allowReservedWords*/ false
|
|
36947
|
+
: parseEntityName(/*allowReservedWords*/ false);
|
|
36947
36948
|
}
|
|
36948
36949
|
function parseExternalModuleReference() {
|
|
36949
36950
|
var pos = getNodePos();
|
|
@@ -37122,7 +37123,7 @@ var ts;
|
|
|
37122
37123
|
else {
|
|
37123
37124
|
parseExpected(88 /* DefaultKeyword */);
|
|
37124
37125
|
}
|
|
37125
|
-
var expression = parseAssignmentExpressionOrHigher(
|
|
37126
|
+
var expression = parseAssignmentExpressionOrHigher();
|
|
37126
37127
|
parseSemicolon();
|
|
37127
37128
|
setAwaitContext(savedAwaitContext);
|
|
37128
37129
|
var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
|
|
@@ -37196,7 +37197,7 @@ var ts;
|
|
|
37196
37197
|
var pos = getNodePos();
|
|
37197
37198
|
var hasBrace = parseOptional(18 /* OpenBraceToken */);
|
|
37198
37199
|
var p2 = getNodePos();
|
|
37199
|
-
var entityName = parseEntityName(/* allowReservedWords*/ false
|
|
37200
|
+
var entityName = parseEntityName(/* allowReservedWords*/ false);
|
|
37200
37201
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
37201
37202
|
reScanHashToken(); // rescan #id as # id
|
|
37202
37203
|
nextTokenJSDoc(); // then skip the #
|
|
@@ -37639,7 +37640,7 @@ var ts;
|
|
|
37639
37640
|
// parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error
|
|
37640
37641
|
var p2 = getNodePos();
|
|
37641
37642
|
var name = ts.tokenIsIdentifierOrKeyword(token())
|
|
37642
|
-
? parseEntityName(/*allowReservedWords*/ true
|
|
37643
|
+
? parseEntityName(/*allowReservedWords*/ true)
|
|
37643
37644
|
: undefined;
|
|
37644
37645
|
if (name) {
|
|
37645
37646
|
while (token() === 80 /* PrivateIdentifier */) {
|
|
@@ -38961,6 +38962,7 @@ var ts;
|
|
|
38961
38962
|
["es2021.intl", "lib.es2021.intl.d.ts"],
|
|
38962
38963
|
["es2022.array", "lib.es2022.array.d.ts"],
|
|
38963
38964
|
["es2022.error", "lib.es2022.error.d.ts"],
|
|
38965
|
+
["es2022.intl", "lib.es2022.intl.d.ts"],
|
|
38964
38966
|
["es2022.object", "lib.es2022.object.d.ts"],
|
|
38965
38967
|
["es2022.string", "lib.es2022.string.d.ts"],
|
|
38966
38968
|
["esnext.array", "lib.es2022.array.d.ts"],
|
|
@@ -42159,7 +42161,7 @@ var ts;
|
|
|
42159
42161
|
ts.Debug.assert(ts.extensionIsTS(resolved.extension));
|
|
42160
42162
|
return { fileName: resolved.path, packageId: resolved.packageId };
|
|
42161
42163
|
}
|
|
42162
|
-
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
|
|
42164
|
+
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, diagnostics, resultFromCache) {
|
|
42163
42165
|
var _a;
|
|
42164
42166
|
if (resultFromCache) {
|
|
42165
42167
|
(_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
|
|
@@ -42167,7 +42169,8 @@ var ts;
|
|
|
42167
42169
|
}
|
|
42168
42170
|
return {
|
|
42169
42171
|
resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
|
|
42170
|
-
failedLookupLocations: failedLookupLocations
|
|
42172
|
+
failedLookupLocations: failedLookupLocations,
|
|
42173
|
+
resolutionDiagnostics: diagnostics
|
|
42171
42174
|
};
|
|
42172
42175
|
}
|
|
42173
42176
|
function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
|
|
@@ -42368,7 +42371,18 @@ var ts;
|
|
|
42368
42371
|
features |= NodeResolutionFeatures.EsmMode;
|
|
42369
42372
|
}
|
|
42370
42373
|
var conditions = features & NodeResolutionFeatures.Exports ? features & NodeResolutionFeatures.EsmMode ? ["node", "import", "types"] : ["node", "require", "types"] : [];
|
|
42371
|
-
var
|
|
42374
|
+
var diagnostics = [];
|
|
42375
|
+
var moduleResolutionState = {
|
|
42376
|
+
compilerOptions: options,
|
|
42377
|
+
host: host,
|
|
42378
|
+
traceEnabled: traceEnabled,
|
|
42379
|
+
failedLookupLocations: failedLookupLocations,
|
|
42380
|
+
packageJsonInfoCache: cache,
|
|
42381
|
+
features: features,
|
|
42382
|
+
conditions: conditions,
|
|
42383
|
+
requestContainingDirectory: containingDirectory,
|
|
42384
|
+
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
42385
|
+
};
|
|
42372
42386
|
var resolved = primaryLookup();
|
|
42373
42387
|
var primary = true;
|
|
42374
42388
|
if (!resolved) {
|
|
@@ -42387,7 +42401,7 @@ var ts;
|
|
|
42387
42401
|
isExternalLibraryImport: pathContainsNodeModules(fileName),
|
|
42388
42402
|
};
|
|
42389
42403
|
}
|
|
42390
|
-
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
|
|
42404
|
+
result = { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations, resolutionDiagnostics: diagnostics };
|
|
42391
42405
|
perFolderCache === null || perFolderCache === void 0 ? void 0 : perFolderCache.set(typeReferenceDirectiveName, /*mode*/ resolutionMode, result);
|
|
42392
42406
|
if (traceEnabled)
|
|
42393
42407
|
traceResult(result);
|
|
@@ -42470,6 +42484,8 @@ var ts;
|
|
|
42470
42484
|
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
42471
42485
|
conditions: ts.emptyArray,
|
|
42472
42486
|
features: NodeResolutionFeatures.None,
|
|
42487
|
+
requestContainingDirectory: containingDirectory,
|
|
42488
|
+
reportDiagnostic: ts.noop
|
|
42473
42489
|
};
|
|
42474
42490
|
return ts.forEachAncestorDirectory(containingDirectory, function (ancestorDirectory) {
|
|
42475
42491
|
if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
|
|
@@ -43121,6 +43137,7 @@ var ts;
|
|
|
43121
43137
|
if (compilerOptions.noDtsResolution) {
|
|
43122
43138
|
conditions.pop();
|
|
43123
43139
|
}
|
|
43140
|
+
var diagnostics = [];
|
|
43124
43141
|
var state = {
|
|
43125
43142
|
compilerOptions: compilerOptions,
|
|
43126
43143
|
host: host,
|
|
@@ -43129,9 +43146,11 @@ var ts;
|
|
|
43129
43146
|
packageJsonInfoCache: cache,
|
|
43130
43147
|
features: features,
|
|
43131
43148
|
conditions: conditions,
|
|
43149
|
+
requestContainingDirectory: containingDirectory,
|
|
43150
|
+
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
43132
43151
|
};
|
|
43133
43152
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
43134
|
-
return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, state.resultFromCache);
|
|
43153
|
+
return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, diagnostics, state.resultFromCache);
|
|
43135
43154
|
function tryResolve(extensions) {
|
|
43136
43155
|
var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, /*considerPackageJson*/ true); };
|
|
43137
43156
|
var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
|
|
@@ -43304,9 +43323,9 @@ var ts;
|
|
|
43304
43323
|
}
|
|
43305
43324
|
}
|
|
43306
43325
|
function loadJSOrExactTSFileName(extensions, candidate, onlyRecordFailures, state) {
|
|
43307
|
-
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.
|
|
43326
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) && ts.fileExtensionIsOneOf(candidate, ts.supportedTSExtensionsFlat)) {
|
|
43308
43327
|
var result = tryFile(candidate, onlyRecordFailures, state);
|
|
43309
|
-
return result !== undefined ? { path: candidate, ext: ts.
|
|
43328
|
+
return result !== undefined ? { path: candidate, ext: ts.tryExtractTSExtension(candidate) } : undefined;
|
|
43310
43329
|
}
|
|
43311
43330
|
return loadModuleFromFileNoImplicitExtensions(extensions, candidate, onlyRecordFailures, state);
|
|
43312
43331
|
}
|
|
@@ -43429,6 +43448,8 @@ var ts;
|
|
|
43429
43448
|
packageJsonInfoCache: cache === null || cache === void 0 ? void 0 : cache.getPackageJsonInfoCache(),
|
|
43430
43449
|
conditions: ["node", "require", "types"],
|
|
43431
43450
|
features: features,
|
|
43451
|
+
requestContainingDirectory: packageJsonInfo.packageDirectory,
|
|
43452
|
+
reportDiagnostic: ts.noop
|
|
43432
43453
|
};
|
|
43433
43454
|
var requireResolution = loadNodeModuleFromDirectoryWorker(extensions, packageJsonInfo.packageDirectory,
|
|
43434
43455
|
/*onlyRecordFailures*/ false, requireState, packageJsonInfo.packageJsonContent, packageJsonInfo.versionPaths);
|
|
@@ -43515,6 +43536,8 @@ var ts;
|
|
|
43515
43536
|
packageJsonInfoCache: packageJsonInfoCache,
|
|
43516
43537
|
features: 0,
|
|
43517
43538
|
conditions: [],
|
|
43539
|
+
requestContainingDirectory: undefined,
|
|
43540
|
+
reportDiagnostic: ts.noop
|
|
43518
43541
|
};
|
|
43519
43542
|
var parts = ts.getPathComponents(fileName);
|
|
43520
43543
|
parts.pop();
|
|
@@ -43806,7 +43829,6 @@ var ts;
|
|
|
43806
43829
|
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
43807
43830
|
return loadModuleFromTargetImportOrExport;
|
|
43808
43831
|
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
43809
|
-
var _a, _b;
|
|
43810
43832
|
if (typeof target === "string") {
|
|
43811
43833
|
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
43812
43834
|
if (state.traceEnabled) {
|
|
@@ -43843,13 +43865,16 @@ var ts;
|
|
|
43843
43865
|
}
|
|
43844
43866
|
return toSearchResult(/*value*/ undefined);
|
|
43845
43867
|
}
|
|
43846
|
-
var finalPath =
|
|
43868
|
+
var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
|
|
43869
|
+
var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
|
|
43870
|
+
if (inputLink)
|
|
43871
|
+
return inputLink;
|
|
43847
43872
|
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, finalPath, /*onlyRecordFailures*/ false, state)));
|
|
43848
43873
|
}
|
|
43849
43874
|
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
43850
43875
|
if (!Array.isArray(target)) {
|
|
43851
|
-
for (var _i = 0,
|
|
43852
|
-
var key =
|
|
43876
|
+
for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
|
|
43877
|
+
var key = _a[_i];
|
|
43853
43878
|
if (key === "default" || state.conditions.indexOf(key) >= 0 || isApplicableVersionedTypesKey(state.conditions, key)) {
|
|
43854
43879
|
var subTarget = target[key];
|
|
43855
43880
|
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern);
|
|
@@ -43867,8 +43892,8 @@ var ts;
|
|
|
43867
43892
|
}
|
|
43868
43893
|
return toSearchResult(/*value*/ undefined);
|
|
43869
43894
|
}
|
|
43870
|
-
for (var
|
|
43871
|
-
var elem = target_2[
|
|
43895
|
+
for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
|
|
43896
|
+
var elem = target_2[_b];
|
|
43872
43897
|
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
43873
43898
|
if (result) {
|
|
43874
43899
|
return result;
|
|
@@ -43886,6 +43911,128 @@ var ts;
|
|
|
43886
43911
|
trace(state.host, ts.Diagnostics.package_json_scope_0_has_invalid_type_for_target_of_specifier_1, scope.packageDirectory, moduleName);
|
|
43887
43912
|
}
|
|
43888
43913
|
return toSearchResult(/*value*/ undefined);
|
|
43914
|
+
function toAbsolutePath(path) {
|
|
43915
|
+
var _a, _b;
|
|
43916
|
+
if (path === undefined)
|
|
43917
|
+
return path;
|
|
43918
|
+
return ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames })(ts.getNormalizedAbsolutePath(path, (_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)));
|
|
43919
|
+
}
|
|
43920
|
+
function combineDirectoryPath(root, dir) {
|
|
43921
|
+
return ts.ensureTrailingDirectorySeparator(ts.combinePaths(root, dir));
|
|
43922
|
+
}
|
|
43923
|
+
function useCaseSensitiveFileNames() {
|
|
43924
|
+
return !state.host.useCaseSensitiveFileNames ? true :
|
|
43925
|
+
typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
|
|
43926
|
+
state.host.useCaseSensitiveFileNames();
|
|
43927
|
+
}
|
|
43928
|
+
function tryLoadInputFileForPath(finalPath, entry, packagePath, isImports) {
|
|
43929
|
+
var _a, _b, _c, _d;
|
|
43930
|
+
// Replace any references to outputs for files in the program with the input files to support package self-names used with outDir
|
|
43931
|
+
// PROBLEM: We don't know how to calculate the output paths yet, because the "common source directory" we use as the base of the file structure
|
|
43932
|
+
// we reproduce into the output directory is based on the set of input files, which we're still in the process of traversing and resolving!
|
|
43933
|
+
// _Given that_, we have to guess what the base of the output directory is (obviously the user wrote the export map, so has some idea what it is!).
|
|
43934
|
+
// We are going to probe _so many_ possible paths. We limit where we'll do this to try to reduce the possibilities of false positive lookups.
|
|
43935
|
+
if ((extensions === Extensions.TypeScript || extensions === Extensions.JavaScript || extensions === Extensions.Json)
|
|
43936
|
+
&& (state.compilerOptions.declarationDir || state.compilerOptions.outDir)
|
|
43937
|
+
&& finalPath.indexOf("/node_modules/") === -1
|
|
43938
|
+
&& (state.compilerOptions.configFile ? ts.startsWith(toAbsolutePath(state.compilerOptions.configFile.fileName), scope.packageDirectory) : true)) {
|
|
43939
|
+
// So that all means we'll only try these guesses for files outside `node_modules` in a directory where the `package.json` and `tsconfig.json` are siblings.
|
|
43940
|
+
// Even with all that, we still don't know if the root of the output file structure will be (relative to the package file)
|
|
43941
|
+
// `.`, `./src` or any other deeper directory structure. (If project references are used, it's definitely `.` by fiat, so that should be pretty common.)
|
|
43942
|
+
var getCanonicalFileName = ts.hostGetCanonicalFileName({ useCaseSensitiveFileNames: useCaseSensitiveFileNames });
|
|
43943
|
+
var commonSourceDirGuesses = [];
|
|
43944
|
+
// A `rootDir` compiler option strongly indicates the root location
|
|
43945
|
+
// A `composite` project is using project references and has it's common src dir set to `.`, so it shouldn't need to check any other locations
|
|
43946
|
+
if (state.compilerOptions.rootDir || (state.compilerOptions.composite && state.compilerOptions.configFilePath)) {
|
|
43947
|
+
var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return []; }, ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "", getCanonicalFileName));
|
|
43948
|
+
commonSourceDirGuesses.push(commonDir);
|
|
43949
|
+
}
|
|
43950
|
+
else if (state.requestContainingDirectory) {
|
|
43951
|
+
// However without either of those set we're in the dark. Let's say you have
|
|
43952
|
+
//
|
|
43953
|
+
// ./tools/index.ts
|
|
43954
|
+
// ./src/index.ts
|
|
43955
|
+
// ./dist/index.js
|
|
43956
|
+
// ./package.json <-- references ./dist/index.js
|
|
43957
|
+
// ./tsconfig.json <-- loads ./src/index.ts
|
|
43958
|
+
//
|
|
43959
|
+
// How do we know `./src` is the common src dir, and not `./tools`, given only the `./dist` out dir and `./dist/index.js` filename?
|
|
43960
|
+
// Answer: We... don't. We know we're looking for an `index.ts` input file, but we have _no clue_ which subfolder it's supposed to be loaded from
|
|
43961
|
+
// without more context.
|
|
43962
|
+
// But we do have more context! Just a tiny bit more! We're resolving an import _for some other input file_! And that input file, too
|
|
43963
|
+
// must be inside the common source directory! So we propagate that tidbit of info all the way to here via state.requestContainingDirectory
|
|
43964
|
+
var requestingFile_1 = toAbsolutePath(ts.combinePaths(state.requestContainingDirectory, "index.ts"));
|
|
43965
|
+
// And we can try every folder above the common folder for the request folder and the config/package base directory
|
|
43966
|
+
// This technically can be wrong - we may load ./src/index.ts when ./src/sub/index.ts was right because we don't
|
|
43967
|
+
// know if only `./src/sub` files were loaded by the program; but this has the best chance to be right of just about anything
|
|
43968
|
+
// else we have. And, given that we're about to load `./src/index.ts` because we choose it as likely correct, there will then
|
|
43969
|
+
// be a file outside of `./src/sub` in the program (the file we resolved to), making us de-facto right. So this fallback lookup
|
|
43970
|
+
// logic may influence what files are pulled in by self-names, which in turn influences the output path shape, but it's all
|
|
43971
|
+
// internally consistent so the paths should be stable so long as we prefer the "most general" (meaning: top-most-level directory) possible results first.
|
|
43972
|
+
var commonDir = toAbsolutePath(ts.getCommonSourceDirectory(state.compilerOptions, function () { return [requestingFile_1, toAbsolutePath(packagePath)]; }, ((_d = (_c = state.host).getCurrentDirectory) === null || _d === void 0 ? void 0 : _d.call(_c)) || "", getCanonicalFileName));
|
|
43973
|
+
commonSourceDirGuesses.push(commonDir);
|
|
43974
|
+
var fragment = ts.ensureTrailingDirectorySeparator(commonDir);
|
|
43975
|
+
while (fragment && fragment.length > 1) {
|
|
43976
|
+
var parts = ts.getPathComponents(fragment);
|
|
43977
|
+
parts.pop(); // remove a directory
|
|
43978
|
+
var commonDir_1 = ts.getPathFromPathComponents(parts);
|
|
43979
|
+
commonSourceDirGuesses.unshift(commonDir_1);
|
|
43980
|
+
fragment = ts.ensureTrailingDirectorySeparator(commonDir_1);
|
|
43981
|
+
}
|
|
43982
|
+
}
|
|
43983
|
+
if (commonSourceDirGuesses.length > 1) {
|
|
43984
|
+
state.reportDiagnostic(ts.createCompilerDiagnostic(isImports
|
|
43985
|
+
? ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate
|
|
43986
|
+
: ts.Diagnostics.The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate, entry === "" ? "." : entry, // replace empty string with `.` - the reverse of the operation done when entries are built - so main entrypoint errors don't look weird
|
|
43987
|
+
packagePath));
|
|
43988
|
+
}
|
|
43989
|
+
for (var _i = 0, commonSourceDirGuesses_1 = commonSourceDirGuesses; _i < commonSourceDirGuesses_1.length; _i++) {
|
|
43990
|
+
var commonSourceDirGuess = commonSourceDirGuesses_1[_i];
|
|
43991
|
+
var candidateDirectories = getOutputDirectoriesForBaseDirectory(commonSourceDirGuess);
|
|
43992
|
+
for (var _e = 0, candidateDirectories_1 = candidateDirectories; _e < candidateDirectories_1.length; _e++) {
|
|
43993
|
+
var candidateDir = candidateDirectories_1[_e];
|
|
43994
|
+
if (ts.startsWith(finalPath, candidateDir)) {
|
|
43995
|
+
// The matched export is looking up something in either the out declaration or js dir, now map the written path back into the source dir and source extension
|
|
43996
|
+
var pathFragment = finalPath.slice(candidateDir.length + 1); // +1 to also remove directory seperator
|
|
43997
|
+
var possibleInputBase = ts.combinePaths(commonSourceDirGuess, pathFragment);
|
|
43998
|
+
var jsAndDtsExtensions = [".mjs" /* Mjs */, ".cjs" /* Cjs */, ".js" /* Js */, ".json" /* Json */, ".d.mts" /* Dmts */, ".d.cts" /* Dcts */, ".d.ts" /* Dts */];
|
|
43999
|
+
for (var _f = 0, jsAndDtsExtensions_1 = jsAndDtsExtensions; _f < jsAndDtsExtensions_1.length; _f++) {
|
|
44000
|
+
var ext = jsAndDtsExtensions_1[_f];
|
|
44001
|
+
if (ts.fileExtensionIs(possibleInputBase, ext)) {
|
|
44002
|
+
var inputExts = ts.getPossibleOriginalInputExtensionForExtension(possibleInputBase);
|
|
44003
|
+
for (var _g = 0, inputExts_1 = inputExts; _g < inputExts_1.length; _g++) {
|
|
44004
|
+
var possibleExt = inputExts_1[_g];
|
|
44005
|
+
var possibleInputWithInputExtension = ts.changeAnyExtension(possibleInputBase, possibleExt, ext, !useCaseSensitiveFileNames());
|
|
44006
|
+
if ((extensions === Extensions.TypeScript && ts.hasJSFileExtension(possibleInputWithInputExtension)) ||
|
|
44007
|
+
(extensions === Extensions.JavaScript && ts.hasTSFileExtension(possibleInputWithInputExtension))) {
|
|
44008
|
+
continue;
|
|
44009
|
+
}
|
|
44010
|
+
if (state.host.fileExists(possibleInputWithInputExtension)) {
|
|
44011
|
+
return toSearchResult(withPackageId(scope, loadJSOrExactTSFileName(extensions, possibleInputWithInputExtension, /*onlyRecordFailures*/ false, state)));
|
|
44012
|
+
}
|
|
44013
|
+
}
|
|
44014
|
+
}
|
|
44015
|
+
}
|
|
44016
|
+
}
|
|
44017
|
+
}
|
|
44018
|
+
}
|
|
44019
|
+
}
|
|
44020
|
+
return undefined;
|
|
44021
|
+
function getOutputDirectoriesForBaseDirectory(commonSourceDirGuess) {
|
|
44022
|
+
var _a, _b;
|
|
44023
|
+
// Config file ouput paths are processed to be relative to the host's current directory, while
|
|
44024
|
+
// otherwise the paths are resolved relative to the common source dir the compiler puts together
|
|
44025
|
+
var currentDir = state.compilerOptions.configFile ? ((_b = (_a = state.host).getCurrentDirectory) === null || _b === void 0 ? void 0 : _b.call(_a)) || "" : commonSourceDirGuess;
|
|
44026
|
+
var candidateDirectories = [];
|
|
44027
|
+
if (state.compilerOptions.declarationDir) {
|
|
44028
|
+
candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.declarationDir)));
|
|
44029
|
+
}
|
|
44030
|
+
if (state.compilerOptions.outDir && state.compilerOptions.outDir !== state.compilerOptions.declarationDir) {
|
|
44031
|
+
candidateDirectories.push(toAbsolutePath(combineDirectoryPath(currentDir, state.compilerOptions.outDir)));
|
|
44032
|
+
}
|
|
44033
|
+
return candidateDirectories;
|
|
44034
|
+
}
|
|
44035
|
+
}
|
|
43889
44036
|
}
|
|
43890
44037
|
}
|
|
43891
44038
|
/* @internal */
|
|
@@ -44076,11 +44223,12 @@ var ts;
|
|
|
44076
44223
|
function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
|
|
44077
44224
|
var traceEnabled = isTraceEnabled(compilerOptions, host);
|
|
44078
44225
|
var failedLookupLocations = [];
|
|
44079
|
-
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [] };
|
|
44080
44226
|
var containingDirectory = ts.getDirectoryPath(containingFile);
|
|
44227
|
+
var diagnostics = [];
|
|
44228
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: cache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: containingDirectory, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
|
|
44081
44229
|
var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
|
|
44082
44230
|
// No originalPath because classic resolution doesn't resolve realPath
|
|
44083
|
-
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, state.resultFromCache);
|
|
44231
|
+
return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, /*isExternalLibraryImport*/ false, failedLookupLocations, diagnostics, state.resultFromCache);
|
|
44084
44232
|
function tryResolve(extensions) {
|
|
44085
44233
|
var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
|
|
44086
44234
|
if (resolvedUsingSettings) {
|
|
@@ -44123,9 +44271,10 @@ var ts;
|
|
|
44123
44271
|
trace(host, ts.Diagnostics.Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2, projectName, moduleName, globalCache);
|
|
44124
44272
|
}
|
|
44125
44273
|
var failedLookupLocations = [];
|
|
44126
|
-
var
|
|
44274
|
+
var diagnostics = [];
|
|
44275
|
+
var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations, packageJsonInfoCache: packageJsonInfoCache, features: NodeResolutionFeatures.None, conditions: [], requestContainingDirectory: undefined, reportDiagnostic: function (diag) { return void diagnostics.push(diag); } };
|
|
44127
44276
|
var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, /*typesScopeOnly*/ false, /*cache*/ undefined, /*redirectedReference*/ undefined);
|
|
44128
|
-
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, state.resultFromCache);
|
|
44277
|
+
return createResolvedModuleWithFailedLookupLocations(resolved, /*isExternalLibraryImport*/ true, failedLookupLocations, diagnostics, state.resultFromCache);
|
|
44129
44278
|
}
|
|
44130
44279
|
ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
|
|
44131
44280
|
/**
|
|
@@ -57989,7 +58138,8 @@ var ts;
|
|
|
57989
58138
|
if (symbol === globalThisSymbol) {
|
|
57990
58139
|
var varsOnly_1 = new ts.Map();
|
|
57991
58140
|
members.forEach(function (p) {
|
|
57992
|
-
|
|
58141
|
+
var _a;
|
|
58142
|
+
if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) === null || _a === void 0 ? void 0 : _a.length) && ts.every(p.declarations, ts.isAmbientModule))) {
|
|
57993
58143
|
varsOnly_1.set(p.escapedName, p);
|
|
57994
58144
|
}
|
|
57995
58145
|
});
|
|
@@ -84840,6 +84990,9 @@ var ts;
|
|
|
84840
84990
|
var validForTypeAssertions = ts.isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
84841
84991
|
var override = ts.getResolutionModeOverrideForClause(declaration.assertClause, validForTypeAssertions ? grammarErrorOnNode : undefined);
|
|
84842
84992
|
if (validForTypeAssertions && override) {
|
|
84993
|
+
if (!ts.isNightly()) {
|
|
84994
|
+
grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next);
|
|
84995
|
+
}
|
|
84843
84996
|
if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
|
|
84844
84997
|
return grammarErrorOnNode(declaration.assertClause, ts.Diagnostics.Resolution_modes_are_only_supported_when_moduleResolution_is_node16_or_nodenext);
|
|
84845
84998
|
}
|
|
@@ -86180,7 +86333,7 @@ var ts;
|
|
|
86180
86333
|
if (ts.isDeclaration(node)) {
|
|
86181
86334
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
86182
86335
|
var symbol = getSymbolOfNode(node);
|
|
86183
|
-
return getTypeOfSymbol(symbol);
|
|
86336
|
+
return symbol ? getTypeOfSymbol(symbol) : errorType;
|
|
86184
86337
|
}
|
|
86185
86338
|
if (isDeclarationNameOrImportPropertyName(node)) {
|
|
86186
86339
|
var symbol = getSymbolAtLocation(node);
|
|
@@ -108238,34 +108391,44 @@ var ts;
|
|
|
108238
108391
|
if (!decl.importClause) {
|
|
108239
108392
|
// import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc)
|
|
108240
108393
|
return factory.updateImportDeclaration(decl,
|
|
108241
|
-
/*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108394
|
+
/*decorators*/ undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108242
108395
|
}
|
|
108243
108396
|
// The `importClause` visibility corresponds to the default's visibility.
|
|
108244
108397
|
var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
|
|
108245
108398
|
if (!decl.importClause.namedBindings) {
|
|
108246
108399
|
// No named bindings (either namespace or list), meaning the import is just default or should be elided
|
|
108247
108400
|
return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding,
|
|
108248
|
-
/*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108401
|
+
/*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108249
108402
|
}
|
|
108250
108403
|
if (decl.importClause.namedBindings.kind === 268 /* NamespaceImport */) {
|
|
108251
108404
|
// Namespace import (optionally with visible default)
|
|
108252
108405
|
var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined;
|
|
108253
|
-
return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108406
|
+
return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause)) : undefined;
|
|
108254
108407
|
}
|
|
108255
108408
|
// Named imports (optionally with visible default)
|
|
108256
108409
|
var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
|
|
108257
108410
|
if ((bindingList && bindingList.length) || visibleDefaultBinding) {
|
|
108258
108411
|
return factory.updateImportDeclaration(decl,
|
|
108259
|
-
/*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108412
|
+
/*decorators*/ undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108260
108413
|
}
|
|
108261
108414
|
// Augmentation of export depends on import
|
|
108262
108415
|
if (resolver.isImportRequiredByAugmentation(decl)) {
|
|
108263
108416
|
return factory.updateImportDeclaration(decl,
|
|
108264
108417
|
/*decorators*/ undefined, decl.modifiers,
|
|
108265
|
-
/*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier),
|
|
108418
|
+
/*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), getResolutionModeOverrideForClauseInNightly(decl.assertClause));
|
|
108266
108419
|
}
|
|
108267
108420
|
// Nothing visible
|
|
108268
108421
|
}
|
|
108422
|
+
function getResolutionModeOverrideForClauseInNightly(assertClause) {
|
|
108423
|
+
var mode = ts.getResolutionModeOverrideForClause(assertClause);
|
|
108424
|
+
if (mode !== undefined) {
|
|
108425
|
+
if (!ts.isNightly()) {
|
|
108426
|
+
context.addDiagnostic(ts.createDiagnosticForNode(assertClause, ts.Diagnostics.Resolution_mode_assertions_are_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next));
|
|
108427
|
+
}
|
|
108428
|
+
return assertClause;
|
|
108429
|
+
}
|
|
108430
|
+
return undefined;
|
|
108431
|
+
}
|
|
108269
108432
|
function transformAndReplaceLatePaintedStatements(statements) {
|
|
108270
108433
|
// This is a `while` loop because `handleSymbolAccessibilityError` can see additional import aliases marked as visible during
|
|
108271
108434
|
// error handling which must now be included in the output and themselves checked for errors.
|
|
@@ -116094,7 +116257,6 @@ var ts;
|
|
|
116094
116257
|
ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer.code,
|
|
116095
116258
|
ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list.code,
|
|
116096
116259
|
ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma.code,
|
|
116097
|
-
ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body.code,
|
|
116098
116260
|
ts.Diagnostics.A_return_statement_cannot_be_used_inside_a_class_static_block.code,
|
|
116099
116261
|
ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter.code,
|
|
116100
116262
|
ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter.code,
|
|
@@ -116481,6 +116643,40 @@ var ts;
|
|
|
116481
116643
|
ts.performance.measure("Program", "beforeProgram", "afterProgram");
|
|
116482
116644
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116483
116645
|
return program;
|
|
116646
|
+
function addResolutionDiagnostics(list) {
|
|
116647
|
+
if (!list)
|
|
116648
|
+
return;
|
|
116649
|
+
for (var _i = 0, list_3 = list; _i < list_3.length; _i++) {
|
|
116650
|
+
var elem = list_3[_i];
|
|
116651
|
+
programDiagnostics.add(elem);
|
|
116652
|
+
}
|
|
116653
|
+
}
|
|
116654
|
+
function pullDiagnosticsFromCache(names, containingFile) {
|
|
116655
|
+
var _a;
|
|
116656
|
+
if (!moduleResolutionCache)
|
|
116657
|
+
return;
|
|
116658
|
+
var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
|
|
116659
|
+
var containingFileMode = !ts.isString(containingFile) ? containingFile.impliedNodeFormat : undefined;
|
|
116660
|
+
var containingDir = ts.getDirectoryPath(containingFileName);
|
|
116661
|
+
var redirectedReference = getRedirectReferenceForResolution(containingFile);
|
|
116662
|
+
var i = 0;
|
|
116663
|
+
for (var _i = 0, names_4 = names; _i < names_4.length; _i++) {
|
|
116664
|
+
var n = names_4[_i];
|
|
116665
|
+
// mimics logic done in the resolution cache, should be resilient to upgrading it to use `FileReference`s for non-type-reference modal lookups to make it rely on the index in the list less
|
|
116666
|
+
var mode = typeof n === "string" ? getModeForResolutionAtIndex(containingFile, i) : getModeForFileReference(n, containingFileMode);
|
|
116667
|
+
var name = typeof n === "string" ? n : n.fileName;
|
|
116668
|
+
i++;
|
|
116669
|
+
// only nonrelative names hit the cache, and, at least as of right now, only nonrelative names can issue diagnostics
|
|
116670
|
+
// (Since diagnostics are only issued via import or export map lookup)
|
|
116671
|
+
// This may totally change if/when the issue of output paths not mapping to input files is fixed in a broader context
|
|
116672
|
+
// When it is, how we extract diagnostics from the module name resolver will have the be refined - the current cache
|
|
116673
|
+
// APIs wrapping the underlying resolver make it almost impossible to smuggle the diagnostics out in a generalized way
|
|
116674
|
+
if (ts.isExternalModuleNameRelative(name))
|
|
116675
|
+
continue;
|
|
116676
|
+
var diags = (_a = moduleResolutionCache.getOrCreateCacheForModuleName(name, mode, redirectedReference).get(containingDir)) === null || _a === void 0 ? void 0 : _a.resolutionDiagnostics;
|
|
116677
|
+
addResolutionDiagnostics(diags);
|
|
116678
|
+
}
|
|
116679
|
+
}
|
|
116484
116680
|
function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
|
|
116485
116681
|
if (!moduleNames.length)
|
|
116486
116682
|
return ts.emptyArray;
|
|
@@ -116492,6 +116688,7 @@ var ts;
|
|
|
116492
116688
|
ts.performance.mark("afterResolveModule");
|
|
116493
116689
|
ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
|
|
116494
116690
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
|
|
116691
|
+
pullDiagnosticsFromCache(moduleNames, containingFile);
|
|
116495
116692
|
return result;
|
|
116496
116693
|
}
|
|
116497
116694
|
function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
|
|
@@ -120928,8 +121125,8 @@ var ts;
|
|
|
120928
121125
|
!!redirectedReference;
|
|
120929
121126
|
var seenNamesInFile = ts.createModeAwareCache();
|
|
120930
121127
|
var i = 0;
|
|
120931
|
-
for (var _i = 0,
|
|
120932
|
-
var entry =
|
|
121128
|
+
for (var _i = 0, names_5 = names; _i < names_5.length; _i++) {
|
|
121129
|
+
var entry = names_5[_i];
|
|
120933
121130
|
var name = ts.isString(entry) ? entry : entry.fileName.toLowerCase();
|
|
120934
121131
|
// Imports supply a `containingSourceFile` but no `containingSourceFileMode` - it would be redundant
|
|
120935
121132
|
// they require calculating the mode for a given import from it's position in the resolution table, since a given
|
|
@@ -121539,14 +121736,14 @@ var ts;
|
|
|
121539
121736
|
if (options === void 0) { options = {}; }
|
|
121540
121737
|
var info = getInfo(importingSourceFile.path, host);
|
|
121541
121738
|
var modulePaths = getAllModulePaths(importingSourceFile.path, nodeModulesFileName, host, preferences, options);
|
|
121542
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121739
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, /*packageNameOnly*/ true, options.overrideImportMode); });
|
|
121543
121740
|
}
|
|
121544
121741
|
moduleSpecifiers_1.getNodeModulesPackageName = getNodeModulesPackageName;
|
|
121545
121742
|
function getModuleSpecifierWorker(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences, userPreferences, options) {
|
|
121546
121743
|
if (options === void 0) { options = {}; }
|
|
121547
121744
|
var info = getInfo(importingSourceFileName, host);
|
|
121548
121745
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
121549
|
-
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121746
|
+
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
121550
121747
|
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
121551
121748
|
}
|
|
121552
121749
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
@@ -121622,7 +121819,7 @@ var ts;
|
|
|
121622
121819
|
var relativeSpecifiers;
|
|
121623
121820
|
for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
|
|
121624
121821
|
var modulePath = modulePaths_1[_i];
|
|
121625
|
-
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
121822
|
+
var specifier = tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode);
|
|
121626
121823
|
nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
|
|
121627
121824
|
if (specifier && modulePath.isRedirect) {
|
|
121628
121825
|
// If we got a specifier for a redirect, it was a bare package specifier (e.g. "@foo/bar",
|
|
@@ -122015,7 +122212,7 @@ var ts;
|
|
|
122015
122212
|
? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
|
|
122016
122213
|
: ts.removeFileExtension(relativePath);
|
|
122017
122214
|
}
|
|
122018
|
-
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, packageNameOnly, overrideMode) {
|
|
122215
|
+
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
122019
122216
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
122020
122217
|
var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
|
|
122021
122218
|
if (!host.fileExists || !host.readFile) {
|
|
@@ -122029,8 +122226,9 @@ var ts;
|
|
|
122029
122226
|
var moduleSpecifier = path;
|
|
122030
122227
|
var isPackageRootPath = false;
|
|
122031
122228
|
if (!packageNameOnly) {
|
|
122229
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
122032
122230
|
var packageRootIndex = parts.packageRootIndex;
|
|
122033
|
-
var
|
|
122231
|
+
var moduleFileName = void 0;
|
|
122034
122232
|
while (true) {
|
|
122035
122233
|
// If the module could be imported by a directory name, use that directory's name
|
|
122036
122234
|
var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath, blockedByExports = _c.blockedByExports, verbatimFromExports = _c.verbatimFromExports;
|
|
@@ -122047,12 +122245,12 @@ var ts;
|
|
|
122047
122245
|
isPackageRootPath = true;
|
|
122048
122246
|
break;
|
|
122049
122247
|
}
|
|
122050
|
-
if (!
|
|
122051
|
-
|
|
122248
|
+
if (!moduleFileName)
|
|
122249
|
+
moduleFileName = moduleFileToTry;
|
|
122052
122250
|
// try with next level of directory
|
|
122053
122251
|
packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
|
|
122054
122252
|
if (packageRootIndex === -1) {
|
|
122055
|
-
moduleSpecifier =
|
|
122253
|
+
moduleSpecifier = removeExtensionAndIndexPostFix(moduleFileName, preferences.ending, options, host);
|
|
122056
122254
|
break;
|
|
122057
122255
|
}
|
|
122058
122256
|
}
|
|
@@ -122110,7 +122308,7 @@ var ts;
|
|
|
122110
122308
|
}
|
|
122111
122309
|
}
|
|
122112
122310
|
// If the file is the main module, it can be imported by the package name
|
|
122113
|
-
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
|
|
122311
|
+
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
122114
122312
|
if (ts.isString(mainFileRelative)) {
|
|
122115
122313
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
122116
122314
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
@@ -122118,17 +122316,14 @@ var ts;
|
|
|
122118
122316
|
}
|
|
122119
122317
|
}
|
|
122120
122318
|
}
|
|
122121
|
-
|
|
122122
|
-
|
|
122123
|
-
|
|
122124
|
-
|
|
122125
|
-
|
|
122126
|
-
|
|
122127
|
-
// IFF there is not _also_ a file by the same name
|
|
122128
|
-
if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
|
|
122129
|
-
return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
|
|
122319
|
+
else {
|
|
122320
|
+
// No package.json exists; an index.js will still resolve as the package name
|
|
122321
|
+
var fileName = getCanonicalFileName(moduleFileToTry.substring(parts.packageRootIndex + 1));
|
|
122322
|
+
if (fileName === "index.d.ts" || fileName === "index.js" || fileName === "index.ts" || fileName === "index.tsx") {
|
|
122323
|
+
return { moduleFileToTry: moduleFileToTry, packageRootPath: packageRootPath };
|
|
122324
|
+
}
|
|
122130
122325
|
}
|
|
122131
|
-
return
|
|
122326
|
+
return { moduleFileToTry: moduleFileToTry };
|
|
122132
122327
|
}
|
|
122133
122328
|
}
|
|
122134
122329
|
function tryGetAnyFileFromPath(host, path) {
|
|
@@ -122150,7 +122345,7 @@ var ts;
|
|
|
122150
122345
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
122151
122346
|
});
|
|
122152
122347
|
}
|
|
122153
|
-
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
122348
|
+
function removeExtensionAndIndexPostFix(fileName, ending, options, host) {
|
|
122154
122349
|
if (ts.fileExtensionIsOneOf(fileName, [".json" /* Json */, ".mjs" /* Mjs */, ".cjs" /* Cjs */]))
|
|
122155
122350
|
return fileName;
|
|
122156
122351
|
var noExtension = ts.removeFileExtension(fileName);
|
|
@@ -122158,7 +122353,13 @@ var ts;
|
|
|
122158
122353
|
return noExtension + getJSExtensionForFile(fileName, options);
|
|
122159
122354
|
switch (ending) {
|
|
122160
122355
|
case 0 /* Minimal */:
|
|
122161
|
-
|
|
122356
|
+
var withoutIndex = ts.removeSuffix(noExtension, "/index");
|
|
122357
|
+
if (host && withoutIndex !== noExtension && tryGetAnyFileFromPath(host, withoutIndex)) {
|
|
122358
|
+
// Can't remove index if there's a file by the same name as the directory.
|
|
122359
|
+
// Probably more callers should pass `host` so we can determine this?
|
|
122360
|
+
return noExtension;
|
|
122361
|
+
}
|
|
122362
|
+
return withoutIndex;
|
|
122162
122363
|
case 1 /* Index */:
|
|
122163
122364
|
return noExtension;
|
|
122164
122365
|
case 2 /* JsExtension */:
|