typescript 5.0.0-dev.20230202 → 5.0.0-dev.20230204
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 +118 -56
- package/lib/tsserver.js +2871 -2798
- package/lib/tsserverlibrary.js +140 -68
- package/lib/typescript.js +136 -65
- package/lib/typingsInstaller.js +33 -16
- package/package.json +2 -1
package/lib/tsc.js
CHANGED
|
@@ -23,7 +23,7 @@ var __export = (target, all) => {
|
|
|
23
23
|
|
|
24
24
|
// src/compiler/corePublic.ts
|
|
25
25
|
var versionMajorMinor = "5.0";
|
|
26
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
26
|
+
var version = `${versionMajorMinor}.0-dev.20230204`;
|
|
27
27
|
|
|
28
28
|
// src/compiler/core.ts
|
|
29
29
|
var emptyArray = [];
|
|
@@ -6572,7 +6572,6 @@ var Diagnostics = {
|
|
|
6572
6572
|
Cannot_find_type_definition_file_for_0: diag(2688, 1 /* Error */, "Cannot_find_type_definition_file_for_0_2688", "Cannot find type definition file for '{0}'."),
|
|
6573
6573
|
Cannot_extend_an_interface_0_Did_you_mean_implements: diag(2689, 1 /* Error */, "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", "Cannot extend an interface '{0}'. Did you mean 'implements'?"),
|
|
6574
6574
|
_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0: diag(2690, 1 /* Error */, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Did_you_mean_to_use_1_in_0_2690", "'{0}' only refers to a type, but is being used as a value here. Did you mean to use '{1} in {0}'?"),
|
|
6575
|
-
An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: diag(2691, 1 /* Error */, "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead."),
|
|
6576
6575
|
_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: diag(2692, 1 /* Error */, "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible."),
|
|
6577
6576
|
_0_only_refers_to_a_type_but_is_being_used_as_a_value_here: diag(2693, 1 /* Error */, "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", "'{0}' only refers to a type, but is being used as a value here."),
|
|
6578
6577
|
Namespace_0_has_no_exported_member_1: diag(2694, 1 /* Error */, "Namespace_0_has_no_exported_member_1_2694", "Namespace '{0}' has no exported member '{1}'."),
|
|
@@ -35955,6 +35954,22 @@ function resolvedTypeScriptOnly(resolved) {
|
|
|
35955
35954
|
Debug.assert(extensionIsTS(resolved.extension));
|
|
35956
35955
|
return { fileName: resolved.path, packageId: resolved.packageId };
|
|
35957
35956
|
}
|
|
35957
|
+
function createResolvedModuleWithFailedLookupLocationsHandlingSymlink(moduleName, resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state, legacyResult) {
|
|
35958
|
+
if (!state.resultFromCache && !state.compilerOptions.preserveSymlinks && resolved && isExternalLibraryImport && !resolved.originalPath && !isExternalModuleNameRelative(moduleName)) {
|
|
35959
|
+
const { resolvedFileName, originalPath } = getOriginalAndResolvedFileName(resolved.path, state.host, state.traceEnabled);
|
|
35960
|
+
if (originalPath)
|
|
35961
|
+
resolved = { ...resolved, path: resolvedFileName, originalPath };
|
|
35962
|
+
}
|
|
35963
|
+
return createResolvedModuleWithFailedLookupLocations(
|
|
35964
|
+
resolved,
|
|
35965
|
+
isExternalLibraryImport,
|
|
35966
|
+
failedLookupLocations,
|
|
35967
|
+
affectingLocations,
|
|
35968
|
+
diagnostics,
|
|
35969
|
+
state.resultFromCache,
|
|
35970
|
+
legacyResult
|
|
35971
|
+
);
|
|
35972
|
+
}
|
|
35958
35973
|
function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, resultFromCache, legacyResult) {
|
|
35959
35974
|
if (resultFromCache) {
|
|
35960
35975
|
resultFromCache.failedLookupLocations = updateResolutionField(resultFromCache.failedLookupLocations, failedLookupLocations);
|
|
@@ -36115,6 +36130,15 @@ function arePathsEqual(path1, path2, host) {
|
|
|
36115
36130
|
const useCaseSensitiveFileNames = typeof host.useCaseSensitiveFileNames === "function" ? host.useCaseSensitiveFileNames() : host.useCaseSensitiveFileNames;
|
|
36116
36131
|
return comparePaths(path1, path2, !useCaseSensitiveFileNames) === 0 /* EqualTo */;
|
|
36117
36132
|
}
|
|
36133
|
+
function getOriginalAndResolvedFileName(fileName, host, traceEnabled) {
|
|
36134
|
+
const resolvedFileName = realPath(fileName, host, traceEnabled);
|
|
36135
|
+
const pathsAreEqual = arePathsEqual(fileName, resolvedFileName, host);
|
|
36136
|
+
return {
|
|
36137
|
+
// If the fileName and realpath are differing only in casing prefer fileName so that we can issue correct errors for casing under forceConsistentCasingInFileNames
|
|
36138
|
+
resolvedFileName: pathsAreEqual ? fileName : resolvedFileName,
|
|
36139
|
+
originalPath: pathsAreEqual ? void 0 : fileName
|
|
36140
|
+
};
|
|
36141
|
+
}
|
|
36118
36142
|
function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference, cache, resolutionMode) {
|
|
36119
36143
|
Debug.assert(typeof typeReferenceDirectiveName === "string", "Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.");
|
|
36120
36144
|
const traceEnabled = isTraceEnabled(options, host);
|
|
@@ -36186,13 +36210,13 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
|
|
|
36186
36210
|
let resolvedTypeReferenceDirective;
|
|
36187
36211
|
if (resolved) {
|
|
36188
36212
|
const { fileName, packageId } = resolved;
|
|
36189
|
-
|
|
36190
|
-
|
|
36213
|
+
let resolvedFileName = fileName, originalPath;
|
|
36214
|
+
if (!options.preserveSymlinks)
|
|
36215
|
+
({ resolvedFileName, originalPath } = getOriginalAndResolvedFileName(fileName, host, traceEnabled));
|
|
36191
36216
|
resolvedTypeReferenceDirective = {
|
|
36192
36217
|
primary,
|
|
36193
|
-
|
|
36194
|
-
|
|
36195
|
-
originalPath: pathsAreEqual ? void 0 : fileName,
|
|
36218
|
+
resolvedFileName,
|
|
36219
|
+
originalPath,
|
|
36196
36220
|
packageId,
|
|
36197
36221
|
isExternalLibraryImport: pathContainsNodeModules(fileName)
|
|
36198
36222
|
};
|
|
@@ -37050,13 +37074,14 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
|
|
|
37050
37074
|
legacyResult = diagnosticResult.value.resolved.path;
|
|
37051
37075
|
}
|
|
37052
37076
|
}
|
|
37053
|
-
return
|
|
37077
|
+
return createResolvedModuleWithFailedLookupLocationsHandlingSymlink(
|
|
37078
|
+
moduleName,
|
|
37054
37079
|
(_c = result == null ? void 0 : result.value) == null ? void 0 : _c.resolved,
|
|
37055
37080
|
(_d = result == null ? void 0 : result.value) == null ? void 0 : _d.isExternalLibraryImport,
|
|
37056
37081
|
failedLookupLocations,
|
|
37057
37082
|
affectingLocations,
|
|
37058
37083
|
diagnostics,
|
|
37059
|
-
state
|
|
37084
|
+
state,
|
|
37060
37085
|
legacyResult
|
|
37061
37086
|
);
|
|
37062
37087
|
function tryResolve(extensions2, state2) {
|
|
@@ -37086,16 +37111,7 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
|
|
|
37086
37111
|
}
|
|
37087
37112
|
resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
37088
37113
|
}
|
|
37089
|
-
|
|
37090
|
-
return void 0;
|
|
37091
|
-
let resolvedValue = resolved2.value;
|
|
37092
|
-
if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) {
|
|
37093
|
-
const path = realPath(resolvedValue.path, host, traceEnabled);
|
|
37094
|
-
const pathsAreEqual = arePathsEqual(path, resolvedValue.path, host);
|
|
37095
|
-
const originalPath = pathsAreEqual ? void 0 : resolvedValue.path;
|
|
37096
|
-
resolvedValue = { ...resolvedValue, path: pathsAreEqual ? resolvedValue.path : path, originalPath };
|
|
37097
|
-
}
|
|
37098
|
-
return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
|
|
37114
|
+
return resolved2 && { value: resolved2.value && { resolved: resolved2.value, isExternalLibraryImport: true } };
|
|
37099
37115
|
} else {
|
|
37100
37116
|
const { path: candidate, parts } = normalizePathForCJSResolution(containingDirectory, moduleName);
|
|
37101
37117
|
const resolved2 = nodeLoadModuleByRelativeName(
|
|
@@ -38150,13 +38166,14 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
|
|
|
38150
38166
|
candidateIsFromPackageJsonField: false
|
|
38151
38167
|
};
|
|
38152
38168
|
const resolved = tryResolve(1 /* TypeScript */ | 4 /* Declaration */) || tryResolve(2 /* JavaScript */ | (compilerOptions.resolveJsonModule ? 8 /* Json */ : 0));
|
|
38153
|
-
return
|
|
38169
|
+
return createResolvedModuleWithFailedLookupLocationsHandlingSymlink(
|
|
38170
|
+
moduleName,
|
|
38154
38171
|
resolved && resolved.value,
|
|
38155
38172
|
(resolved == null ? void 0 : resolved.value) && pathContainsNodeModules(resolved.value.path),
|
|
38156
38173
|
failedLookupLocations,
|
|
38157
38174
|
affectingLocations,
|
|
38158
38175
|
diagnostics,
|
|
38159
|
-
state
|
|
38176
|
+
state
|
|
38160
38177
|
);
|
|
38161
38178
|
function tryResolve(extensions) {
|
|
38162
38179
|
const resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
|
|
@@ -42482,6 +42499,7 @@ function createTypeChecker(host) {
|
|
|
42482
42499
|
isArrayType,
|
|
42483
42500
|
isTupleType,
|
|
42484
42501
|
isArrayLikeType,
|
|
42502
|
+
isEmptyAnonymousObjectType,
|
|
42485
42503
|
isTypeInvalidDueToUnionDiscriminant,
|
|
42486
42504
|
getExactOptionalProperties,
|
|
42487
42505
|
getAllPossiblePropertiesOfTypes,
|
|
@@ -44304,7 +44322,12 @@ function createTypeChecker(host) {
|
|
|
44304
44322
|
}
|
|
44305
44323
|
function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) {
|
|
44306
44324
|
const exportValue = moduleSymbol.exports.get("export=" /* ExportEquals */);
|
|
44307
|
-
const exportSymbol = exportValue ? getPropertyOfType(
|
|
44325
|
+
const exportSymbol = exportValue ? getPropertyOfType(
|
|
44326
|
+
getTypeOfSymbol(exportValue),
|
|
44327
|
+
name,
|
|
44328
|
+
/*skipObjectFunctionPropertyAugment*/
|
|
44329
|
+
true
|
|
44330
|
+
) : moduleSymbol.exports.get(name);
|
|
44308
44331
|
const resolved = resolveSymbol(exportSymbol, dontResolveAlias);
|
|
44309
44332
|
markSymbolOfAliasDeclarationIfTypeOnly(
|
|
44310
44333
|
sourceNode,
|
|
@@ -45339,12 +45362,9 @@ function createTypeChecker(host) {
|
|
|
45339
45362
|
if (resolutionDiagnostic) {
|
|
45340
45363
|
error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
|
|
45341
45364
|
} else {
|
|
45342
|
-
const tsExtension = tryExtractTSExtension(moduleReference);
|
|
45343
45365
|
const isExtensionlessRelativePathImport = pathIsRelative(moduleReference) && !hasExtension(moduleReference);
|
|
45344
45366
|
const resolutionIsNode16OrNext = moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */;
|
|
45345
|
-
if (
|
|
45346
|
-
errorOnTSExtensionImport(tsExtension);
|
|
45347
|
-
} else if (!getResolveJsonModule(compilerOptions) && fileExtensionIs(moduleReference, ".json" /* Json */) && moduleResolutionKind !== 1 /* Classic */ && hasJsonModuleEmitEnabled(compilerOptions)) {
|
|
45367
|
+
if (!getResolveJsonModule(compilerOptions) && fileExtensionIs(moduleReference, ".json" /* Json */) && moduleResolutionKind !== 1 /* Classic */ && hasJsonModuleEmitEnabled(compilerOptions)) {
|
|
45348
45368
|
error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
45349
45369
|
} else if (mode === 99 /* ESNext */ && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
|
|
45350
45370
|
const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
|
|
@@ -45364,10 +45384,6 @@ function createTypeChecker(host) {
|
|
|
45364
45384
|
}
|
|
45365
45385
|
}
|
|
45366
45386
|
return void 0;
|
|
45367
|
-
function errorOnTSExtensionImport(tsExtension) {
|
|
45368
|
-
const diag2 = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
|
|
45369
|
-
error(errorNode, diag2, tsExtension, getSuggestedImportSource(tsExtension));
|
|
45370
|
-
}
|
|
45371
45387
|
function getSuggestedImportSource(tsExtension) {
|
|
45372
45388
|
const importSourceWithoutExtension = removeExtension(moduleReference, tsExtension);
|
|
45373
45389
|
if (emitModuleKindIsNonNodeESM(moduleKind) || mode === 99 /* ESNext */) {
|
|
@@ -53719,7 +53735,7 @@ function createTypeChecker(host) {
|
|
|
53719
53735
|
for (const tag of node.tags) {
|
|
53720
53736
|
if (isJSDocOverloadTag(tag)) {
|
|
53721
53737
|
const jsDocSignature = tag.typeExpression;
|
|
53722
|
-
if (jsDocSignature.type === void 0) {
|
|
53738
|
+
if (jsDocSignature.type === void 0 && !isConstructorDeclaration(decl)) {
|
|
53723
53739
|
reportImplicitAny(jsDocSignature, anyType);
|
|
53724
53740
|
}
|
|
53725
53741
|
result.push(getSignatureFromDeclaration(jsDocSignature));
|
|
@@ -53831,6 +53847,12 @@ function createTypeChecker(host) {
|
|
|
53831
53847
|
if (declaration.kind === 173 /* Constructor */) {
|
|
53832
53848
|
return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol));
|
|
53833
53849
|
}
|
|
53850
|
+
if (isJSDocSignature(declaration)) {
|
|
53851
|
+
const root = getJSDocRoot(declaration);
|
|
53852
|
+
if (root && isConstructorDeclaration(root.parent)) {
|
|
53853
|
+
return getDeclaredTypeOfClassOrInterface(getMergedSymbol(root.parent.parent.symbol));
|
|
53854
|
+
}
|
|
53855
|
+
}
|
|
53834
53856
|
if (isJSDocConstructSignature(declaration)) {
|
|
53835
53857
|
return getTypeFromTypeNode(declaration.parameters[0].type);
|
|
53836
53858
|
}
|
|
@@ -54359,7 +54381,7 @@ function createTypeChecker(host) {
|
|
|
54359
54381
|
return links.resolvedJSDocType;
|
|
54360
54382
|
}
|
|
54361
54383
|
function getSubstitutionType(baseType, constraint) {
|
|
54362
|
-
if (constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType) {
|
|
54384
|
+
if (constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */) {
|
|
54363
54385
|
return baseType;
|
|
54364
54386
|
}
|
|
54365
54387
|
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`;
|
|
@@ -56046,7 +56068,7 @@ function createTypeChecker(host) {
|
|
|
56046
56068
|
}
|
|
56047
56069
|
}
|
|
56048
56070
|
const propType = getTypeOfSymbol(prop);
|
|
56049
|
-
return accessExpression && getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? getFlowTypeOfReference(accessExpression, propType) : propType;
|
|
56071
|
+
return accessExpression && getAssignmentTargetKind(accessExpression) !== 1 /* Definite */ ? getFlowTypeOfReference(accessExpression, propType) : accessNode && isIndexedAccessTypeNode(accessNode) && containsMissingType(propType) ? getUnionType([propType, undefinedType]) : propType;
|
|
56050
56072
|
}
|
|
56051
56073
|
if (everyType(objectType, isTupleType) && isNumericLiteralName(propName)) {
|
|
56052
56074
|
const index = +propName;
|
|
@@ -58551,7 +58573,6 @@ function createTypeChecker(host) {
|
|
|
58551
58573
|
let overrideNextErrorInfo = 0;
|
|
58552
58574
|
let lastSkippedInfo;
|
|
58553
58575
|
let incompatibleStack;
|
|
58554
|
-
let inPropertyCheck = false;
|
|
58555
58576
|
Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
|
|
58556
58577
|
const result = isRelatedTo(
|
|
58557
58578
|
source,
|
|
@@ -59510,14 +59531,15 @@ function createTypeChecker(host) {
|
|
|
59510
59531
|
);
|
|
59511
59532
|
}
|
|
59512
59533
|
}
|
|
59513
|
-
if (result2 && !
|
|
59514
|
-
inPropertyCheck = true;
|
|
59534
|
+
if (result2 && !(intersectionState & 2 /* Target */) && target2.flags & 2097152 /* Intersection */ && !isGenericObjectType(target2) && source2.flags & (524288 /* Object */ | 2097152 /* Intersection */)) {
|
|
59515
59535
|
result2 &= propertiesRelatedTo(
|
|
59516
59536
|
source2,
|
|
59517
59537
|
target2,
|
|
59518
59538
|
reportErrors2,
|
|
59519
59539
|
/*excludedProperties*/
|
|
59520
59540
|
void 0,
|
|
59541
|
+
/*optionalsOnly*/
|
|
59542
|
+
false,
|
|
59521
59543
|
0 /* None */
|
|
59522
59544
|
);
|
|
59523
59545
|
if (result2 && isObjectLiteralType(source2) && getObjectFlags(source2) & 8192 /* FreshLiteral */) {
|
|
@@ -59530,7 +59552,17 @@ function createTypeChecker(host) {
|
|
|
59530
59552
|
0 /* None */
|
|
59531
59553
|
);
|
|
59532
59554
|
}
|
|
59533
|
-
|
|
59555
|
+
} else if (result2 && isNonGenericObjectType(target2) && !isArrayOrTupleType(target2) && source2.flags & 2097152 /* Intersection */ && getApparentType(source2).flags & 3670016 /* StructuredType */ && !some(source2.types, (t) => !!(getObjectFlags(t) & 262144 /* NonInferrableType */))) {
|
|
59556
|
+
result2 &= propertiesRelatedTo(
|
|
59557
|
+
source2,
|
|
59558
|
+
target2,
|
|
59559
|
+
reportErrors2,
|
|
59560
|
+
/*excludedProperties*/
|
|
59561
|
+
void 0,
|
|
59562
|
+
/*optionalsOnly*/
|
|
59563
|
+
true,
|
|
59564
|
+
intersectionState
|
|
59565
|
+
);
|
|
59534
59566
|
}
|
|
59535
59567
|
}
|
|
59536
59568
|
if (result2) {
|
|
@@ -60020,12 +60052,14 @@ function createTypeChecker(host) {
|
|
|
60020
60052
|
reportStructuralErrors,
|
|
60021
60053
|
/*excludedProperties*/
|
|
60022
60054
|
void 0,
|
|
60055
|
+
/*optionalsOnly*/
|
|
60056
|
+
false,
|
|
60023
60057
|
intersectionState
|
|
60024
60058
|
);
|
|
60025
60059
|
if (result2) {
|
|
60026
|
-
result2 &= signaturesRelatedTo(source2, target2, 0 /* Call */, reportStructuralErrors);
|
|
60060
|
+
result2 &= signaturesRelatedTo(source2, target2, 0 /* Call */, reportStructuralErrors, intersectionState);
|
|
60027
60061
|
if (result2) {
|
|
60028
|
-
result2 &= signaturesRelatedTo(source2, target2, 1 /* Construct */, reportStructuralErrors);
|
|
60062
|
+
result2 &= signaturesRelatedTo(source2, target2, 1 /* Construct */, reportStructuralErrors, intersectionState);
|
|
60029
60063
|
if (result2) {
|
|
60030
60064
|
result2 &= indexSignaturesRelatedTo(source2, target2, sourceIsPrimitive, reportStructuralErrors, intersectionState);
|
|
60031
60065
|
}
|
|
@@ -60154,6 +60188,8 @@ function createTypeChecker(host) {
|
|
|
60154
60188
|
/*reportErrors*/
|
|
60155
60189
|
false,
|
|
60156
60190
|
excludedProperties,
|
|
60191
|
+
/*optionalsOnly*/
|
|
60192
|
+
false,
|
|
60157
60193
|
0 /* None */
|
|
60158
60194
|
);
|
|
60159
60195
|
if (result2) {
|
|
@@ -60162,7 +60198,8 @@ function createTypeChecker(host) {
|
|
|
60162
60198
|
type,
|
|
60163
60199
|
0 /* Call */,
|
|
60164
60200
|
/*reportStructuralErrors*/
|
|
60165
|
-
false
|
|
60201
|
+
false,
|
|
60202
|
+
0 /* None */
|
|
60166
60203
|
);
|
|
60167
60204
|
if (result2) {
|
|
60168
60205
|
result2 &= signaturesRelatedTo(
|
|
@@ -60170,7 +60207,8 @@ function createTypeChecker(host) {
|
|
|
60170
60207
|
type,
|
|
60171
60208
|
1 /* Construct */,
|
|
60172
60209
|
/*reportStructuralErrors*/
|
|
60173
|
-
false
|
|
60210
|
+
false,
|
|
60211
|
+
0 /* None */
|
|
60174
60212
|
);
|
|
60175
60213
|
if (result2 && !(isTupleType(source2) && isTupleType(type))) {
|
|
60176
60214
|
result2 &= indexSignaturesRelatedTo(
|
|
@@ -60348,7 +60386,7 @@ function createTypeChecker(host) {
|
|
|
60348
60386
|
}
|
|
60349
60387
|
}
|
|
60350
60388
|
}
|
|
60351
|
-
function propertiesRelatedTo(source2, target2, reportErrors2, excludedProperties, intersectionState) {
|
|
60389
|
+
function propertiesRelatedTo(source2, target2, reportErrors2, excludedProperties, optionalsOnly, intersectionState) {
|
|
60352
60390
|
if (relation === identityRelation) {
|
|
60353
60391
|
return propertiesIdenticalTo(source2, target2, excludedProperties);
|
|
60354
60392
|
}
|
|
@@ -60484,7 +60522,7 @@ function createTypeChecker(host) {
|
|
|
60484
60522
|
const numericNamesOnly = isTupleType(source2) && isTupleType(target2);
|
|
60485
60523
|
for (const targetProp of excludeProperties(properties, excludedProperties)) {
|
|
60486
60524
|
const name = targetProp.escapedName;
|
|
60487
|
-
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
|
|
60525
|
+
if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length") && (!optionalsOnly || targetProp.flags & 16777216 /* Optional */)) {
|
|
60488
60526
|
const sourceProp = getPropertyOfType(source2, name);
|
|
60489
60527
|
if (sourceProp && sourceProp !== targetProp) {
|
|
60490
60528
|
const related = propertyRelatedTo(source2, target2, sourceProp, targetProp, getNonMissingTypeOfSymbol, reportErrors2, intersectionState, relation === comparableRelation);
|
|
@@ -60520,7 +60558,7 @@ function createTypeChecker(host) {
|
|
|
60520
60558
|
}
|
|
60521
60559
|
return result2;
|
|
60522
60560
|
}
|
|
60523
|
-
function signaturesRelatedTo(source2, target2, kind, reportErrors2) {
|
|
60561
|
+
function signaturesRelatedTo(source2, target2, kind, reportErrors2, intersectionState) {
|
|
60524
60562
|
var _a3, _b;
|
|
60525
60563
|
if (relation === identityRelation) {
|
|
60526
60564
|
return signaturesIdenticalTo(source2, target2, kind);
|
|
@@ -60557,6 +60595,7 @@ function createTypeChecker(host) {
|
|
|
60557
60595
|
/*erase*/
|
|
60558
60596
|
true,
|
|
60559
60597
|
reportErrors2,
|
|
60598
|
+
intersectionState,
|
|
60560
60599
|
incompatibleReporter(sourceSignatures[i], targetSignatures[i])
|
|
60561
60600
|
);
|
|
60562
60601
|
if (!related) {
|
|
@@ -60568,7 +60607,7 @@ function createTypeChecker(host) {
|
|
|
60568
60607
|
const eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks;
|
|
60569
60608
|
const sourceSignature = first(sourceSignatures);
|
|
60570
60609
|
const targetSignature = first(targetSignatures);
|
|
60571
|
-
result2 = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors2, incompatibleReporter(sourceSignature, targetSignature));
|
|
60610
|
+
result2 = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors2, intersectionState, incompatibleReporter(sourceSignature, targetSignature));
|
|
60572
60611
|
if (!result2 && reportErrors2 && kind === 1 /* Construct */ && sourceObjectFlags & targetObjectFlags && (((_a3 = targetSignature.declaration) == null ? void 0 : _a3.kind) === 173 /* Constructor */ || ((_b = sourceSignature.declaration) == null ? void 0 : _b.kind) === 173 /* Constructor */)) {
|
|
60573
60612
|
const constructSignatureToString = (signature) => signatureToString(
|
|
60574
60613
|
signature,
|
|
@@ -60593,6 +60632,7 @@ function createTypeChecker(host) {
|
|
|
60593
60632
|
/*erase*/
|
|
60594
60633
|
true,
|
|
60595
60634
|
shouldElaborateErrors,
|
|
60635
|
+
intersectionState,
|
|
60596
60636
|
incompatibleReporter(s, t)
|
|
60597
60637
|
);
|
|
60598
60638
|
if (related) {
|
|
@@ -60645,7 +60685,7 @@ function createTypeChecker(host) {
|
|
|
60645
60685
|
}
|
|
60646
60686
|
return (source2, target2) => reportIncompatibleError(Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source2), typeToString(target2));
|
|
60647
60687
|
}
|
|
60648
|
-
function signatureRelatedTo(source2, target2, erase, reportErrors2, incompatibleReporter) {
|
|
60688
|
+
function signatureRelatedTo(source2, target2, erase, reportErrors2, intersectionState, incompatibleReporter) {
|
|
60649
60689
|
return compareSignaturesRelated(
|
|
60650
60690
|
erase ? getErasedSignature(source2) : source2,
|
|
60651
60691
|
erase ? getErasedSignature(target2) : target2,
|
|
@@ -60653,9 +60693,20 @@ function createTypeChecker(host) {
|
|
|
60653
60693
|
reportErrors2,
|
|
60654
60694
|
reportError,
|
|
60655
60695
|
incompatibleReporter,
|
|
60656
|
-
|
|
60696
|
+
isRelatedToWorker2,
|
|
60657
60697
|
reportUnreliableMapper
|
|
60658
60698
|
);
|
|
60699
|
+
function isRelatedToWorker2(source3, target3, reportErrors3) {
|
|
60700
|
+
return isRelatedTo(
|
|
60701
|
+
source3,
|
|
60702
|
+
target3,
|
|
60703
|
+
3 /* Both */,
|
|
60704
|
+
reportErrors3,
|
|
60705
|
+
/*headMessage*/
|
|
60706
|
+
void 0,
|
|
60707
|
+
intersectionState
|
|
60708
|
+
);
|
|
60709
|
+
}
|
|
60659
60710
|
}
|
|
60660
60711
|
function signaturesIdenticalTo(source2, target2, kind) {
|
|
60661
60712
|
const sourceSignatures = getSignaturesOfType(source2, kind);
|
|
@@ -60714,7 +60765,7 @@ function createTypeChecker(host) {
|
|
|
60714
60765
|
}
|
|
60715
60766
|
for (const info of getIndexInfosOfType(source2)) {
|
|
60716
60767
|
if (isApplicableIndexType(info.keyType, keyType)) {
|
|
60717
|
-
const related = indexInfoRelatedTo(info, targetInfo, reportErrors2);
|
|
60768
|
+
const related = indexInfoRelatedTo(info, targetInfo, reportErrors2, intersectionState);
|
|
60718
60769
|
if (!related) {
|
|
60719
60770
|
return 0 /* False */;
|
|
60720
60771
|
}
|
|
@@ -60723,8 +60774,16 @@ function createTypeChecker(host) {
|
|
|
60723
60774
|
}
|
|
60724
60775
|
return result2;
|
|
60725
60776
|
}
|
|
60726
|
-
function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors2) {
|
|
60727
|
-
const related = isRelatedTo(
|
|
60777
|
+
function indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors2, intersectionState) {
|
|
60778
|
+
const related = isRelatedTo(
|
|
60779
|
+
sourceInfo.type,
|
|
60780
|
+
targetInfo.type,
|
|
60781
|
+
3 /* Both */,
|
|
60782
|
+
reportErrors2,
|
|
60783
|
+
/*headMessage*/
|
|
60784
|
+
void 0,
|
|
60785
|
+
intersectionState
|
|
60786
|
+
);
|
|
60728
60787
|
if (!related && reportErrors2) {
|
|
60729
60788
|
if (sourceInfo.keyType === targetInfo.keyType) {
|
|
60730
60789
|
reportError(Diagnostics._0_index_signatures_are_incompatible, typeToString(sourceInfo.keyType));
|
|
@@ -60753,7 +60812,7 @@ function createTypeChecker(host) {
|
|
|
60753
60812
|
function typeRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState) {
|
|
60754
60813
|
const sourceInfo = getApplicableIndexInfo(source2, targetInfo.keyType);
|
|
60755
60814
|
if (sourceInfo) {
|
|
60756
|
-
return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors2);
|
|
60815
|
+
return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors2, intersectionState);
|
|
60757
60816
|
}
|
|
60758
60817
|
if (!(intersectionState & 1 /* Source */) && isObjectTypeWithInferableIndex(source2)) {
|
|
60759
60818
|
return membersRelatedToIndexInfo(source2, targetInfo, reportErrors2, intersectionState);
|
|
@@ -61044,12 +61103,15 @@ function createTypeChecker(host) {
|
|
|
61044
61103
|
}
|
|
61045
61104
|
function isDeeplyNestedType(type, stack, depth, maxDepth = 3) {
|
|
61046
61105
|
if (depth >= maxDepth) {
|
|
61106
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
61107
|
+
return some(type.types, (t) => isDeeplyNestedType(t, stack, depth, maxDepth));
|
|
61108
|
+
}
|
|
61047
61109
|
const identity2 = getRecursionIdentity(type);
|
|
61048
61110
|
let count = 0;
|
|
61049
61111
|
let lastTypeId = 0;
|
|
61050
61112
|
for (let i = 0; i < depth; i++) {
|
|
61051
61113
|
const t = stack[i];
|
|
61052
|
-
if (getRecursionIdentity(t) === identity2) {
|
|
61114
|
+
if (t.flags & 2097152 /* Intersection */ ? some(t.types, (u) => getRecursionIdentity(u) === identity2) : getRecursionIdentity(t) === identity2) {
|
|
61053
61115
|
if (t.id >= lastTypeId) {
|
|
61054
61116
|
count++;
|
|
61055
61117
|
if (count >= maxDepth) {
|
|
@@ -70068,7 +70130,7 @@ function createTypeChecker(host) {
|
|
|
70068
70130
|
}
|
|
70069
70131
|
}
|
|
70070
70132
|
function checkCallExpression(node, checkMode) {
|
|
70071
|
-
var _a2;
|
|
70133
|
+
var _a2, _b, _c;
|
|
70072
70134
|
checkGrammarTypeArguments(node, node.typeArguments);
|
|
70073
70135
|
const signature = getResolvedSignature(
|
|
70074
70136
|
node,
|
|
@@ -70085,7 +70147,7 @@ function createTypeChecker(host) {
|
|
|
70085
70147
|
}
|
|
70086
70148
|
if (node.kind === 211 /* NewExpression */) {
|
|
70087
70149
|
const declaration = signature.declaration;
|
|
70088
|
-
if (declaration && declaration.kind !== 173 /* Constructor */ && declaration.kind !== 177 /* ConstructSignature */ && declaration.kind !== 182 /* ConstructorType */ && !isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) {
|
|
70150
|
+
if (declaration && declaration.kind !== 173 /* Constructor */ && declaration.kind !== 177 /* ConstructSignature */ && declaration.kind !== 182 /* ConstructorType */ && !(isJSDocSignature(declaration) && ((_b = (_a2 = getJSDocRoot(declaration)) == null ? void 0 : _a2.parent) == null ? void 0 : _b.kind) === 173 /* Constructor */) && !isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) {
|
|
70089
70151
|
if (noImplicitAny) {
|
|
70090
70152
|
error(node, Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
|
|
70091
70153
|
}
|
|
@@ -70113,7 +70175,7 @@ function createTypeChecker(host) {
|
|
|
70113
70175
|
/*allowDeclaration*/
|
|
70114
70176
|
false
|
|
70115
70177
|
);
|
|
70116
|
-
if ((
|
|
70178
|
+
if ((_c = jsSymbol == null ? void 0 : jsSymbol.exports) == null ? void 0 : _c.size) {
|
|
70117
70179
|
const jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, emptyArray, emptyArray, emptyArray);
|
|
70118
70180
|
jsAssignmentType.objectFlags |= 4096 /* JSLiteral */;
|
|
70119
70181
|
return getIntersectionType([returnType, jsAssignmentType]);
|
|
@@ -77823,7 +77885,7 @@ function createTypeChecker(host) {
|
|
|
77823
77885
|
getNodeLinks(node).flags |= 2048 /* LexicalModuleMergesWithClass */;
|
|
77824
77886
|
}
|
|
77825
77887
|
}
|
|
77826
|
-
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 308 /* SourceFile */) {
|
|
77888
|
+
if (compilerOptions.verbatimModuleSyntax && node.parent.kind === 308 /* SourceFile */ && (moduleKind === 1 /* CommonJS */ || node.parent.impliedNodeFormat === 1 /* CommonJS */)) {
|
|
77827
77889
|
const exportModifier = (_b = node.modifiers) == null ? void 0 : _b.find((m) => m.kind === 93 /* ExportKeyword */);
|
|
77828
77890
|
if (exportModifier) {
|
|
77829
77891
|
error(exportModifier, Diagnostics.A_top_level_export_modifier_cannot_be_used_on_value_declarations_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|