typescript 5.0.0-dev.20230110 → 5.0.0-dev.20230112
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 +127 -63
- package/lib/tsserver.js +181 -98
- package/lib/tsserverlibrary.js +180 -98
- package/lib/typescript.js +177 -97
- package/lib/typingsInstaller.js +43 -29
- package/package.json +1 -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.20230112`;
|
|
27
27
|
|
|
28
28
|
// src/compiler/core.ts
|
|
29
29
|
var emptyArray = [];
|
|
@@ -6763,6 +6763,7 @@ var Diagnostics = {
|
|
|
6763
6763
|
Default_export_of_the_module_has_or_is_using_private_name_0: diag(4082, 1 /* Error */, "Default_export_of_the_module_has_or_is_using_private_name_0_4082", "Default export of the module has or is using private name '{0}'."),
|
|
6764
6764
|
Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1: diag(4083, 1 /* Error */, "Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1_4083", "Type parameter '{0}' of exported type alias has or is using private name '{1}'."),
|
|
6765
6765
|
Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, 1 /* Error */, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."),
|
|
6766
|
+
Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1: diag(4085, 1 /* Error */, "Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1_4085", "Extends clause for inferred type '{0}' has or is using private name '{1}'."),
|
|
6766
6767
|
Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict: diag(4090, 1 /* Error */, "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090", "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict."),
|
|
6767
6768
|
Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2: diag(4091, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2_4091", "Parameter '{0}' of index signature from exported interface has or is using name '{1}' from private module '{2}'."),
|
|
6768
6769
|
Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1: diag(4092, 1 /* Error */, "Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1_4092", "Parameter '{0}' of index signature from exported interface has or is using private name '{1}'."),
|
|
@@ -8403,7 +8404,8 @@ function isIdentifierStart(ch, languageVersion) {
|
|
|
8403
8404
|
return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch === 36 /* $ */ || ch === 95 /* _ */ || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierStart(ch, languageVersion);
|
|
8404
8405
|
}
|
|
8405
8406
|
function isIdentifierPart(ch, languageVersion, identifierVariant) {
|
|
8406
|
-
return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ ||
|
|
8407
|
+
return ch >= 65 /* A */ && ch <= 90 /* Z */ || ch >= 97 /* a */ && ch <= 122 /* z */ || ch >= 48 /* _0 */ && ch <= 57 /* _9 */ || ch === 36 /* $ */ || ch === 95 /* _ */ || // "-" and ":" are valid in JSX Identifiers
|
|
8408
|
+
(identifierVariant === 1 /* JSX */ ? ch === 45 /* minus */ || ch === 58 /* colon */ : false) || ch > 127 /* maxAsciiCharacter */ && isUnicodeIdentifierPart(ch, languageVersion);
|
|
8407
8409
|
}
|
|
8408
8410
|
function isIdentifierText(name, languageVersion, identifierVariant) {
|
|
8409
8411
|
let ch = codePointAt(name, 0);
|
|
@@ -16637,6 +16639,10 @@ function isOptionalDeclaration(declaration) {
|
|
|
16637
16639
|
return false;
|
|
16638
16640
|
}
|
|
16639
16641
|
}
|
|
16642
|
+
function isNonNullAccess(node) {
|
|
16643
|
+
const kind = node.kind;
|
|
16644
|
+
return (kind === 208 /* PropertyAccessExpression */ || kind === 209 /* ElementAccessExpression */) && isNonNullExpression(node.expression);
|
|
16645
|
+
}
|
|
16640
16646
|
|
|
16641
16647
|
// src/compiler/factory/baseNodeFactory.ts
|
|
16642
16648
|
function createBaseNodeFactory() {
|
|
@@ -34292,7 +34298,8 @@ function convertToObjectWorker(sourceFile, rootExpression, errors, returnValue,
|
|
|
34292
34298
|
if (returnValue) {
|
|
34293
34299
|
result[keyText] = value;
|
|
34294
34300
|
}
|
|
34295
|
-
if (jsonConversionNotifier &&
|
|
34301
|
+
if (jsonConversionNotifier && // Current callbacks are only on known parent option or if we are setting values in the root
|
|
34302
|
+
(parentOption || isRootOptionMap(knownOptions))) {
|
|
34296
34303
|
const isValidOptionValue = isCompilerOptionsValue(option, value);
|
|
34297
34304
|
if (parentOption) {
|
|
34298
34305
|
if (isValidOptionValue) {
|
|
@@ -35772,7 +35779,8 @@ function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFil
|
|
|
35772
35779
|
conditions,
|
|
35773
35780
|
requestContainingDirectory: containingDirectory,
|
|
35774
35781
|
reportDiagnostic: (diag2) => void diagnostics.push(diag2),
|
|
35775
|
-
isConfigLookup: false
|
|
35782
|
+
isConfigLookup: false,
|
|
35783
|
+
candidateIsFromPackageJsonField: false
|
|
35776
35784
|
};
|
|
35777
35785
|
let resolved = primaryLookup();
|
|
35778
35786
|
let primary = true;
|
|
@@ -36618,7 +36626,8 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
|
|
|
36618
36626
|
conditions,
|
|
36619
36627
|
requestContainingDirectory: containingDirectory,
|
|
36620
36628
|
reportDiagnostic: (diag2) => void diagnostics.push(diag2),
|
|
36621
|
-
isConfigLookup
|
|
36629
|
+
isConfigLookup,
|
|
36630
|
+
candidateIsFromPackageJsonField: false
|
|
36622
36631
|
};
|
|
36623
36632
|
if (traceEnabled && getEmitModuleResolutionKind(compilerOptions) >= 3 /* Node16 */ && getEmitModuleResolutionKind(compilerOptions) <= 99 /* NodeNext */) {
|
|
36624
36633
|
trace(host, Diagnostics.Resolving_in_0_mode_with_conditions_1, features & 32 /* EsmMode */ ? "ESM" : "CJS", conditions.map((c) => `'${c}'`).join(", "));
|
|
@@ -36842,7 +36851,7 @@ function tryAddingExtensions(candidate, extensions, originalExtension, onlyRecor
|
|
|
36842
36851
|
}
|
|
36843
36852
|
function tryExtension(ext, resolvedUsingTsExtension) {
|
|
36844
36853
|
const path = tryFile(candidate + ext, onlyRecordFailures, state);
|
|
36845
|
-
return path === void 0 ? void 0 : { path, ext, resolvedUsingTsExtension };
|
|
36854
|
+
return path === void 0 ? void 0 : { path, ext, resolvedUsingTsExtension: !state.candidateIsFromPackageJsonField && resolvedUsingTsExtension };
|
|
36846
36855
|
}
|
|
36847
36856
|
}
|
|
36848
36857
|
function tryFile(fileName, onlyRecordFailures, state) {
|
|
@@ -36888,7 +36897,8 @@ function getTemporaryModuleResolutionState(packageJsonInfoCache, host, options)
|
|
|
36888
36897
|
conditions: emptyArray,
|
|
36889
36898
|
requestContainingDirectory: void 0,
|
|
36890
36899
|
reportDiagnostic: noop,
|
|
36891
|
-
isConfigLookup: false
|
|
36900
|
+
isConfigLookup: false,
|
|
36901
|
+
candidateIsFromPackageJsonField: false
|
|
36892
36902
|
};
|
|
36893
36903
|
}
|
|
36894
36904
|
function getPackageScopeForPath(fileName, state) {
|
|
@@ -36976,6 +36986,8 @@ function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFail
|
|
|
36976
36986
|
}
|
|
36977
36987
|
const expandedExtensions = extensions2 === 4 /* Declaration */ ? 1 /* TypeScript */ | 4 /* Declaration */ : extensions2;
|
|
36978
36988
|
const features = state2.features;
|
|
36989
|
+
const candidateIsFromPackageJsonField = state2.candidateIsFromPackageJsonField;
|
|
36990
|
+
state2.candidateIsFromPackageJsonField = true;
|
|
36979
36991
|
if ((jsonContent == null ? void 0 : jsonContent.type) !== "module") {
|
|
36980
36992
|
state2.features &= ~32 /* EsmMode */;
|
|
36981
36993
|
}
|
|
@@ -36988,6 +37000,7 @@ function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFail
|
|
|
36988
37000
|
false
|
|
36989
37001
|
);
|
|
36990
37002
|
state2.features = features;
|
|
37003
|
+
state2.candidateIsFromPackageJsonField = candidateIsFromPackageJsonField;
|
|
36991
37004
|
return result;
|
|
36992
37005
|
};
|
|
36993
37006
|
const onlyRecordFailuresForPackageFile = packageFile ? !directoryProbablyExists(getDirectoryPath(packageFile), state.host) : void 0;
|
|
@@ -37061,7 +37074,10 @@ function loadModuleFromSelfNameReference(extensions, moduleName, directory, stat
|
|
|
37061
37074
|
return void 0;
|
|
37062
37075
|
}
|
|
37063
37076
|
const trailingParts = parts.slice(nameParts.length);
|
|
37064
|
-
|
|
37077
|
+
const subpath = !length(trailingParts) ? "." : `.${directorySeparator}${trailingParts.join(directorySeparator)}`;
|
|
37078
|
+
const priorityExtensions = extensions & (1 /* TypeScript */ | 4 /* Declaration */);
|
|
37079
|
+
const secondaryExtensions = extensions & ~(1 /* TypeScript */ | 4 /* Declaration */);
|
|
37080
|
+
return loadModuleFromExports(scope, priorityExtensions, subpath, state, cache, redirectedReference) || loadModuleFromExports(scope, secondaryExtensions, subpath, state, cache, redirectedReference);
|
|
37065
37081
|
}
|
|
37066
37082
|
function loadModuleFromExports(scope, extensions, subpath, state, cache, redirectedReference) {
|
|
37067
37083
|
if (!scope.contents.packageJsonContent.exports) {
|
|
@@ -37563,25 +37579,26 @@ function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, dir
|
|
|
37563
37579
|
}
|
|
37564
37580
|
}
|
|
37565
37581
|
function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state, cache, redirectedReference) {
|
|
37566
|
-
var _a2;
|
|
37582
|
+
var _a2, _b, _c;
|
|
37567
37583
|
const candidate = normalizePath(combinePaths(nodeModulesDirectory, moduleName));
|
|
37584
|
+
const { packageName, rest } = parsePackageName(moduleName);
|
|
37585
|
+
const packageDirectory = combinePaths(nodeModulesDirectory, packageName);
|
|
37586
|
+
let rootPackageInfo;
|
|
37568
37587
|
let packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
|
|
37569
|
-
if (!(state.features & 8 /* Exports */)) {
|
|
37570
|
-
|
|
37571
|
-
|
|
37572
|
-
|
|
37573
|
-
return noPackageId(fromFile);
|
|
37574
|
-
}
|
|
37575
|
-
const fromDirectory = loadNodeModuleFromDirectoryWorker(
|
|
37576
|
-
extensions,
|
|
37577
|
-
candidate,
|
|
37578
|
-
!nodeModulesDirectoryExists,
|
|
37579
|
-
state,
|
|
37580
|
-
packageInfo.contents.packageJsonContent,
|
|
37581
|
-
getVersionPathsOfPackageJsonInfo(packageInfo, state)
|
|
37582
|
-
);
|
|
37583
|
-
return withPackageId(packageInfo, fromDirectory);
|
|
37588
|
+
if (rest !== "" && packageInfo && (!(state.features & 8 /* Exports */) || !hasProperty((_b = (_a2 = rootPackageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state)) == null ? void 0 : _a2.contents.packageJsonContent) != null ? _b : emptyArray, "exports"))) {
|
|
37589
|
+
const fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
|
|
37590
|
+
if (fromFile) {
|
|
37591
|
+
return noPackageId(fromFile);
|
|
37584
37592
|
}
|
|
37593
|
+
const fromDirectory = loadNodeModuleFromDirectoryWorker(
|
|
37594
|
+
extensions,
|
|
37595
|
+
candidate,
|
|
37596
|
+
!nodeModulesDirectoryExists,
|
|
37597
|
+
state,
|
|
37598
|
+
packageInfo.contents.packageJsonContent,
|
|
37599
|
+
getVersionPathsOfPackageJsonInfo(packageInfo, state)
|
|
37600
|
+
);
|
|
37601
|
+
return withPackageId(packageInfo, fromDirectory);
|
|
37585
37602
|
}
|
|
37586
37603
|
const loader = (extensions2, candidate2, onlyRecordFailures, state2) => {
|
|
37587
37604
|
let pathAndExtension = loadModuleFromFile(extensions2, candidate2, onlyRecordFailures, state2) || loadNodeModuleFromDirectoryWorker(
|
|
@@ -37597,13 +37614,11 @@ function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, node
|
|
|
37597
37614
|
}
|
|
37598
37615
|
return withPackageId(packageInfo, pathAndExtension);
|
|
37599
37616
|
};
|
|
37600
|
-
const { packageName, rest } = parsePackageName(moduleName);
|
|
37601
|
-
const packageDirectory = combinePaths(nodeModulesDirectory, packageName);
|
|
37602
37617
|
if (rest !== "") {
|
|
37603
|
-
packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
|
|
37618
|
+
packageInfo = rootPackageInfo != null ? rootPackageInfo : getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
|
|
37604
37619
|
}
|
|
37605
37620
|
if (packageInfo && packageInfo.contents.packageJsonContent.exports && state.features & 8 /* Exports */) {
|
|
37606
|
-
return (
|
|
37621
|
+
return (_c = loadModuleFromExports(packageInfo, extensions, combinePaths(".", rest), state, cache, redirectedReference)) == null ? void 0 : _c.value;
|
|
37607
37622
|
}
|
|
37608
37623
|
const versionPaths = rest !== "" && packageInfo ? getVersionPathsOfPackageJsonInfo(packageInfo, state) : void 0;
|
|
37609
37624
|
if (versionPaths) {
|
|
@@ -37720,7 +37735,8 @@ function classicNameResolver(moduleName, containingFile, compilerOptions, host,
|
|
|
37720
37735
|
conditions: [],
|
|
37721
37736
|
requestContainingDirectory: containingDirectory,
|
|
37722
37737
|
reportDiagnostic: (diag2) => void diagnostics.push(diag2),
|
|
37723
|
-
isConfigLookup: false
|
|
37738
|
+
isConfigLookup: false,
|
|
37739
|
+
candidateIsFromPackageJsonField: false
|
|
37724
37740
|
};
|
|
37725
37741
|
const resolved = tryResolve(1 /* TypeScript */ | 4 /* Declaration */) || tryResolve(2 /* JavaScript */ | (compilerOptions.resolveJsonModule ? 8 /* Json */ : 0));
|
|
37726
37742
|
return createResolvedModuleWithFailedLookupLocations(
|
|
@@ -37799,7 +37815,8 @@ function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, hos
|
|
|
37799
37815
|
conditions: [],
|
|
37800
37816
|
requestContainingDirectory: void 0,
|
|
37801
37817
|
reportDiagnostic: (diag2) => void diagnostics.push(diag2),
|
|
37802
|
-
isConfigLookup: false
|
|
37818
|
+
isConfigLookup: false,
|
|
37819
|
+
candidateIsFromPackageJsonField: false
|
|
37803
37820
|
};
|
|
37804
37821
|
const resolved = loadModuleFromImmediateNodeModulesDirectory(
|
|
37805
37822
|
4 /* Declaration */,
|
|
@@ -40560,8 +40577,12 @@ function createBinder() {
|
|
|
40560
40577
|
return false;
|
|
40561
40578
|
}
|
|
40562
40579
|
if (currentFlow === unreachableFlow) {
|
|
40563
|
-
const reportError =
|
|
40564
|
-
|
|
40580
|
+
const reportError = (
|
|
40581
|
+
// report error on all statements except empty ones
|
|
40582
|
+
isStatementButNotDeclaration(node) && node.kind !== 239 /* EmptyStatement */ || // report error on class declarations
|
|
40583
|
+
node.kind === 260 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set
|
|
40584
|
+
node.kind === 264 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)
|
|
40585
|
+
);
|
|
40565
40586
|
if (reportError) {
|
|
40566
40587
|
currentFlow = reportedUnreachableFlow;
|
|
40567
40588
|
if (!options.allowUnreachableCode) {
|
|
@@ -46367,7 +46388,8 @@ function createTypeChecker(host) {
|
|
|
46367
46388
|
const isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol
|
|
46368
46389
|
forEach(symbol.declarations, (declaration) => declaration.parent.kind === 308 /* SourceFile */ || declaration.parent.kind === 265 /* ModuleBlock */));
|
|
46369
46390
|
if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
|
|
46370
|
-
return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a4 = context.visitedTypes) == null ? void 0 : _a4.has(typeId))) &&
|
|
46391
|
+
return (!!(context.flags & 4096 /* UseTypeOfFunction */) || ((_a4 = context.visitedTypes) == null ? void 0 : _a4.has(typeId))) && // it is type of the symbol uses itself recursively
|
|
46392
|
+
(!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
|
|
46371
46393
|
}
|
|
46372
46394
|
}
|
|
46373
46395
|
}
|
|
@@ -46459,7 +46481,9 @@ function createTypeChecker(host) {
|
|
|
46459
46481
|
const abstractSignatures = filter(resolved.constructSignatures, (signature) => !!(signature.flags & 4 /* Abstract */));
|
|
46460
46482
|
if (some(abstractSignatures)) {
|
|
46461
46483
|
const types = map(abstractSignatures, getOrCreateTypeFromSignature);
|
|
46462
|
-
const typeElementCount = resolved.callSignatures.length + (resolved.constructSignatures.length - abstractSignatures.length) + resolved.indexInfos.length +
|
|
46484
|
+
const typeElementCount = resolved.callSignatures.length + (resolved.constructSignatures.length - abstractSignatures.length) + resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per
|
|
46485
|
+
// the logic in `createTypeNodesFromResolvedType`.
|
|
46486
|
+
(context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? countWhere(resolved.properties, (p) => !(p.flags & 4194304 /* Prototype */)) : length(resolved.properties));
|
|
46463
46487
|
if (typeElementCount) {
|
|
46464
46488
|
types.push(getResolvedTypeWithoutAbstractConstructSignatures(resolved));
|
|
46465
46489
|
}
|
|
@@ -47121,9 +47145,11 @@ function createTypeChecker(host) {
|
|
|
47121
47145
|
if (accessibleSymbolChain) {
|
|
47122
47146
|
return accessibleSymbolChain;
|
|
47123
47147
|
}
|
|
47124
|
-
if (
|
|
47125
|
-
|
|
47126
|
-
|
|
47148
|
+
if (
|
|
47149
|
+
// If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols.
|
|
47150
|
+
endOfChain || // If a parent symbol is an anonymous type, don't write it.
|
|
47151
|
+
!(symbol2.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))
|
|
47152
|
+
) {
|
|
47127
47153
|
if (!endOfChain && !yieldModuleSymbol && !!forEach(symbol2.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
|
|
47128
47154
|
return;
|
|
47129
47155
|
}
|
|
@@ -47745,7 +47771,8 @@ function createTypeChecker(host) {
|
|
|
47745
47771
|
}
|
|
47746
47772
|
if (isLiteralImportTypeNode(node)) {
|
|
47747
47773
|
const nodeSymbol = getNodeLinks(node).resolvedSymbol;
|
|
47748
|
-
if (isInJSDoc(node) && nodeSymbol &&
|
|
47774
|
+
if (isInJSDoc(node) && nodeSymbol && // The import type resolved using jsdoc fallback logic
|
|
47775
|
+
(!node.isTypeOf && !(nodeSymbol.flags & 788968 /* Type */) || // The import type had type arguments autofilled by js fallback logic
|
|
47749
47776
|
!(length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
|
|
47750
47777
|
return setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
|
|
47751
47778
|
}
|
|
@@ -49262,8 +49289,10 @@ function createTypeChecker(host) {
|
|
|
49262
49289
|
}
|
|
49263
49290
|
}
|
|
49264
49291
|
function getNameOfSymbolAsWritten(symbol, context) {
|
|
49265
|
-
if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) &&
|
|
49266
|
-
!
|
|
49292
|
+
if (context && symbol.escapedName === "default" /* Default */ && !(context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */) && // If it's not the first part of an entity name, it must print as `default`
|
|
49293
|
+
(!(context.flags & 16777216 /* InInitialEntityName */) || // if the symbol is synthesized, it will only be referenced externally it must print as `default`
|
|
49294
|
+
!symbol.declarations || // if not in the same binding context (source file, module declaration), it must print as `default`
|
|
49295
|
+
context.enclosingDeclaration && findAncestor(symbol.declarations[0], isDefaultBindingContext) !== findAncestor(context.enclosingDeclaration, isDefaultBindingContext))) {
|
|
49267
49296
|
return "default";
|
|
49268
49297
|
}
|
|
49269
49298
|
if (symbol.declarations && symbol.declarations.length) {
|
|
@@ -50590,7 +50619,10 @@ function createTypeChecker(host) {
|
|
|
50590
50619
|
function getWriteTypeOfSymbol(symbol) {
|
|
50591
50620
|
const checkFlags = getCheckFlags(symbol);
|
|
50592
50621
|
if (symbol.flags & 4 /* Property */) {
|
|
50593
|
-
return checkFlags & 2 /* SyntheticProperty */ ? checkFlags & 65536 /* DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
|
|
50622
|
+
return checkFlags & 2 /* SyntheticProperty */ ? checkFlags & 65536 /* DeferredType */ ? getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) : (
|
|
50623
|
+
// NOTE: cast to TransientSymbol should be safe because only TransientSymbols can have CheckFlags.SyntheticProperty
|
|
50624
|
+
symbol.links.writeType || symbol.links.type
|
|
50625
|
+
) : getTypeOfSymbol(symbol);
|
|
50594
50626
|
}
|
|
50595
50627
|
if (symbol.flags & 98304 /* Accessor */) {
|
|
50596
50628
|
return checkFlags & 1 /* Instantiated */ ? getWriteTypeOfInstantiatedSymbol(symbol) : getWriteTypeOfAccessors(symbol);
|
|
@@ -50715,7 +50747,17 @@ function createTypeChecker(host) {
|
|
|
50715
50747
|
}
|
|
50716
50748
|
}
|
|
50717
50749
|
function getOuterTypeParametersOfClassOrInterface(symbol) {
|
|
50718
|
-
|
|
50750
|
+
var _a2;
|
|
50751
|
+
const declaration = symbol.flags & 32 /* Class */ || symbol.flags & 16 /* Function */ ? symbol.valueDeclaration : (_a2 = symbol.declarations) == null ? void 0 : _a2.find((decl) => {
|
|
50752
|
+
if (decl.kind === 261 /* InterfaceDeclaration */) {
|
|
50753
|
+
return true;
|
|
50754
|
+
}
|
|
50755
|
+
if (decl.kind !== 257 /* VariableDeclaration */) {
|
|
50756
|
+
return false;
|
|
50757
|
+
}
|
|
50758
|
+
const initializer = decl.initializer;
|
|
50759
|
+
return !!initializer && (initializer.kind === 215 /* FunctionExpression */ || initializer.kind === 216 /* ArrowFunction */);
|
|
50760
|
+
});
|
|
50719
50761
|
Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
|
|
50720
50762
|
return getOuterTypeParameters(declaration);
|
|
50721
50763
|
}
|
|
@@ -58997,7 +59039,11 @@ function createTypeChecker(host) {
|
|
|
58997
59039
|
if (variances === emptyArray) {
|
|
58998
59040
|
return 1 /* Unknown */;
|
|
58999
59041
|
}
|
|
59000
|
-
const
|
|
59042
|
+
const params = getSymbolLinks(source2.aliasSymbol).typeParameters;
|
|
59043
|
+
const minParams = getMinTypeArgumentCount(params);
|
|
59044
|
+
const sourceTypes = fillMissingTypeArguments(source2.aliasTypeArguments, params, minParams, isInJSFile(source2.aliasSymbol.valueDeclaration));
|
|
59045
|
+
const targetTypes = fillMissingTypeArguments(target2.aliasTypeArguments, params, minParams, isInJSFile(source2.aliasSymbol.valueDeclaration));
|
|
59046
|
+
const varianceResult = relateVariances(sourceTypes, targetTypes, variances, intersectionState);
|
|
59001
59047
|
if (varianceResult !== void 0) {
|
|
59002
59048
|
return varianceResult;
|
|
59003
59049
|
}
|
|
@@ -61454,7 +61500,11 @@ function createTypeChecker(host) {
|
|
|
61454
61500
|
}
|
|
61455
61501
|
if (source.aliasSymbol && source.aliasSymbol === target.aliasSymbol) {
|
|
61456
61502
|
if (source.aliasTypeArguments) {
|
|
61457
|
-
|
|
61503
|
+
const params = getSymbolLinks(source.aliasSymbol).typeParameters;
|
|
61504
|
+
const minParams = getMinTypeArgumentCount(params);
|
|
61505
|
+
const sourceTypes = fillMissingTypeArguments(source.aliasTypeArguments, params, minParams, isInJSFile(source.aliasSymbol.valueDeclaration));
|
|
61506
|
+
const targetTypes = fillMissingTypeArguments(target.aliasTypeArguments, params, minParams, isInJSFile(source.aliasSymbol.valueDeclaration));
|
|
61507
|
+
inferFromTypeArguments(sourceTypes, targetTypes, getAliasVariances(source.aliasSymbol));
|
|
61458
61508
|
}
|
|
61459
61509
|
return;
|
|
61460
61510
|
}
|
|
@@ -62060,7 +62110,7 @@ function createTypeChecker(host) {
|
|
|
62060
62110
|
if (signature) {
|
|
62061
62111
|
const inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : void 0;
|
|
62062
62112
|
if (inference.contraCandidates) {
|
|
62063
|
-
const useCovariantType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) && some(inference.contraCandidates, (t) => isTypeSubtypeOf(inferredCovariantType, t)) && every(context.inferences, (other) => other
|
|
62113
|
+
const useCovariantType = inferredCovariantType && !(inferredCovariantType.flags & 131072 /* Never */) && some(inference.contraCandidates, (t) => isTypeSubtypeOf(inferredCovariantType, t)) && every(context.inferences, (other) => other !== inference && getConstraintOfTypeParameter(other.typeParameter) !== inference.typeParameter || every(other.candidates, (t) => isTypeSubtypeOf(t, inferredCovariantType)));
|
|
62064
62114
|
inferredType = useCovariantType ? inferredCovariantType : getContravariantInference(inference);
|
|
62065
62115
|
} else if (inferredCovariantType) {
|
|
62066
62116
|
inferredType = inferredCovariantType;
|
|
@@ -63536,12 +63586,13 @@ function createTypeChecker(host) {
|
|
|
63536
63586
|
if (propName === void 0) {
|
|
63537
63587
|
return type;
|
|
63538
63588
|
}
|
|
63539
|
-
const
|
|
63589
|
+
const optionalChain = isOptionalChain(access);
|
|
63590
|
+
const removeNullable = strictNullChecks && (optionalChain || isNonNullAccess(access)) && maybeTypeOfKind(type, 98304 /* Nullable */);
|
|
63540
63591
|
let propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type, propName);
|
|
63541
63592
|
if (!propType) {
|
|
63542
63593
|
return type;
|
|
63543
63594
|
}
|
|
63544
|
-
propType = removeNullable ? getOptionalType(propType) : propType;
|
|
63595
|
+
propType = removeNullable && optionalChain ? getOptionalType(propType) : propType;
|
|
63545
63596
|
const narrowedPropType = narrowType2(propType);
|
|
63546
63597
|
return filterType(type, (t) => {
|
|
63547
63598
|
const discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
|
|
@@ -63860,18 +63911,20 @@ function createTypeChecker(host) {
|
|
|
63860
63911
|
return narrowTypeByTypeFacts(type, nonPrimitiveType, 128 /* TypeofEQHostObject */);
|
|
63861
63912
|
}
|
|
63862
63913
|
function narrowTypeByTypeFacts(type, impliedType, facts) {
|
|
63863
|
-
return mapType(type, (t) =>
|
|
63864
|
-
|
|
63865
|
-
|
|
63866
|
-
|
|
63867
|
-
|
|
63868
|
-
|
|
63869
|
-
|
|
63870
|
-
|
|
63871
|
-
|
|
63872
|
-
|
|
63873
|
-
|
|
63874
|
-
|
|
63914
|
+
return mapType(type, (t) => (
|
|
63915
|
+
// We first check if a constituent is a subtype of the implied type. If so, we either keep or eliminate
|
|
63916
|
+
// the constituent based on its type facts. We use the strict subtype relation because it treats `object`
|
|
63917
|
+
// as a subtype of `{}`, and we need the type facts check because function types are subtypes of `object`,
|
|
63918
|
+
// but are classified as "function" according to `typeof`.
|
|
63919
|
+
isTypeRelatedTo(t, impliedType, strictSubtypeRelation) ? getTypeFacts(t) & facts ? t : neverType : (
|
|
63920
|
+
// We next check if the consituent is a supertype of the implied type. If so, we substitute the implied
|
|
63921
|
+
// type. This handles top types like `unknown` and `{}`, and supertypes like `{ toString(): string }`.
|
|
63922
|
+
isTypeSubtypeOf(impliedType, t) ? impliedType : (
|
|
63923
|
+
// Neither the constituent nor the implied type is a subtype of the other, however their domains may still
|
|
63924
|
+
// overlap. For example, an unconstrained type parameter and type `string`. If the type facts indicate
|
|
63925
|
+
// possible overlap, we form an intersection. Otherwise, we eliminate the constituent.
|
|
63926
|
+
getTypeFacts(t) & facts ? getIntersectionType([t, impliedType]) : neverType
|
|
63927
|
+
)
|
|
63875
63928
|
)
|
|
63876
63929
|
));
|
|
63877
63930
|
}
|
|
@@ -71442,7 +71495,8 @@ function createTypeChecker(host) {
|
|
|
71442
71495
|
}
|
|
71443
71496
|
}
|
|
71444
71497
|
function isIndirectCall(node) {
|
|
71445
|
-
return node.parent.kind === 214 /* ParenthesizedExpression */ && isNumericLiteral(node.left) && node.left.text === "0" && (isCallExpression(node.parent.parent) && node.parent.parent.expression === node.parent || node.parent.parent.kind === 212 /* TaggedTemplateExpression */) &&
|
|
71498
|
+
return node.parent.kind === 214 /* ParenthesizedExpression */ && isNumericLiteral(node.left) && node.left.text === "0" && (isCallExpression(node.parent.parent) && node.parent.parent.expression === node.parent || node.parent.parent.kind === 212 /* TaggedTemplateExpression */) && // special-case for "eval" because it's the only non-access case where an indirect call actually affects behavior.
|
|
71499
|
+
(isAccessExpression(node.right) || isIdentifier(node.right) && node.right.escapedText === "eval");
|
|
71446
71500
|
}
|
|
71447
71501
|
function checkForDisallowedESSymbolOperand(operator2) {
|
|
71448
71502
|
const offendingSymbolOperand = maybeTypeOfKindConsideringBaseConstraint(leftType, 12288 /* ESSymbolLike */) ? left : maybeTypeOfKindConsideringBaseConstraint(rightType, 12288 /* ESSymbolLike */) ? right : void 0;
|
|
@@ -78527,7 +78581,12 @@ function createTypeChecker(host) {
|
|
|
78527
78581
|
return false;
|
|
78528
78582
|
const symbol = getSymbolOfDeclaration(node);
|
|
78529
78583
|
const signaturesOfSymbol = getSignaturesOfSymbol(symbol);
|
|
78530
|
-
return signaturesOfSymbol.length > 1 ||
|
|
78584
|
+
return signaturesOfSymbol.length > 1 || // If there is single signature for the symbol, it is overload if that signature isn't coming from the node
|
|
78585
|
+
// e.g.: function foo(a: string): string;
|
|
78586
|
+
// function foo(a: any) { // This is implementation of the overloads
|
|
78587
|
+
// return a;
|
|
78588
|
+
// }
|
|
78589
|
+
signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node;
|
|
78531
78590
|
}
|
|
78532
78591
|
return false;
|
|
78533
78592
|
}
|
|
@@ -99965,6 +100024,9 @@ function createGetSymbolAccessibilityDiagnosticForNode(node) {
|
|
|
99965
100024
|
case 259 /* FunctionDeclaration */:
|
|
99966
100025
|
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
|
|
99967
100026
|
break;
|
|
100027
|
+
case 192 /* InferType */:
|
|
100028
|
+
diagnosticMessage = Diagnostics.Extends_clause_for_inferred_type_0_has_or_is_using_private_name_1;
|
|
100029
|
+
break;
|
|
99968
100030
|
case 262 /* TypeAliasDeclaration */:
|
|
99969
100031
|
diagnosticMessage = Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
|
|
99970
100032
|
break;
|
|
@@ -108937,7 +108999,8 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
108937
108999
|
const oldSourceFiles = oldProgram.getSourceFiles();
|
|
108938
109000
|
for (const oldSourceFile of oldSourceFiles) {
|
|
108939
109001
|
const newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
|
|
108940
|
-
if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat ||
|
|
109002
|
+
if (shouldCreateNewSourceFile || !newFile || newFile.impliedNodeFormat !== oldSourceFile.impliedNodeFormat || // old file wasn't redirect but new file is
|
|
109003
|
+
oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path) {
|
|
108941
109004
|
host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
|
|
108942
109005
|
}
|
|
108943
109006
|
}
|
|
@@ -113633,7 +113696,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
113633
113696
|
const name = loader.nameAndMode.getName(entry);
|
|
113634
113697
|
const mode = loader.nameAndMode.getMode(entry, containingSourceFile);
|
|
113635
113698
|
let resolution = resolutionsInFile.get(name, mode);
|
|
113636
|
-
if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated ||
|
|
113699
|
+
if (!seenNamesInFile.has(name, mode) && unmatchedRedirects || !resolution || resolution.isInvalidated || // If the name is unresolved import that was invalidated, recalculate
|
|
113700
|
+
hasInvalidatedNonRelativeUnresolvedImport && !isExternalModuleNameRelative(name) && shouldRetryResolution(resolution)) {
|
|
113637
113701
|
const existingResolution = resolution;
|
|
113638
113702
|
resolution = loader.resolve(name, mode);
|
|
113639
113703
|
if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
|