typescript 4.8.0-dev.20220803 → 4.8.0-dev.20220804
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 +191 -101
- package/lib/tsserver.js +259 -107
- package/lib/tsserverlibrary.js +259 -107
- package/lib/typescript.js +259 -107
- package/lib/typescriptServices.js +259 -107
- package/lib/typingsInstaller.js +256 -107
- package/package.json +4 -1
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220804";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -22063,7 +22063,7 @@ var ts;
|
|
|
22063
22063
|
* Wraps an expression in parentheses if it is needed in order to use the expression for
|
|
22064
22064
|
* property or element access.
|
|
22065
22065
|
*/
|
|
22066
|
-
function parenthesizeLeftSideOfAccess(expression) {
|
|
22066
|
+
function parenthesizeLeftSideOfAccess(expression, optionalChain) {
|
|
22067
22067
|
// isLeftHandSideExpression is almost the correct criterion for when it is not necessary
|
|
22068
22068
|
// to parenthesize the expression before a dot. The known exception is:
|
|
22069
22069
|
//
|
|
@@ -22072,7 +22072,8 @@ var ts;
|
|
|
22072
22072
|
//
|
|
22073
22073
|
var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
|
|
22074
22074
|
if (ts.isLeftHandSideExpression(emittedExpression)
|
|
22075
|
-
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
22075
|
+
&& (emittedExpression.kind !== 209 /* NewExpression */ || emittedExpression.arguments)
|
|
22076
|
+
&& (optionalChain || !ts.isOptionalChain(emittedExpression))) {
|
|
22076
22077
|
// TODO(rbuckton): Verify whether this assertion holds.
|
|
22077
22078
|
return expression;
|
|
22078
22079
|
}
|
|
@@ -23479,7 +23480,7 @@ var ts;
|
|
|
23479
23480
|
// @api
|
|
23480
23481
|
function createDecorator(expression) {
|
|
23481
23482
|
var node = createBaseNode(165 /* Decorator */);
|
|
23482
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
23483
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
23483
23484
|
node.transformFlags |=
|
|
23484
23485
|
propagateChildFlags(node.expression) |
|
|
23485
23486
|
1 /* ContainsTypeScript */ |
|
|
@@ -24280,7 +24281,7 @@ var ts;
|
|
|
24280
24281
|
// @api
|
|
24281
24282
|
function createPropertyAccessExpression(expression, name) {
|
|
24282
24283
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24283
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24284
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24284
24285
|
node.name = asName(name);
|
|
24285
24286
|
node.transformFlags =
|
|
24286
24287
|
propagateChildFlags(node.expression) |
|
|
@@ -24310,7 +24311,7 @@ var ts;
|
|
|
24310
24311
|
function createPropertyAccessChain(expression, questionDotToken, name) {
|
|
24311
24312
|
var node = createBaseExpression(206 /* PropertyAccessExpression */);
|
|
24312
24313
|
node.flags |= 32 /* OptionalChain */;
|
|
24313
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24314
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24314
24315
|
node.questionDotToken = questionDotToken;
|
|
24315
24316
|
node.name = asName(name);
|
|
24316
24317
|
node.transformFlags |=
|
|
@@ -24336,7 +24337,7 @@ var ts;
|
|
|
24336
24337
|
// @api
|
|
24337
24338
|
function createElementAccessExpression(expression, index) {
|
|
24338
24339
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24339
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24340
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24340
24341
|
node.argumentExpression = asExpression(index);
|
|
24341
24342
|
node.transformFlags |=
|
|
24342
24343
|
propagateChildFlags(node.expression) |
|
|
@@ -24364,7 +24365,7 @@ var ts;
|
|
|
24364
24365
|
function createElementAccessChain(expression, questionDotToken, index) {
|
|
24365
24366
|
var node = createBaseExpression(207 /* ElementAccessExpression */);
|
|
24366
24367
|
node.flags |= 32 /* OptionalChain */;
|
|
24367
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24368
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24368
24369
|
node.questionDotToken = questionDotToken;
|
|
24369
24370
|
node.argumentExpression = asExpression(index);
|
|
24370
24371
|
node.transformFlags |=
|
|
@@ -24388,7 +24389,7 @@ var ts;
|
|
|
24388
24389
|
// @api
|
|
24389
24390
|
function createCallExpression(expression, typeArguments, argumentsArray) {
|
|
24390
24391
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24391
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24392
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24392
24393
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24393
24394
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
24394
24395
|
node.transformFlags |=
|
|
@@ -24421,7 +24422,7 @@ var ts;
|
|
|
24421
24422
|
function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
|
|
24422
24423
|
var node = createBaseExpression(208 /* CallExpression */);
|
|
24423
24424
|
node.flags |= 32 /* OptionalChain */;
|
|
24424
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24425
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24425
24426
|
node.questionDotToken = questionDotToken;
|
|
24426
24427
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24427
24428
|
node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
|
|
@@ -24476,7 +24477,7 @@ var ts;
|
|
|
24476
24477
|
// @api
|
|
24477
24478
|
function createTaggedTemplateExpression(tag, typeArguments, template) {
|
|
24478
24479
|
var node = createBaseExpression(210 /* TaggedTemplateExpression */);
|
|
24479
|
-
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
|
|
24480
|
+
node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag, /*optionalChain*/ false);
|
|
24480
24481
|
node.typeArguments = asNodeArray(typeArguments);
|
|
24481
24482
|
node.template = template;
|
|
24482
24483
|
node.transformFlags |=
|
|
@@ -24914,7 +24915,7 @@ var ts;
|
|
|
24914
24915
|
// @api
|
|
24915
24916
|
function createExpressionWithTypeArguments(expression, typeArguments) {
|
|
24916
24917
|
var node = createBaseNode(228 /* ExpressionWithTypeArguments */);
|
|
24917
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24918
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24918
24919
|
node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
|
|
24919
24920
|
node.transformFlags |=
|
|
24920
24921
|
propagateChildFlags(node.expression) |
|
|
@@ -24950,7 +24951,7 @@ var ts;
|
|
|
24950
24951
|
// @api
|
|
24951
24952
|
function createNonNullExpression(expression) {
|
|
24952
24953
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24953
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24954
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
24954
24955
|
node.transformFlags |=
|
|
24955
24956
|
propagateChildFlags(node.expression) |
|
|
24956
24957
|
1 /* ContainsTypeScript */;
|
|
@@ -24969,7 +24970,7 @@ var ts;
|
|
|
24969
24970
|
function createNonNullChain(expression) {
|
|
24970
24971
|
var node = createBaseExpression(230 /* NonNullExpression */);
|
|
24971
24972
|
node.flags |= 32 /* OptionalChain */;
|
|
24972
|
-
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
24973
|
+
node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ true);
|
|
24973
24974
|
node.transformFlags |=
|
|
24974
24975
|
propagateChildFlags(node.expression) |
|
|
24975
24976
|
1 /* ContainsTypeScript */;
|
|
@@ -27173,7 +27174,7 @@ var ts;
|
|
|
27173
27174
|
}
|
|
27174
27175
|
else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) {
|
|
27175
27176
|
thisArg = createVoidZero();
|
|
27176
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
|
|
27177
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee, /*optionalChain*/ false);
|
|
27177
27178
|
}
|
|
27178
27179
|
else if (ts.isPropertyAccessExpression(callee)) {
|
|
27179
27180
|
if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
|
|
@@ -27202,7 +27203,7 @@ var ts;
|
|
|
27202
27203
|
else {
|
|
27203
27204
|
// for `a()` target is `a` and thisArg is `void 0`
|
|
27204
27205
|
thisArg = createVoidZero();
|
|
27205
|
-
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
|
|
27206
|
+
target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression, /*optionalChain*/ false);
|
|
27206
27207
|
}
|
|
27207
27208
|
return { target: target, thisArg: thisArg };
|
|
27208
27209
|
}
|
|
@@ -84194,17 +84195,28 @@ var ts;
|
|
|
84194
84195
|
* the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
|
|
84195
84196
|
*/
|
|
84196
84197
|
function getIterationTypesOfIterable(type, use, errorNode) {
|
|
84198
|
+
var _a, _b;
|
|
84197
84199
|
if (isTypeAny(type)) {
|
|
84198
84200
|
return anyIterationTypes;
|
|
84199
84201
|
}
|
|
84200
84202
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
84201
|
-
var
|
|
84203
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84204
|
+
var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
|
|
84202
84205
|
if (iterationTypes_1 === noIterationTypes) {
|
|
84203
84206
|
if (errorNode) {
|
|
84204
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84207
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84208
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84209
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84210
|
+
}
|
|
84205
84211
|
}
|
|
84206
84212
|
return undefined;
|
|
84207
84213
|
}
|
|
84214
|
+
else if ((_a = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
84215
|
+
for (var _i = 0, _c = errorOutputContainer.errors; _i < _c.length; _i++) {
|
|
84216
|
+
var diag = _c[_i];
|
|
84217
|
+
diagnostics.add(diag);
|
|
84218
|
+
}
|
|
84219
|
+
}
|
|
84208
84220
|
return iterationTypes_1;
|
|
84209
84221
|
}
|
|
84210
84222
|
var cacheKey = use & 2 /* AllowsAsyncIterablesFlag */ ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
|
|
@@ -84212,19 +84224,27 @@ var ts;
|
|
|
84212
84224
|
if (cachedTypes)
|
|
84213
84225
|
return cachedTypes === noIterationTypes ? undefined : cachedTypes;
|
|
84214
84226
|
var allIterationTypes;
|
|
84215
|
-
for (var
|
|
84216
|
-
var constituent =
|
|
84217
|
-
var
|
|
84227
|
+
for (var _d = 0, _e = type.types; _d < _e.length; _d++) {
|
|
84228
|
+
var constituent = _e[_d];
|
|
84229
|
+
var errorOutputContainer = errorNode ? { errors: undefined } : undefined;
|
|
84230
|
+
var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode, errorOutputContainer);
|
|
84218
84231
|
if (iterationTypes_2 === noIterationTypes) {
|
|
84219
84232
|
if (errorNode) {
|
|
84220
|
-
reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84233
|
+
var rootDiag = reportTypeNotIterableError(errorNode, type, !!(use & 2 /* AllowsAsyncIterablesFlag */));
|
|
84234
|
+
if (errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) {
|
|
84235
|
+
ts.addRelatedInfo.apply(void 0, __spreadArray([rootDiag], errorOutputContainer.errors, false));
|
|
84236
|
+
}
|
|
84221
84237
|
}
|
|
84222
84238
|
setCachedIterationTypes(type, cacheKey, noIterationTypes);
|
|
84223
84239
|
return undefined;
|
|
84224
84240
|
}
|
|
84225
|
-
else {
|
|
84226
|
-
|
|
84241
|
+
else if ((_b = errorOutputContainer === null || errorOutputContainer === void 0 ? void 0 : errorOutputContainer.errors) === null || _b === void 0 ? void 0 : _b.length) {
|
|
84242
|
+
for (var _f = 0, _g = errorOutputContainer.errors; _f < _g.length; _f++) {
|
|
84243
|
+
var diag = _g[_f];
|
|
84244
|
+
diagnostics.add(diag);
|
|
84245
|
+
}
|
|
84227
84246
|
}
|
|
84247
|
+
allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
|
|
84228
84248
|
}
|
|
84229
84249
|
var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
|
|
84230
84250
|
setCachedIterationTypes(type, cacheKey, iterationTypes);
|
|
@@ -84252,47 +84272,62 @@ var ts;
|
|
|
84252
84272
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84253
84273
|
* `getIterationTypesOfIterable` instead.
|
|
84254
84274
|
*/
|
|
84255
|
-
function getIterationTypesOfIterableWorker(type, use, errorNode) {
|
|
84275
|
+
function getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer) {
|
|
84256
84276
|
if (isTypeAny(type)) {
|
|
84257
84277
|
return anyIterationTypes;
|
|
84258
84278
|
}
|
|
84279
|
+
// If we are reporting errors and encounter a cached `noIterationTypes`, we should ignore the cached value and continue as if nothing was cached.
|
|
84280
|
+
// In addition, we should not cache any new results for this call.
|
|
84281
|
+
var noCache = false;
|
|
84259
84282
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84260
84283
|
var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
|
|
84261
84284
|
getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
|
|
84262
84285
|
if (iterationTypes) {
|
|
84263
|
-
|
|
84264
|
-
|
|
84265
|
-
|
|
84286
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84287
|
+
// ignore the cached value
|
|
84288
|
+
noCache = true;
|
|
84289
|
+
}
|
|
84290
|
+
else {
|
|
84291
|
+
return use & 8 /* ForOfFlag */ ?
|
|
84292
|
+
getAsyncFromSyncIterationTypes(iterationTypes, errorNode) :
|
|
84293
|
+
iterationTypes;
|
|
84294
|
+
}
|
|
84266
84295
|
}
|
|
84267
84296
|
}
|
|
84268
84297
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84269
84298
|
var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
|
|
84270
84299
|
getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
|
|
84271
84300
|
if (iterationTypes) {
|
|
84272
|
-
if (
|
|
84273
|
-
//
|
|
84274
|
-
|
|
84275
|
-
return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
|
|
84276
|
-
}
|
|
84301
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84302
|
+
// ignore the cached value
|
|
84303
|
+
noCache = true;
|
|
84277
84304
|
}
|
|
84278
84305
|
else {
|
|
84279
|
-
|
|
84306
|
+
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84307
|
+
// for a sync iterable in an async context, only use the cached types if they are valid.
|
|
84308
|
+
if (iterationTypes !== noIterationTypes) {
|
|
84309
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84310
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84311
|
+
}
|
|
84312
|
+
}
|
|
84313
|
+
else {
|
|
84314
|
+
return iterationTypes;
|
|
84315
|
+
}
|
|
84280
84316
|
}
|
|
84281
84317
|
}
|
|
84282
84318
|
}
|
|
84283
84319
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84284
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
|
|
84320
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84285
84321
|
if (iterationTypes !== noIterationTypes) {
|
|
84286
84322
|
return iterationTypes;
|
|
84287
84323
|
}
|
|
84288
84324
|
}
|
|
84289
84325
|
if (use & 1 /* AllowsSyncIterablesFlag */) {
|
|
84290
|
-
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
|
|
84326
|
+
var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode, errorOutputContainer, noCache);
|
|
84291
84327
|
if (iterationTypes !== noIterationTypes) {
|
|
84292
84328
|
if (use & 2 /* AllowsAsyncIterablesFlag */) {
|
|
84293
|
-
|
|
84294
|
-
|
|
84295
|
-
: noIterationTypes);
|
|
84329
|
+
iterationTypes = getAsyncFromSyncIterationTypes(iterationTypes, errorNode);
|
|
84330
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes);
|
|
84296
84331
|
}
|
|
84297
84332
|
else {
|
|
84298
84333
|
return iterationTypes;
|
|
@@ -84313,7 +84348,7 @@ var ts;
|
|
|
84313
84348
|
}
|
|
84314
84349
|
function getIterationTypesOfGlobalIterableType(globalType, resolver) {
|
|
84315
84350
|
var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
|
|
84316
|
-
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84351
|
+
getIterationTypesOfIterableSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84317
84352
|
return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
|
|
84318
84353
|
}
|
|
84319
84354
|
/**
|
|
@@ -84367,40 +84402,56 @@ var ts;
|
|
|
84367
84402
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84368
84403
|
* `getIterationTypesOfIterable` instead.
|
|
84369
84404
|
*/
|
|
84370
|
-
function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
|
|
84405
|
+
function getIterationTypesOfIterableSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84371
84406
|
var _a;
|
|
84372
84407
|
var method = getPropertyOfType(type, getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
|
|
84373
84408
|
var methodType = method && !(method.flags & 16777216 /* Optional */) ? getTypeOfSymbol(method) : undefined;
|
|
84374
84409
|
if (isTypeAny(methodType)) {
|
|
84375
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84410
|
+
return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
84376
84411
|
}
|
|
84377
84412
|
var signatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : undefined;
|
|
84378
84413
|
if (!ts.some(signatures)) {
|
|
84379
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84414
|
+
return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
84380
84415
|
}
|
|
84381
84416
|
var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
|
|
84382
|
-
var iterationTypes = (_a =
|
|
84383
|
-
return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84417
|
+
var iterationTypes = (_a = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache)) !== null && _a !== void 0 ? _a : noIterationTypes;
|
|
84418
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
84384
84419
|
}
|
|
84385
84420
|
function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
|
|
84386
84421
|
var message = allowAsyncIterables
|
|
84387
84422
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
84388
84423
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
84389
|
-
errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84424
|
+
return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
|
|
84425
|
+
}
|
|
84426
|
+
/**
|
|
84427
|
+
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
84428
|
+
*
|
|
84429
|
+
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84430
|
+
* record is returned. Otherwise, `undefined` is returned.
|
|
84431
|
+
*/
|
|
84432
|
+
function getIterationTypesOfIterator(type, resolver, errorNode, errorOutputContainer) {
|
|
84433
|
+
return getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, /*noCache*/ false);
|
|
84390
84434
|
}
|
|
84391
84435
|
/**
|
|
84392
84436
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
84393
84437
|
*
|
|
84394
84438
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84395
84439
|
* record is returned. Otherwise, `undefined` is returned.
|
|
84440
|
+
*
|
|
84441
|
+
* NOTE: You probably don't want to call this directly and should be calling
|
|
84442
|
+
* `getIterationTypesOfIterator` instead.
|
|
84396
84443
|
*/
|
|
84397
|
-
function
|
|
84444
|
+
function getIterationTypesOfIteratorWorker(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84398
84445
|
if (isTypeAny(type)) {
|
|
84399
84446
|
return anyIterationTypes;
|
|
84400
84447
|
}
|
|
84401
84448
|
var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
|
|
84402
|
-
getIterationTypesOfIteratorFast(type, resolver)
|
|
84403
|
-
|
|
84449
|
+
getIterationTypesOfIteratorFast(type, resolver);
|
|
84450
|
+
if (iterationTypes === noIterationTypes && errorNode) {
|
|
84451
|
+
iterationTypes = undefined;
|
|
84452
|
+
noCache = true;
|
|
84453
|
+
}
|
|
84454
|
+
iterationTypes !== null && iterationTypes !== void 0 ? iterationTypes : (iterationTypes = getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache));
|
|
84404
84455
|
return iterationTypes === noIterationTypes ? undefined : iterationTypes;
|
|
84405
84456
|
}
|
|
84406
84457
|
/**
|
|
@@ -84438,7 +84489,7 @@ var ts;
|
|
|
84438
84489
|
// iteration types of their `next`, `return`, and `throw` methods. While we define these as `any`
|
|
84439
84490
|
// and `undefined` in our libs by default, a custom lib *could* use different definitions.
|
|
84440
84491
|
var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
|
|
84441
|
-
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined);
|
|
84492
|
+
getIterationTypesOfIteratorSlow(globalType, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined, /*noCache*/ false);
|
|
84442
84493
|
var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
|
|
84443
84494
|
return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
|
|
84444
84495
|
}
|
|
@@ -84508,8 +84559,8 @@ var ts;
|
|
|
84508
84559
|
* If we successfully found the *yield*, *return*, and *next* types, an `IterationTypes`
|
|
84509
84560
|
* record is returned. Otherwise, we return `undefined`.
|
|
84510
84561
|
*/
|
|
84511
|
-
function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
|
|
84512
|
-
var _a, _b, _c, _d;
|
|
84562
|
+
function getIterationTypesOfMethod(type, resolver, methodName, errorNode, errorOutputContainer) {
|
|
84563
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84513
84564
|
var method = getPropertyOfType(type, methodName);
|
|
84514
84565
|
// Ignore 'return' or 'throw' if they are missing.
|
|
84515
84566
|
if (!method && methodName !== "next") {
|
|
@@ -84529,9 +84580,15 @@ var ts;
|
|
|
84529
84580
|
var diagnostic = methodName === "next"
|
|
84530
84581
|
? resolver.mustHaveANextMethodDiagnostic
|
|
84531
84582
|
: resolver.mustBeAMethodDiagnostic;
|
|
84532
|
-
|
|
84583
|
+
if (errorOutputContainer) {
|
|
84584
|
+
(_a = errorOutputContainer.errors) !== null && _a !== void 0 ? _a : (errorOutputContainer.errors = []);
|
|
84585
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, diagnostic, methodName));
|
|
84586
|
+
}
|
|
84587
|
+
else {
|
|
84588
|
+
error(errorNode, diagnostic, methodName);
|
|
84589
|
+
}
|
|
84533
84590
|
}
|
|
84534
|
-
return methodName === "next" ?
|
|
84591
|
+
return methodName === "next" ? noIterationTypes : undefined;
|
|
84535
84592
|
}
|
|
84536
84593
|
// If the method signature comes exclusively from the global iterator or generator type,
|
|
84537
84594
|
// create iteration types from its type arguments like `getIterationTypesOfIteratorFast`
|
|
@@ -84543,8 +84600,8 @@ var ts;
|
|
|
84543
84600
|
if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
|
|
84544
84601
|
var globalGeneratorType = resolver.getGlobalGeneratorType(/*reportErrors*/ false);
|
|
84545
84602
|
var globalIteratorType = resolver.getGlobalIteratorType(/*reportErrors*/ false);
|
|
84546
|
-
var isGeneratorMethod = ((
|
|
84547
|
-
var isIteratorMethod = !isGeneratorMethod && ((
|
|
84603
|
+
var isGeneratorMethod = ((_c = (_b = globalGeneratorType.symbol) === null || _b === void 0 ? void 0 : _b.members) === null || _c === void 0 ? void 0 : _c.get(methodName)) === methodType.symbol;
|
|
84604
|
+
var isIteratorMethod = !isGeneratorMethod && ((_e = (_d = globalIteratorType.symbol) === null || _d === void 0 ? void 0 : _d.members) === null || _e === void 0 ? void 0 : _e.get(methodName)) === methodType.symbol;
|
|
84548
84605
|
if (isGeneratorMethod || isIteratorMethod) {
|
|
84549
84606
|
var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
|
|
84550
84607
|
var mapper = methodType.mapper;
|
|
@@ -84584,7 +84641,13 @@ var ts;
|
|
|
84584
84641
|
var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
|
|
84585
84642
|
if (iterationTypes === noIterationTypes) {
|
|
84586
84643
|
if (errorNode) {
|
|
84587
|
-
|
|
84644
|
+
if (errorOutputContainer) {
|
|
84645
|
+
(_f = errorOutputContainer.errors) !== null && _f !== void 0 ? _f : (errorOutputContainer.errors = []);
|
|
84646
|
+
errorOutputContainer.errors.push(ts.createDiagnosticForNode(errorNode, resolver.mustHaveAValueDiagnostic, methodName));
|
|
84647
|
+
}
|
|
84648
|
+
else {
|
|
84649
|
+
error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
|
|
84650
|
+
}
|
|
84588
84651
|
}
|
|
84589
84652
|
yieldType = anyType;
|
|
84590
84653
|
returnTypes = ts.append(returnTypes, anyType);
|
|
@@ -84605,13 +84668,13 @@ var ts;
|
|
|
84605
84668
|
* NOTE: You probably don't want to call this directly and should be calling
|
|
84606
84669
|
* `getIterationTypesOfIterator` instead.
|
|
84607
84670
|
*/
|
|
84608
|
-
function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
|
|
84671
|
+
function getIterationTypesOfIteratorSlow(type, resolver, errorNode, errorOutputContainer, noCache) {
|
|
84609
84672
|
var iterationTypes = combineIterationTypes([
|
|
84610
|
-
getIterationTypesOfMethod(type, resolver, "next", errorNode),
|
|
84611
|
-
getIterationTypesOfMethod(type, resolver, "return", errorNode),
|
|
84612
|
-
getIterationTypesOfMethod(type, resolver, "throw", errorNode),
|
|
84673
|
+
getIterationTypesOfMethod(type, resolver, "next", errorNode, errorOutputContainer),
|
|
84674
|
+
getIterationTypesOfMethod(type, resolver, "return", errorNode, errorOutputContainer),
|
|
84675
|
+
getIterationTypesOfMethod(type, resolver, "throw", errorNode, errorOutputContainer),
|
|
84613
84676
|
]);
|
|
84614
|
-
return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84677
|
+
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
|
|
84615
84678
|
}
|
|
84616
84679
|
/**
|
|
84617
84680
|
* Gets the requested "iteration type" from a type that is either `Iterable`-like, `Iterator`-like,
|
|
@@ -84632,7 +84695,7 @@ var ts;
|
|
|
84632
84695
|
var use = isAsyncGenerator ? 2 /* AsyncGeneratorReturnType */ : 1 /* GeneratorReturnType */;
|
|
84633
84696
|
var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
|
|
84634
84697
|
return getIterationTypesOfIterable(type, use, /*errorNode*/ undefined) ||
|
|
84635
|
-
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined);
|
|
84698
|
+
getIterationTypesOfIterator(type, resolver, /*errorNode*/ undefined, /*errorOutputContainer*/ undefined);
|
|
84636
84699
|
}
|
|
84637
84700
|
function checkBreakOrContinueStatement(node) {
|
|
84638
84701
|
// Grammar checking
|
|
@@ -122929,8 +122992,6 @@ var ts;
|
|
|
122929
122992
|
if (watcher.files === 0 && watcher.resolutions === 0) {
|
|
122930
122993
|
fileWatchesOfAffectingLocations.delete(path);
|
|
122931
122994
|
watcher.watcher.close();
|
|
122932
|
-
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
122933
|
-
watcher.watcher = ts.noopFileWatcher;
|
|
122934
122995
|
}
|
|
122935
122996
|
});
|
|
122936
122997
|
hasChangedAutomaticTypeDirectiveNames = false;
|
|
@@ -123276,20 +123337,27 @@ var ts;
|
|
|
123276
123337
|
}
|
|
123277
123338
|
var paths = new ts.Set();
|
|
123278
123339
|
paths.add(locationToWatch);
|
|
123340
|
+
var actualWatcher = canWatchDirectoryOrFile(resolutionHost.toPath(locationToWatch)) ?
|
|
123341
|
+
resolutionHost.watchAffectingFileLocation(locationToWatch, function (fileName, eventKind) {
|
|
123342
|
+
cachedDirectoryStructureHost === null || cachedDirectoryStructureHost === void 0 ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
|
|
123343
|
+
var packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
123344
|
+
paths.forEach(function (path) {
|
|
123345
|
+
if (watcher.resolutions)
|
|
123346
|
+
(affectingPathChecks !== null && affectingPathChecks !== void 0 ? affectingPathChecks : (affectingPathChecks = new ts.Set())).add(path);
|
|
123347
|
+
if (watcher.files)
|
|
123348
|
+
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123349
|
+
packageJsonMap === null || packageJsonMap === void 0 ? void 0 : packageJsonMap.delete(resolutionHost.toPath(path));
|
|
123350
|
+
});
|
|
123351
|
+
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123352
|
+
}) : ts.noopFileWatcher;
|
|
123279
123353
|
var watcher = {
|
|
123280
|
-
watcher:
|
|
123281
|
-
|
|
123282
|
-
|
|
123283
|
-
|
|
123284
|
-
|
|
123285
|
-
|
|
123286
|
-
|
|
123287
|
-
if (watcher.files)
|
|
123288
|
-
(affectingPathChecksForFile !== null && affectingPathChecksForFile !== void 0 ? affectingPathChecksForFile : (affectingPathChecksForFile = new ts.Set())).add(path);
|
|
123289
|
-
(_a = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap()) === null || _a === void 0 ? void 0 : _a.delete(resolutionHost.toPath(path));
|
|
123290
|
-
});
|
|
123291
|
-
resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
|
|
123292
|
-
}) : ts.noopFileWatcher,
|
|
123354
|
+
watcher: actualWatcher !== ts.noopFileWatcher ? {
|
|
123355
|
+
close: function () {
|
|
123356
|
+
actualWatcher.close();
|
|
123357
|
+
// Ensure when watching symlinked package.json, we can close the actual file watcher only once
|
|
123358
|
+
actualWatcher = ts.noopFileWatcher;
|
|
123359
|
+
}
|
|
123360
|
+
} : actualWatcher,
|
|
123293
123361
|
resolutions: forResolution ? 1 : 0,
|
|
123294
123362
|
files: forResolution ? 0 : 1,
|
|
123295
123363
|
paths: paths,
|
|
@@ -123703,7 +123771,7 @@ var ts;
|
|
|
123703
123771
|
var info = getInfo(importingSourceFileName, host);
|
|
123704
123772
|
var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host, userPreferences, options);
|
|
123705
123773
|
return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, userPreferences, /*packageNameOnly*/ undefined, options.overrideImportMode); }) ||
|
|
123706
|
-
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
|
|
123774
|
+
getLocalModuleSpecifier(toFileName, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123707
123775
|
}
|
|
123708
123776
|
function tryGetModuleSpecifiersFromCache(moduleSymbol, importingSourceFile, host, userPreferences, options) {
|
|
123709
123777
|
if (options === void 0) { options = {}; }
|
|
@@ -123786,7 +123854,7 @@ var ts;
|
|
|
123786
123854
|
return nodeModulesSpecifiers;
|
|
123787
123855
|
}
|
|
123788
123856
|
if (!specifier && !modulePath.isRedirect) {
|
|
123789
|
-
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
|
|
123857
|
+
var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, options.overrideImportMode || importingSourceFile.impliedNodeFormat, preferences);
|
|
123790
123858
|
if (ts.pathIsBareSpecifier(local)) {
|
|
123791
123859
|
pathsSpecifiers = ts.append(pathsSpecifiers, local);
|
|
123792
123860
|
}
|
|
@@ -123814,7 +123882,7 @@ var ts;
|
|
|
123814
123882
|
var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
|
|
123815
123883
|
return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory };
|
|
123816
123884
|
}
|
|
123817
|
-
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) {
|
|
123885
|
+
function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, importMode, _a) {
|
|
123818
123886
|
var ending = _a.ending, relativePreference = _a.relativePreference;
|
|
123819
123887
|
var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
|
|
123820
123888
|
var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
|
|
@@ -123828,9 +123896,8 @@ var ts;
|
|
|
123828
123896
|
if (!relativeToBaseUrl) {
|
|
123829
123897
|
return relativePath;
|
|
123830
123898
|
}
|
|
123831
|
-
var
|
|
123832
|
-
var
|
|
123833
|
-
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
|
|
123899
|
+
var fromPaths = paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, getAllowedEndings(ending, compilerOptions, importMode), host, compilerOptions);
|
|
123900
|
+
var nonRelative = fromPaths === undefined && baseUrl !== undefined ? removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions) : fromPaths;
|
|
123834
123901
|
if (!nonRelative) {
|
|
123835
123902
|
return relativePath;
|
|
123836
123903
|
}
|
|
@@ -124065,28 +124132,102 @@ var ts;
|
|
|
124065
124132
|
return ambientModuleDeclare.name.text;
|
|
124066
124133
|
}
|
|
124067
124134
|
}
|
|
124068
|
-
function
|
|
124135
|
+
function getAllowedEndings(preferredEnding, compilerOptions, importMode) {
|
|
124136
|
+
if (ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && importMode === ts.ModuleKind.ESNext) {
|
|
124137
|
+
return [2 /* JsExtension */];
|
|
124138
|
+
}
|
|
124139
|
+
switch (preferredEnding) {
|
|
124140
|
+
case 2 /* JsExtension */: return [2 /* JsExtension */, 0 /* Minimal */, 1 /* Index */];
|
|
124141
|
+
case 1 /* Index */: return [1 /* Index */, 0 /* Minimal */, 2 /* JsExtension */];
|
|
124142
|
+
case 0 /* Minimal */: return [0 /* Minimal */, 1 /* Index */, 2 /* JsExtension */];
|
|
124143
|
+
default: ts.Debug.assertNever(preferredEnding);
|
|
124144
|
+
}
|
|
124145
|
+
}
|
|
124146
|
+
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
124069
124147
|
for (var key in paths) {
|
|
124070
|
-
|
|
124071
|
-
var
|
|
124072
|
-
var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
|
|
124148
|
+
var _loop_36 = function (patternText_1) {
|
|
124149
|
+
var pattern = ts.normalizePath(patternText_1);
|
|
124073
124150
|
var indexOfStar = pattern.indexOf("*");
|
|
124151
|
+
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
124152
|
+
// meaning a '.ts' or '.d.ts' extension is allowed to resolve. This is distinct from the case where a '*' substitution
|
|
124153
|
+
// causes a module specifier to have an extension, i.e. the extension comes from the module specifier in a JS/TS file
|
|
124154
|
+
// and matches the '*'. For example:
|
|
124155
|
+
//
|
|
124156
|
+
// Module Specifier | Path Mapping (key: [pattern]) | Interpolation | Resolution Action
|
|
124157
|
+
// ---------------------->------------------------------->--------------------->---------------------------------------------------------------
|
|
124158
|
+
// import "@app/foo" -> "@app/*": ["./src/app/*.ts"] -> "./src/app/foo.ts" -> tryFile("./src/app/foo.ts") || [continue resolution algorithm]
|
|
124159
|
+
// import "@app/foo.ts" -> "@app/*": ["./src/app/*"] -> "./src/app/foo.ts" -> [continue resolution algorithm]
|
|
124160
|
+
//
|
|
124161
|
+
// (https://github.com/microsoft/TypeScript/blob/ad4ded80e1d58f0bf36ac16bea71bc10d9f09895/src/compiler/moduleNameResolver.ts#L2509-L2516)
|
|
124162
|
+
//
|
|
124163
|
+
// The interpolation produced by both scenarios is identical, but only in the former, where the extension is encoded in
|
|
124164
|
+
// the path mapping rather than in the module specifier, will we prioritize a file lookup on the interpolation result.
|
|
124165
|
+
// (In fact, currently, the latter scenario will necessarily fail since no resolution mode recognizes '.ts' as a valid
|
|
124166
|
+
// extension for a module specifier.)
|
|
124167
|
+
//
|
|
124168
|
+
// Here, this means we need to be careful about whether we generate a match from the target filename (typically with a
|
|
124169
|
+
// .ts extension) or the possible relative module specifiers representing that file:
|
|
124170
|
+
//
|
|
124171
|
+
// Filename | Relative Module Specifier Candidates | Path Mapping | Filename Result | Module Specifier Results
|
|
124172
|
+
// --------------------<----------------------------------------------<------------------------------<-------------------||----------------------------
|
|
124173
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*.d.ts"] <- @app/haha || (none)
|
|
124174
|
+
// dist/haha.d.ts <- dist/haha, dist/haha.js <- "@app/*": ["./dist/*"] <- (none) || @app/haha, @app/haha.js
|
|
124175
|
+
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*.d.ts"] <- @app/foo/index || (none)
|
|
124176
|
+
// dist/foo/index.d.ts <- dist/foo, dist/foo/index, dist/foo/index.js <- "@app/*": ["./dist/*"] <- (none) || @app/foo, @app/foo/index, @app/foo/index.js
|
|
124177
|
+
// dist/wow.js.js <- dist/wow.js, dist/wow.js.js <- "@app/*": ["./dist/*.js"] <- @app/wow.js || @app/wow, @app/wow.js
|
|
124178
|
+
//
|
|
124179
|
+
// The "Filename Result" can be generated only if `pattern` has an extension. Care must be taken that the list of
|
|
124180
|
+
// relative module specifiers to run the interpolation (a) is actually valid for the module resolution mode, (b) takes
|
|
124181
|
+
// into account the existence of other files (e.g. 'dist/wow.js' cannot refer to 'dist/wow.js.js' if 'dist/wow.js'
|
|
124182
|
+
// exists) and (c) that they are ordered by preference. The last row shows that the filename result and module
|
|
124183
|
+
// specifier results are not mutually exclusive. Note that the filename result is a higher priority in module
|
|
124184
|
+
// resolution, but as long criteria (b) above is met, I don't think its result needs to be the highest priority result
|
|
124185
|
+
// in module specifier generation. I have included it last, as it's difficult to tell exactly where it should be
|
|
124186
|
+
// sorted among the others for a particular value of `importModuleSpecifierEnding`.
|
|
124187
|
+
var candidates = allowedEndings.map(function (ending) { return ({
|
|
124188
|
+
ending: ending,
|
|
124189
|
+
value: removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions)
|
|
124190
|
+
}); });
|
|
124191
|
+
if (ts.tryGetExtensionFromPath(pattern)) {
|
|
124192
|
+
candidates.push({ ending: undefined, value: relativeToBaseUrl });
|
|
124193
|
+
}
|
|
124074
124194
|
if (indexOfStar !== -1) {
|
|
124075
|
-
var prefix = pattern.
|
|
124076
|
-
var suffix = pattern.
|
|
124077
|
-
|
|
124078
|
-
|
|
124079
|
-
|
|
124080
|
-
|
|
124081
|
-
|
|
124082
|
-
|
|
124195
|
+
var prefix = pattern.substring(0, indexOfStar);
|
|
124196
|
+
var suffix = pattern.substring(indexOfStar + 1);
|
|
124197
|
+
for (var _b = 0, candidates_3 = candidates; _b < candidates_3.length; _b++) {
|
|
124198
|
+
var _c = candidates_3[_b], ending = _c.ending, value = _c.value;
|
|
124199
|
+
if (value.length >= prefix.length + suffix.length &&
|
|
124200
|
+
ts.startsWith(value, prefix) &&
|
|
124201
|
+
ts.endsWith(value, suffix) &&
|
|
124202
|
+
validateEnding({ ending: ending, value: value })) {
|
|
124203
|
+
var matchedStar = value.substring(prefix.length, value.length - suffix.length);
|
|
124204
|
+
return { value: key.replace("*", matchedStar) };
|
|
124205
|
+
}
|
|
124083
124206
|
}
|
|
124084
124207
|
}
|
|
124085
|
-
else if (
|
|
124086
|
-
return
|
|
124208
|
+
else if (ts.some(candidates, function (c) { return c.ending !== 0 /* Minimal */ && pattern === c.value; }) ||
|
|
124209
|
+
ts.some(candidates, function (c) { return c.ending === 0 /* Minimal */ && pattern === c.value && validateEnding(c); })) {
|
|
124210
|
+
return { value: key };
|
|
124087
124211
|
}
|
|
124212
|
+
};
|
|
124213
|
+
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
124214
|
+
var patternText_1 = _a[_i];
|
|
124215
|
+
var state_12 = _loop_36(patternText_1);
|
|
124216
|
+
if (typeof state_12 === "object")
|
|
124217
|
+
return state_12.value;
|
|
124088
124218
|
}
|
|
124089
124219
|
}
|
|
124220
|
+
function validateEnding(_a) {
|
|
124221
|
+
var ending = _a.ending, value = _a.value;
|
|
124222
|
+
// Optimization: `removeExtensionAndIndexPostFix` can query the file system (a good bit) if `ending` is `Minimal`, the basename
|
|
124223
|
+
// is 'index', and a `host` is provided. To avoid that until it's unavoidable, we ran the function with no `host` above. Only
|
|
124224
|
+
// here, after we've checked that the minimal ending is indeed a match (via the length and prefix/suffix checks / `some` calls),
|
|
124225
|
+
// do we check that the host-validated result is consistent with the answer we got before. If it's not, it falls back to the
|
|
124226
|
+
// `Ending.Index` result, which should already be in the list of candidates if `Minimal` was. (Note: the assumption here is
|
|
124227
|
+
// that every module resolution mode that supports dropping extensions also supports dropping `/index`. Like literally
|
|
124228
|
+
// everything else in this file, this logic needs to be updated if that's not true in some future module resolution mode.)
|
|
124229
|
+
return ending !== 0 /* Minimal */ || value === removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions, host);
|
|
124230
|
+
}
|
|
124090
124231
|
}
|
|
124091
124232
|
var MatchingMode;
|
|
124092
124233
|
(function (MatchingMode) {
|
|
@@ -124182,10 +124323,10 @@ var ts;
|
|
|
124182
124323
|
return undefined;
|
|
124183
124324
|
}
|
|
124184
124325
|
// Simplify the full file path to something that can be resolved by Node.
|
|
124326
|
+
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
124185
124327
|
var moduleSpecifier = path;
|
|
124186
124328
|
var isPackageRootPath = false;
|
|
124187
124329
|
if (!packageNameOnly) {
|
|
124188
|
-
var preferences = getPreferences(host, userPreferences, options, importingSourceFile);
|
|
124189
124330
|
var packageRootIndex = parts.packageRootIndex;
|
|
124190
124331
|
var moduleFileName = void 0;
|
|
124191
124332
|
while (true) {
|
|
@@ -124234,15 +124375,13 @@ var ts;
|
|
|
124234
124375
|
var packageRootPath = path.substring(0, packageRootIndex);
|
|
124235
124376
|
var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
|
|
124236
124377
|
var moduleFileToTry = path;
|
|
124378
|
+
var maybeBlockedByTypesVersions = false;
|
|
124237
124379
|
var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
|
|
124238
124380
|
if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
|
|
124239
124381
|
var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
|
|
124382
|
+
var importMode = overrideMode || importingSourceFile.impliedNodeFormat;
|
|
124240
124383
|
if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node16 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
|
|
124241
|
-
|
|
124242
|
-
// an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
|
|
124243
|
-
// usually called to conjure an import out of thin air, we don't have an existing usage to call `getModeForUsageAtIndex`
|
|
124244
|
-
// with, so for now we just stick with the mode of the file.
|
|
124245
|
-
var conditions = ["node", overrideMode || importingSourceFile.impliedNodeFormat === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124384
|
+
var conditions = ["node", importMode === ts.ModuleKind.ESNext ? "import" : "require", "types"];
|
|
124246
124385
|
var fromExports = packageJsonContent.exports && typeof packageJsonContent.name === "string"
|
|
124247
124386
|
? tryGetModuleNameFromExports(options, path, packageRootPath, ts.getPackageNameFromTypesPackageName(packageJsonContent.name), packageJsonContent.exports, conditions)
|
|
124248
124387
|
: undefined;
|
|
@@ -124261,16 +124400,26 @@ var ts;
|
|
|
124261
124400
|
: undefined;
|
|
124262
124401
|
if (versionPaths) {
|
|
124263
124402
|
var subModuleName = path.slice(packageRootPath.length + 1);
|
|
124264
|
-
var fromPaths = tryGetModuleNameFromPaths(
|
|
124265
|
-
if (fromPaths
|
|
124403
|
+
var fromPaths = tryGetModuleNameFromPaths(subModuleName, versionPaths.paths, getAllowedEndings(preferences.ending, options, importMode), host, options);
|
|
124404
|
+
if (fromPaths === undefined) {
|
|
124405
|
+
maybeBlockedByTypesVersions = true;
|
|
124406
|
+
}
|
|
124407
|
+
else {
|
|
124266
124408
|
moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
|
|
124267
124409
|
}
|
|
124268
124410
|
}
|
|
124269
124411
|
// If the file is the main module, it can be imported by the package name
|
|
124270
124412
|
var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main || "index.js";
|
|
124271
|
-
if (ts.isString(mainFileRelative)) {
|
|
124413
|
+
if (ts.isString(mainFileRelative) && !(maybeBlockedByTypesVersions && ts.matchPatternOrExact(ts.tryParsePatterns(versionPaths.paths), mainFileRelative))) {
|
|
124414
|
+
// The 'main' file is also subject to mapping through typesVersions, and we couldn't come up with a path
|
|
124415
|
+
// explicitly through typesVersions, so if it matches a key in typesVersions now, it's not reachable.
|
|
124416
|
+
// (The only way this can happen is if some file in a package that's not resolvable from outside the
|
|
124417
|
+
// package got pulled into the program anyway, e.g. transitively through a file that *is* reachable. It
|
|
124418
|
+
// happens very easily in fourslash tests though, since every test file listed gets included. See
|
|
124419
|
+
// importNameCodeFix_typesVersions.ts for an example.)
|
|
124272
124420
|
var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
|
|
124273
124421
|
if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
|
|
124422
|
+
// ^ An arbitrary removal of file extension for this comparison is almost certainly wrong
|
|
124274
124423
|
return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
|
|
124275
124424
|
}
|
|
124276
124425
|
}
|
|
@@ -162335,6 +162484,9 @@ var ts;
|
|
|
162335
162484
|
if (!containingDecl) {
|
|
162336
162485
|
return;
|
|
162337
162486
|
}
|
|
162487
|
+
if (ts.isFunctionLikeDeclaration(containingDecl) && containingDecl.body && ts.rangeContainsPosition(containingDecl.body, startPosition)) {
|
|
162488
|
+
return;
|
|
162489
|
+
}
|
|
162338
162490
|
var checker = program.getTypeChecker();
|
|
162339
162491
|
var signatureSymbol = containingDecl.symbol;
|
|
162340
162492
|
if (!signatureSymbol) {
|