typescript 5.1.0-dev.20230331 → 5.1.0-dev.20230402
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 +132 -100
- package/lib/tsserver.js +154 -106
- package/lib/tsserverlibrary.js +148 -106
- package/lib/typescript.js +142 -106
- package/lib/typingsInstaller.js +4 -4
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.1";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20230402`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -6193,7 +6193,7 @@ var Diagnostics = {
|
|
|
6193
6193
|
Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, 1 /* Error */, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."),
|
|
6194
6194
|
Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, 1 /* Error */, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."),
|
|
6195
6195
|
This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, 1 /* Error */, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."),
|
|
6196
|
-
|
|
6196
|
+
A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2355, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
|
|
6197
6197
|
An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, 1 /* Error */, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."),
|
|
6198
6198
|
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, 1 /* Error */, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."),
|
|
6199
6199
|
The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, 1 /* Error */, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."),
|
|
@@ -6633,7 +6633,6 @@ var Diagnostics = {
|
|
|
6633
6633
|
Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2844, 1 /* Error */, "Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844", "Type of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
6634
6634
|
This_condition_will_always_return_0: diag(2845, 1 /* Error */, "This_condition_will_always_return_0_2845", "This condition will always return '{0}'."),
|
|
6635
6635
|
A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_file_0_instead: diag(2846, 1 /* Error */, "A_declaration_file_cannot_be_imported_without_import_type_Did_you_mean_to_import_an_implementation_f_2846", "A declaration file cannot be imported without 'import type'. Did you mean to import an implementation file '{0}' instead?"),
|
|
6636
|
-
A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value: diag(2847, 1 /* Error */, "A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value_2847", "A function whose declared type is neither 'undefined', 'void', nor 'any' must return a value."),
|
|
6637
6636
|
The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression: diag(2848, 1 /* Error */, "The_right_hand_side_of_an_instanceof_expression_must_not_be_an_instantiation_expression_2848", "The right-hand side of an 'instanceof' expression must not be an instantiation expression."),
|
|
6638
6637
|
Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1: diag(2849, 1 /* Error */, "Target_signature_provides_too_few_arguments_Expected_0_or_more_but_got_1_2849", "Target signature provides too few arguments. Expected {0} or more, but got {1}."),
|
|
6639
6638
|
Import_declaration_0_is_using_private_name_1: diag(4e3, 1 /* Error */, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
@@ -16219,6 +16218,9 @@ function getAllowSyntheticDefaultImports(compilerOptions) {
|
|
|
16219
16218
|
function moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution) {
|
|
16220
16219
|
return moduleResolution >= 3 /* Node16 */ && moduleResolution <= 99 /* NodeNext */ || moduleResolution === 100 /* Bundler */;
|
|
16221
16220
|
}
|
|
16221
|
+
function shouldResolveJsRequire(compilerOptions) {
|
|
16222
|
+
return !!compilerOptions.noDtsResolution || getEmitModuleResolutionKind(compilerOptions) !== 100 /* Bundler */;
|
|
16223
|
+
}
|
|
16222
16224
|
function getResolvePackageJsonExports(compilerOptions) {
|
|
16223
16225
|
const moduleResolution = getEmitModuleResolutionKind(compilerOptions);
|
|
16224
16226
|
if (!moduleResolutionSupportsPackageJsonExportsAndImports(moduleResolution)) {
|
|
@@ -34131,7 +34133,8 @@ var commandOptionsWithoutBuild = [
|
|
|
34131
34133
|
affectsBuildInfo: true,
|
|
34132
34134
|
category: Diagnostics.Modules,
|
|
34133
34135
|
description: Diagnostics.Allow_imports_to_include_TypeScript_file_extensions_Requires_moduleResolution_bundler_and_either_noEmit_or_emitDeclarationOnly_to_be_set,
|
|
34134
|
-
defaultValueDescription: false
|
|
34136
|
+
defaultValueDescription: false,
|
|
34137
|
+
transpileOptionValue: void 0
|
|
34135
34138
|
},
|
|
34136
34139
|
{
|
|
34137
34140
|
name: "resolvePackageJsonExports",
|
|
@@ -41292,7 +41295,7 @@ function createBinder() {
|
|
|
41292
41295
|
}
|
|
41293
41296
|
if (!isBindingPattern(node.name)) {
|
|
41294
41297
|
const possibleVariableDecl = node.kind === 258 /* VariableDeclaration */ ? node : node.parent.parent;
|
|
41295
|
-
if (isInJSFile(node) &&
|
|
41298
|
+
if (isInJSFile(node) && shouldResolveJsRequire(options) && isVariableDeclarationInitializedToBareOrAccessedRequire(possibleVariableDecl) && !getJSDocTypeTag(node) && !(getCombinedModifierFlags(node) & 1 /* Export */)) {
|
|
41296
41299
|
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
|
|
41297
41300
|
} else if (isBlockOrCatchScoped(node)) {
|
|
41298
41301
|
bindBlockScopedDeclaration(node, 2 /* BlockScopedVariable */, 111551 /* BlockScopedVariableExcludes */);
|
|
@@ -44903,7 +44906,7 @@ function createTypeChecker(host) {
|
|
|
44903
44906
|
const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
|
|
44904
44907
|
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
|
|
44905
44908
|
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
|
|
44906
|
-
if (hasExportAssignmentSymbol(moduleSymbol) && !
|
|
44909
|
+
if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports) {
|
|
44907
44910
|
const compilerOptionName = moduleKind >= 5 /* ES2015 */ ? "allowSyntheticDefaultImports" : "esModuleInterop";
|
|
44908
44911
|
const exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
|
|
44909
44912
|
const exportAssignment = exportEqualsSymbol.valueDeclaration;
|
|
@@ -45071,7 +45074,7 @@ function createTypeChecker(host) {
|
|
|
45071
45074
|
if (!isIdentifier(name)) {
|
|
45072
45075
|
return void 0;
|
|
45073
45076
|
}
|
|
45074
|
-
const suppressInteropError = name.escapedText === "default" /* Default */ &&
|
|
45077
|
+
const suppressInteropError = name.escapedText === "default" /* Default */ && allowSyntheticDefaultImports;
|
|
45075
45078
|
const targetSymbol = resolveESModuleSymbol(
|
|
45076
45079
|
moduleSymbol,
|
|
45077
45080
|
moduleSpecifier,
|
|
@@ -49713,7 +49716,7 @@ function createTypeChecker(host) {
|
|
|
49713
49716
|
return;
|
|
49714
49717
|
}
|
|
49715
49718
|
let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
|
|
49716
|
-
if (verbatimTargetName === "export=" /* ExportEquals */ &&
|
|
49719
|
+
if (verbatimTargetName === "export=" /* ExportEquals */ && allowSyntheticDefaultImports) {
|
|
49717
49720
|
verbatimTargetName = "default" /* Default */;
|
|
49718
49721
|
}
|
|
49719
49722
|
const targetName = getInternalSymbolName(target, verbatimTargetName);
|
|
@@ -53489,7 +53492,7 @@ function createTypeChecker(host) {
|
|
|
53489
53492
|
}
|
|
53490
53493
|
function isConstTypeVariable(type) {
|
|
53491
53494
|
var _a2;
|
|
53492
|
-
return !!(type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0
|
|
53495
|
+
return !!(type && (type.flags & 262144 /* TypeParameter */ && some((_a2 = type.symbol) == null ? void 0 : _a2.declarations, (d) => hasSyntacticModifier(d, 2048 /* Const */)) || type.flags & 1048576 /* Union */ && some(type.types, isConstTypeVariable) || type.flags & 8388608 /* IndexedAccess */ && isConstTypeVariable(type.objectType) || type.flags & 16777216 /* Conditional */ && isConstTypeVariable(getConstraintOfConditionalType(type)) || type.flags & 33554432 /* Substitution */ && isConstTypeVariable(type.baseType) || isGenericTupleType(type) && findIndex(getTypeArguments(type), (t, i) => !!(type.target.elementFlags[i] & 8 /* Variadic */) && isConstTypeVariable(t)) >= 0));
|
|
53493
53496
|
}
|
|
53494
53497
|
function getConstraintOfIndexedAccess(type) {
|
|
53495
53498
|
return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : void 0;
|
|
@@ -70936,7 +70939,7 @@ function createTypeChecker(host) {
|
|
|
70936
70939
|
return anyType;
|
|
70937
70940
|
}
|
|
70938
70941
|
}
|
|
70939
|
-
if (isInJSFile(node) &&
|
|
70942
|
+
if (isInJSFile(node) && shouldResolveJsRequire(compilerOptions) && isCommonJsRequire(node)) {
|
|
70940
70943
|
return resolveExternalModuleTypeByLiteral(node.arguments[0]);
|
|
70941
70944
|
}
|
|
70942
70945
|
const returnType = getReturnTypeOfSignature(signature);
|
|
@@ -72012,7 +72015,16 @@ function createTypeChecker(host) {
|
|
|
72012
72015
|
return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, neverType) : neverType;
|
|
72013
72016
|
}
|
|
72014
72017
|
if (types.length === 0) {
|
|
72015
|
-
|
|
72018
|
+
const contextualReturnType = getContextualReturnType(
|
|
72019
|
+
func,
|
|
72020
|
+
/*contextFlags*/
|
|
72021
|
+
void 0
|
|
72022
|
+
);
|
|
72023
|
+
const returnType2 = contextualReturnType && (unwrapReturnType(contextualReturnType, functionFlags) || voidType).flags & 32768 /* Undefined */ ? undefinedType : voidType;
|
|
72024
|
+
return functionFlags & 2 /* Async */ ? createPromiseReturnType(func, returnType2) : (
|
|
72025
|
+
// Async function
|
|
72026
|
+
returnType2
|
|
72027
|
+
);
|
|
72016
72028
|
}
|
|
72017
72029
|
returnType = getUnionType(types, 2 /* Subtype */);
|
|
72018
72030
|
}
|
|
@@ -72234,7 +72246,7 @@ function createTypeChecker(host) {
|
|
|
72234
72246
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics() {
|
|
72235
72247
|
const functionFlags = getFunctionFlags(func);
|
|
72236
72248
|
const type = returnType && unwrapReturnType(returnType, functionFlags);
|
|
72237
|
-
if (type && maybeTypeOfKind(type,
|
|
72249
|
+
if (type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */))) {
|
|
72238
72250
|
return;
|
|
72239
72251
|
}
|
|
72240
72252
|
if (func.kind === 171 /* MethodSignature */ || nodeIsMissing(func.body) || func.body.kind !== 239 /* Block */ || !functionHasImplicitReturn(func)) {
|
|
@@ -72245,12 +72257,8 @@ function createTypeChecker(host) {
|
|
|
72245
72257
|
if (type && type.flags & 131072 /* Never */) {
|
|
72246
72258
|
error(errorNode, Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
|
|
72247
72259
|
} else if (type && !hasExplicitReturn) {
|
|
72248
|
-
|
|
72249
|
-
|
|
72250
|
-
} else {
|
|
72251
|
-
error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
|
|
72252
|
-
}
|
|
72253
|
-
} else if (type && strictNullChecks) {
|
|
72260
|
+
error(errorNode, Diagnostics.A_function_whose_declared_type_is_neither_undefined_void_nor_any_must_return_a_value);
|
|
72261
|
+
} else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
|
|
72254
72262
|
error(errorNode, Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
|
|
72255
72263
|
} else if (compilerOptions.noImplicitReturns) {
|
|
72256
72264
|
if (!type) {
|
|
@@ -72258,7 +72266,7 @@ function createTypeChecker(host) {
|
|
|
72258
72266
|
return;
|
|
72259
72267
|
}
|
|
72260
72268
|
const inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
|
|
72261
|
-
if (
|
|
72269
|
+
if (isUnwrappedReturnTypeUndefinedVoidOrAny(func, inferredReturnType)) {
|
|
72262
72270
|
return;
|
|
72263
72271
|
}
|
|
72264
72272
|
}
|
|
@@ -73724,11 +73732,7 @@ function createTypeChecker(host) {
|
|
|
73724
73732
|
}
|
|
73725
73733
|
function isConstContext(node) {
|
|
73726
73734
|
const parent = node.parent;
|
|
73727
|
-
return isAssertionExpression(parent) && isConstTypeReference(parent.type) || isJSDocTypeAssertion(parent) && isConstTypeReference(getJSDocTypeAssertionType(parent)) || isValidConstAssertionArgument(node) &&
|
|
73728
|
-
}
|
|
73729
|
-
function isConstTypeParameterContext(node) {
|
|
73730
|
-
const contextualType = getContextualType(node, 0 /* None */);
|
|
73731
|
-
return !!contextualType && someType(contextualType, isConstTypeVariable);
|
|
73735
|
+
return isAssertionExpression(parent) && isConstTypeReference(parent.type) || isJSDocTypeAssertion(parent) && isConstTypeReference(getJSDocTypeAssertionType(parent)) || isValidConstAssertionArgument(node) && isConstTypeVariable(getContextualType(node, 0 /* None */)) || (isParenthesizedExpression(parent) || isArrayLiteralExpression(parent) || isSpreadElement(parent)) && isConstContext(parent) || (isPropertyAssignment(parent) || isShorthandPropertyAssignment(parent) || isTemplateSpan(parent)) && isConstContext(parent.parent);
|
|
73732
73736
|
}
|
|
73733
73737
|
function checkExpressionForMutableLocation(node, checkMode, forceTuple) {
|
|
73734
73738
|
const type = checkExpression(node, checkMode, forceTuple);
|
|
@@ -77411,9 +77415,9 @@ function createTypeChecker(host) {
|
|
|
77411
77415
|
}
|
|
77412
77416
|
return isAsync ? getAwaitedTypeNoAlias(returnType) || errorType : returnType;
|
|
77413
77417
|
}
|
|
77414
|
-
function
|
|
77415
|
-
const
|
|
77416
|
-
return !!
|
|
77418
|
+
function isUnwrappedReturnTypeUndefinedVoidOrAny(func, returnType) {
|
|
77419
|
+
const type = unwrapReturnType(returnType, getFunctionFlags(func));
|
|
77420
|
+
return !!(type && (maybeTypeOfKind(type, 16384 /* Void */) || type.flags & (1 /* Any */ | 32768 /* Undefined */)));
|
|
77417
77421
|
}
|
|
77418
77422
|
function checkReturnStatement(node) {
|
|
77419
77423
|
var _a2;
|
|
@@ -77455,7 +77459,7 @@ function createTypeChecker(host) {
|
|
|
77455
77459
|
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
|
|
77456
77460
|
}
|
|
77457
77461
|
}
|
|
77458
|
-
} else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !
|
|
77462
|
+
} else if (container.kind !== 174 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
|
|
77459
77463
|
error(node, Diagnostics.Not_all_code_paths_return_a_value);
|
|
77460
77464
|
}
|
|
77461
77465
|
}
|
|
@@ -114677,7 +114681,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
114677
114681
|
false
|
|
114678
114682
|
);
|
|
114679
114683
|
}
|
|
114680
|
-
const shouldProcessRequires = isJavaScriptFile &&
|
|
114684
|
+
const shouldProcessRequires = isJavaScriptFile && shouldResolveJsRequire(options);
|
|
114681
114685
|
if (file.flags & 2097152 /* PossiblyContainsDynamicImport */ || shouldProcessRequires) {
|
|
114682
114686
|
collectDynamicImportOrRequireCalls(file);
|
|
114683
114687
|
}
|
|
@@ -118090,6 +118094,79 @@ function canWatchDirectoryOrFile(dirPath) {
|
|
|
118090
118094
|
}
|
|
118091
118095
|
return true;
|
|
118092
118096
|
}
|
|
118097
|
+
function canWatchAtTypes(atTypes, rootPath) {
|
|
118098
|
+
const dirPath = getDirectoryPath(getDirectoryPath(atTypes));
|
|
118099
|
+
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
|
118100
|
+
}
|
|
118101
|
+
function isInDirectoryPath(dir, file) {
|
|
118102
|
+
if (dir === void 0 || file.length <= dir.length) {
|
|
118103
|
+
return false;
|
|
118104
|
+
}
|
|
118105
|
+
return startsWith(file, dir) && file[dir.length] === directorySeparator;
|
|
118106
|
+
}
|
|
118107
|
+
function canWatchAffectingLocation(filePath) {
|
|
118108
|
+
return canWatchDirectoryOrFile(filePath);
|
|
118109
|
+
}
|
|
118110
|
+
function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath, rootDir, rootPath, rootSplitLength, getCurrentDirectory) {
|
|
118111
|
+
if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
|
|
118112
|
+
failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
|
|
118113
|
+
const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
|
|
118114
|
+
const failedLookupSplit = failedLookupLocation.split(directorySeparator);
|
|
118115
|
+
Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
|
|
118116
|
+
if (failedLookupPathSplit.length > rootSplitLength + 1) {
|
|
118117
|
+
return {
|
|
118118
|
+
dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
|
|
118119
|
+
dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
|
|
118120
|
+
};
|
|
118121
|
+
} else {
|
|
118122
|
+
return {
|
|
118123
|
+
dir: rootDir,
|
|
118124
|
+
dirPath: rootPath,
|
|
118125
|
+
nonRecursive: false
|
|
118126
|
+
};
|
|
118127
|
+
}
|
|
118128
|
+
}
|
|
118129
|
+
return getDirectoryToWatchFromFailedLookupLocationDirectory(
|
|
118130
|
+
getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
|
|
118131
|
+
getDirectoryPath(failedLookupLocationPath),
|
|
118132
|
+
rootPath
|
|
118133
|
+
);
|
|
118134
|
+
}
|
|
118135
|
+
function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath, rootPath) {
|
|
118136
|
+
while (pathContainsNodeModules(dirPath)) {
|
|
118137
|
+
dir = getDirectoryPath(dir);
|
|
118138
|
+
dirPath = getDirectoryPath(dirPath);
|
|
118139
|
+
}
|
|
118140
|
+
if (isNodeModulesDirectory(dirPath)) {
|
|
118141
|
+
return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
|
|
118142
|
+
}
|
|
118143
|
+
let nonRecursive = true;
|
|
118144
|
+
let subDirectoryPath, subDirectory;
|
|
118145
|
+
if (rootPath !== void 0) {
|
|
118146
|
+
while (!isInDirectoryPath(dirPath, rootPath)) {
|
|
118147
|
+
const parentPath = getDirectoryPath(dirPath);
|
|
118148
|
+
if (parentPath === dirPath) {
|
|
118149
|
+
break;
|
|
118150
|
+
}
|
|
118151
|
+
nonRecursive = false;
|
|
118152
|
+
subDirectoryPath = dirPath;
|
|
118153
|
+
subDirectory = dir;
|
|
118154
|
+
dirPath = parentPath;
|
|
118155
|
+
dir = getDirectoryPath(dir);
|
|
118156
|
+
}
|
|
118157
|
+
}
|
|
118158
|
+
return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
|
|
118159
|
+
}
|
|
118160
|
+
function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath, rootPath, filterCustomPath) {
|
|
118161
|
+
if (isInDirectoryPath(rootPath, typeRootPath)) {
|
|
118162
|
+
return rootPath;
|
|
118163
|
+
}
|
|
118164
|
+
const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath, rootPath);
|
|
118165
|
+
return toWatch && filterCustomPath(toWatch.dirPath) ? toWatch.dirPath : void 0;
|
|
118166
|
+
}
|
|
118167
|
+
function getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory) {
|
|
118168
|
+
return rootDirForResolution && removeTrailingDirectorySeparator(getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
|
|
118169
|
+
}
|
|
118093
118170
|
function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
|
|
118094
118171
|
let filesWithChangedSetOfUnresolvedImports;
|
|
118095
118172
|
let filesWithInvalidatedResolutions;
|
|
@@ -118124,7 +118201,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118124
118201
|
const customFailedLookupPaths = /* @__PURE__ */ new Map();
|
|
118125
118202
|
const directoryWatchesOfFailedLookups = /* @__PURE__ */ new Map();
|
|
118126
118203
|
const fileWatchesOfAffectingLocations = /* @__PURE__ */ new Map();
|
|
118127
|
-
const rootDir =
|
|
118204
|
+
const rootDir = getRootDirectoryOfResolutionCache(rootDirForResolution, getCurrentDirectory);
|
|
118128
118205
|
const rootPath = rootDir && resolutionHost.toPath(rootDir);
|
|
118129
118206
|
const rootSplitLength = rootPath !== void 0 ? rootPath.split(directorySeparator).length : 0;
|
|
118130
118207
|
const typeRootsWatches = /* @__PURE__ */ new Map();
|
|
@@ -118157,12 +118234,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118157
118234
|
function getResolvedTypeReferenceDirective(resolution) {
|
|
118158
118235
|
return resolution.resolvedTypeReferenceDirective;
|
|
118159
118236
|
}
|
|
118160
|
-
function isInDirectoryPath(dir, file) {
|
|
118161
|
-
if (dir === void 0 || file.length <= dir.length) {
|
|
118162
|
-
return false;
|
|
118163
|
-
}
|
|
118164
|
-
return startsWith(file, dir) && file[dir.length] === directorySeparator;
|
|
118165
|
-
}
|
|
118166
118237
|
function clear2() {
|
|
118167
118238
|
clearMap(directoryWatchesOfFailedLookups, closeFileWatcherOf);
|
|
118168
118239
|
clearMap(fileWatchesOfAffectingLocations, closeFileWatcherOf);
|
|
@@ -118446,55 +118517,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118446
118517
|
function isNodeModulesAtTypesDirectory(dirPath) {
|
|
118447
118518
|
return endsWith(dirPath, "/node_modules/@types");
|
|
118448
118519
|
}
|
|
118449
|
-
function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
|
|
118450
|
-
if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
|
|
118451
|
-
failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
|
|
118452
|
-
const failedLookupPathSplit = failedLookupLocationPath.split(directorySeparator);
|
|
118453
|
-
const failedLookupSplit = failedLookupLocation.split(directorySeparator);
|
|
118454
|
-
Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, `FailedLookup: ${failedLookupLocation} failedLookupLocationPath: ${failedLookupLocationPath}`);
|
|
118455
|
-
if (failedLookupPathSplit.length > rootSplitLength + 1) {
|
|
118456
|
-
return {
|
|
118457
|
-
dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(directorySeparator),
|
|
118458
|
-
dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(directorySeparator)
|
|
118459
|
-
};
|
|
118460
|
-
} else {
|
|
118461
|
-
return {
|
|
118462
|
-
dir: rootDir,
|
|
118463
|
-
dirPath: rootPath,
|
|
118464
|
-
nonRecursive: false
|
|
118465
|
-
};
|
|
118466
|
-
}
|
|
118467
|
-
}
|
|
118468
|
-
return getDirectoryToWatchFromFailedLookupLocationDirectory(
|
|
118469
|
-
getDirectoryPath(getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())),
|
|
118470
|
-
getDirectoryPath(failedLookupLocationPath)
|
|
118471
|
-
);
|
|
118472
|
-
}
|
|
118473
|
-
function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
|
|
118474
|
-
while (pathContainsNodeModules(dirPath)) {
|
|
118475
|
-
dir = getDirectoryPath(dir);
|
|
118476
|
-
dirPath = getDirectoryPath(dirPath);
|
|
118477
|
-
}
|
|
118478
|
-
if (isNodeModulesDirectory(dirPath)) {
|
|
118479
|
-
return canWatchDirectoryOrFile(getDirectoryPath(dirPath)) ? { dir, dirPath } : void 0;
|
|
118480
|
-
}
|
|
118481
|
-
let nonRecursive = true;
|
|
118482
|
-
let subDirectoryPath, subDirectory;
|
|
118483
|
-
if (rootPath !== void 0) {
|
|
118484
|
-
while (!isInDirectoryPath(dirPath, rootPath)) {
|
|
118485
|
-
const parentPath = getDirectoryPath(dirPath);
|
|
118486
|
-
if (parentPath === dirPath) {
|
|
118487
|
-
break;
|
|
118488
|
-
}
|
|
118489
|
-
nonRecursive = false;
|
|
118490
|
-
subDirectoryPath = dirPath;
|
|
118491
|
-
subDirectory = dir;
|
|
118492
|
-
dirPath = parentPath;
|
|
118493
|
-
dir = getDirectoryPath(dir);
|
|
118494
|
-
}
|
|
118495
|
-
}
|
|
118496
|
-
return canWatchDirectoryOrFile(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : void 0;
|
|
118497
|
-
}
|
|
118498
118520
|
function isPathWithDefaultFailedLookupExtension(path) {
|
|
118499
118521
|
return fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
|
|
118500
118522
|
}
|
|
@@ -118533,7 +118555,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118533
118555
|
if (failedLookupLocations) {
|
|
118534
118556
|
for (const failedLookupLocation of failedLookupLocations) {
|
|
118535
118557
|
const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
|
|
118536
|
-
const toWatch = getDirectoryToWatchFailedLookupLocation(
|
|
118558
|
+
const toWatch = getDirectoryToWatchFailedLookupLocation(
|
|
118559
|
+
failedLookupLocation,
|
|
118560
|
+
failedLookupLocationPath,
|
|
118561
|
+
rootDir,
|
|
118562
|
+
rootPath,
|
|
118563
|
+
rootSplitLength,
|
|
118564
|
+
getCurrentDirectory
|
|
118565
|
+
);
|
|
118537
118566
|
if (toWatch) {
|
|
118538
118567
|
const { dir, dirPath, nonRecursive } = toWatch;
|
|
118539
118568
|
if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
|
|
@@ -118601,7 +118630,7 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118601
118630
|
}
|
|
118602
118631
|
const paths = /* @__PURE__ */ new Set();
|
|
118603
118632
|
paths.add(locationToWatch);
|
|
118604
|
-
let actualWatcher =
|
|
118633
|
+
let actualWatcher = canWatchAffectingLocation(resolutionHost.toPath(locationToWatch)) ? resolutionHost.watchAffectingFileLocation(locationToWatch, (fileName, eventKind) => {
|
|
118605
118634
|
cachedDirectoryStructureHost == null ? void 0 : cachedDirectoryStructureHost.addOrDeleteFile(fileName, resolutionHost.toPath(locationToWatch), eventKind);
|
|
118606
118635
|
const packageJsonMap = moduleResolutionCache.getPackageJsonInfoCache().getInternalMap();
|
|
118607
118636
|
paths.forEach((path) => {
|
|
@@ -118669,7 +118698,14 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118669
118698
|
let removeAtRoot = false;
|
|
118670
118699
|
for (const failedLookupLocation of failedLookupLocations) {
|
|
118671
118700
|
const failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
|
|
118672
|
-
const toWatch = getDirectoryToWatchFailedLookupLocation(
|
|
118701
|
+
const toWatch = getDirectoryToWatchFailedLookupLocation(
|
|
118702
|
+
failedLookupLocation,
|
|
118703
|
+
failedLookupLocationPath,
|
|
118704
|
+
rootDir,
|
|
118705
|
+
rootPath,
|
|
118706
|
+
rootSplitLength,
|
|
118707
|
+
getCurrentDirectory
|
|
118708
|
+
);
|
|
118673
118709
|
if (toWatch) {
|
|
118674
118710
|
const { dirPath } = toWatch;
|
|
118675
118711
|
const refCount = customFailedLookupPaths.get(failedLookupLocationPath);
|
|
@@ -118837,13 +118873,6 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118837
118873
|
function closeTypeRootsWatch() {
|
|
118838
118874
|
clearMap(typeRootsWatches, closeFileWatcher);
|
|
118839
118875
|
}
|
|
118840
|
-
function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
|
|
118841
|
-
if (isInDirectoryPath(rootPath, typeRootPath)) {
|
|
118842
|
-
return rootPath;
|
|
118843
|
-
}
|
|
118844
|
-
const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
|
|
118845
|
-
return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : void 0;
|
|
118846
|
-
}
|
|
118847
118876
|
function createTypeRootsWatch(typeRootPath, typeRoot) {
|
|
118848
118877
|
return canWatchTypeRootPath(typeRootPath) ? resolutionHost.watchTypeRootsDirectory(typeRoot, (fileOrDirectory) => {
|
|
118849
118878
|
const fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
|
|
@@ -118852,7 +118881,12 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118852
118881
|
}
|
|
118853
118882
|
hasChangedAutomaticTypeDirectiveNames = true;
|
|
118854
118883
|
resolutionHost.onChangedAutomaticTypeDirectiveNames();
|
|
118855
|
-
const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
|
|
118884
|
+
const dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(
|
|
118885
|
+
typeRoot,
|
|
118886
|
+
typeRootPath,
|
|
118887
|
+
rootPath,
|
|
118888
|
+
(dirPath2) => directoryWatchesOfFailedLookups.has(dirPath2)
|
|
118889
|
+
);
|
|
118856
118890
|
if (dirPath) {
|
|
118857
118891
|
scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
|
|
118858
118892
|
}
|
|
@@ -118878,12 +118912,10 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
118878
118912
|
closeTypeRootsWatch();
|
|
118879
118913
|
}
|
|
118880
118914
|
}
|
|
118881
|
-
function canWatchTypeRootPath(
|
|
118915
|
+
function canWatchTypeRootPath(typeRoot) {
|
|
118882
118916
|
if (resolutionHost.getCompilationSettings().typeRoots)
|
|
118883
118917
|
return true;
|
|
118884
|
-
|
|
118885
|
-
const dirPath = resolutionHost.toPath(dir);
|
|
118886
|
-
return dirPath === rootPath || canWatchDirectoryOrFile(dirPath);
|
|
118918
|
+
return canWatchAtTypes(resolutionHost.toPath(typeRoot), rootPath);
|
|
118887
118919
|
}
|
|
118888
118920
|
}
|
|
118889
118921
|
function resolutionIsSymlink(resolution) {
|