@typescript-deploys/pr-build 5.7.0-pr-56941-53 → 5.7.0-pr-57718-9
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 +292 -421
- package/lib/_typingsInstaller.js +1 -1
- package/lib/cs/diagnosticMessages.generated.json +12 -4
- package/lib/de/diagnosticMessages.generated.json +12 -4
- package/lib/es/diagnosticMessages.generated.json +12 -4
- package/lib/fr/diagnosticMessages.generated.json +12 -4
- package/lib/it/diagnosticMessages.generated.json +12 -4
- package/lib/ja/diagnosticMessages.generated.json +12 -4
- package/lib/ko/diagnosticMessages.generated.json +12 -4
- package/lib/lib.es2024.sharedmemory.d.ts +1 -1
- package/lib/pl/diagnosticMessages.generated.json +12 -4
- package/lib/pt-br/diagnosticMessages.generated.json +12 -4
- package/lib/ru/diagnosticMessages.generated.json +12 -4
- package/lib/tr/diagnosticMessages.generated.json +12 -4
- package/lib/typescript.js +535 -548
- package/lib/zh-cn/diagnosticMessages.generated.json +13 -5
- package/lib/zh-tw/diagnosticMessages.generated.json +12 -4
- package/package.json +1 -1
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.7";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20241031`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -3680,7 +3680,6 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
3680
3680
|
ObjectFlags3[ObjectFlags3["IsGenericObjectType"] = 4194304] = "IsGenericObjectType";
|
|
3681
3681
|
ObjectFlags3[ObjectFlags3["IsGenericIndexType"] = 8388608] = "IsGenericIndexType";
|
|
3682
3682
|
ObjectFlags3[ObjectFlags3["IsGenericType"] = 12582912] = "IsGenericType";
|
|
3683
|
-
ObjectFlags3[ObjectFlags3["IsNarrowedType"] = 16777216] = "IsNarrowedType";
|
|
3684
3683
|
ObjectFlags3[ObjectFlags3["ContainsIntersections"] = 16777216] = "ContainsIntersections";
|
|
3685
3684
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
|
|
3686
3685
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
@@ -15158,12 +15157,12 @@ function canHaveFlowNode(node) {
|
|
|
15158
15157
|
case 80 /* Identifier */:
|
|
15159
15158
|
case 110 /* ThisKeyword */:
|
|
15160
15159
|
case 108 /* SuperKeyword */:
|
|
15161
|
-
case 212 /* ElementAccessExpression */:
|
|
15162
|
-
case 211 /* PropertyAccessExpression */:
|
|
15163
|
-
case 218 /* FunctionExpression */:
|
|
15164
15160
|
case 166 /* QualifiedName */:
|
|
15165
15161
|
case 236 /* MetaProperty */:
|
|
15162
|
+
case 212 /* ElementAccessExpression */:
|
|
15163
|
+
case 211 /* PropertyAccessExpression */:
|
|
15166
15164
|
case 208 /* BindingElement */:
|
|
15165
|
+
case 218 /* FunctionExpression */:
|
|
15167
15166
|
case 219 /* ArrowFunction */:
|
|
15168
15167
|
case 174 /* MethodDeclaration */:
|
|
15169
15168
|
case 177 /* GetAccessor */:
|
|
@@ -16086,7 +16085,7 @@ function hasInvalidEscape(template) {
|
|
|
16086
16085
|
}
|
|
16087
16086
|
var doubleQuoteEscapedCharsRegExp = /[\\"\u0000-\u001f\u2028\u2029\u0085]/g;
|
|
16088
16087
|
var singleQuoteEscapedCharsRegExp = /[\\'\u0000-\u001f\u2028\u2029\u0085]/g;
|
|
16089
|
-
var backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u001f\u2028\u2029\u0085]/g;
|
|
16088
|
+
var backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u0009\u000b-\u001f\u2028\u2029\u0085]/g;
|
|
16090
16089
|
var escapedCharsMap = new Map(Object.entries({
|
|
16091
16090
|
" ": "\\t",
|
|
16092
16091
|
"\v": "\\v",
|
|
@@ -17377,6 +17376,13 @@ function getLastChild(node) {
|
|
|
17377
17376
|
});
|
|
17378
17377
|
return lastChild;
|
|
17379
17378
|
}
|
|
17379
|
+
function addToSeen(seen, key) {
|
|
17380
|
+
if (seen.has(key)) {
|
|
17381
|
+
return false;
|
|
17382
|
+
}
|
|
17383
|
+
seen.add(key);
|
|
17384
|
+
return true;
|
|
17385
|
+
}
|
|
17380
17386
|
function isTypeNodeKind(kind) {
|
|
17381
17387
|
return kind >= 182 /* FirstTypeNode */ && kind <= 205 /* LastTypeNode */ || kind === 133 /* AnyKeyword */ || kind === 159 /* UnknownKeyword */ || kind === 150 /* NumberKeyword */ || kind === 163 /* BigIntKeyword */ || kind === 151 /* ObjectKeyword */ || kind === 136 /* BooleanKeyword */ || kind === 154 /* StringKeyword */ || kind === 155 /* SymbolKeyword */ || kind === 116 /* VoidKeyword */ || kind === 157 /* UndefinedKeyword */ || kind === 146 /* NeverKeyword */ || kind === 141 /* IntrinsicKeyword */ || kind === 233 /* ExpressionWithTypeArguments */ || kind === 312 /* JSDocAllType */ || kind === 313 /* JSDocUnknownType */ || kind === 314 /* JSDocNullableType */ || kind === 315 /* JSDocNonNullableType */ || kind === 316 /* JSDocOptionalType */ || kind === 317 /* JSDocFunctionType */ || kind === 318 /* JSDocVariadicType */;
|
|
17382
17388
|
}
|
|
@@ -26006,13 +26012,23 @@ var importStarHelper = {
|
|
|
26006
26012
|
dependencies: [createBindingHelper, setModuleDefaultHelper],
|
|
26007
26013
|
priority: 2,
|
|
26008
26014
|
text: `
|
|
26009
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26010
|
-
|
|
26011
|
-
|
|
26012
|
-
|
|
26013
|
-
|
|
26014
|
-
|
|
26015
|
-
|
|
26015
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26016
|
+
var ownKeys = function(o) {
|
|
26017
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26018
|
+
var ar = [];
|
|
26019
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26020
|
+
return ar;
|
|
26021
|
+
};
|
|
26022
|
+
return ownKeys(o);
|
|
26023
|
+
};
|
|
26024
|
+
return function (mod) {
|
|
26025
|
+
if (mod && mod.__esModule) return mod;
|
|
26026
|
+
var result = {};
|
|
26027
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
26028
|
+
__setModuleDefault(result, mod);
|
|
26029
|
+
return result;
|
|
26030
|
+
};
|
|
26031
|
+
})();`
|
|
26016
26032
|
};
|
|
26017
26033
|
var importDefaultHelper = {
|
|
26018
26034
|
name: "typescript:commonjsimportdefault",
|
|
@@ -29532,10 +29548,12 @@ var Parser;
|
|
|
29532
29548
|
case 90 /* DefaultKeyword */:
|
|
29533
29549
|
return nextTokenCanFollowDefaultKeyword();
|
|
29534
29550
|
case 126 /* StaticKeyword */:
|
|
29551
|
+
nextToken();
|
|
29552
|
+
return canFollowModifier();
|
|
29535
29553
|
case 139 /* GetKeyword */:
|
|
29536
29554
|
case 153 /* SetKeyword */:
|
|
29537
29555
|
nextToken();
|
|
29538
|
-
return
|
|
29556
|
+
return canFollowGetOrSetKeyword();
|
|
29539
29557
|
default:
|
|
29540
29558
|
return nextTokenIsOnSameLineAndCanFollowModifier();
|
|
29541
29559
|
}
|
|
@@ -29553,6 +29571,9 @@ var Parser;
|
|
|
29553
29571
|
function canFollowModifier() {
|
|
29554
29572
|
return token() === 23 /* OpenBracketToken */ || token() === 19 /* OpenBraceToken */ || token() === 42 /* AsteriskToken */ || token() === 26 /* DotDotDotToken */ || isLiteralPropertyName();
|
|
29555
29573
|
}
|
|
29574
|
+
function canFollowGetOrSetKeyword() {
|
|
29575
|
+
return token() === 23 /* OpenBracketToken */ || isLiteralPropertyName();
|
|
29576
|
+
}
|
|
29556
29577
|
function nextTokenCanFollowDefaultKeyword() {
|
|
29557
29578
|
nextToken();
|
|
29558
29579
|
return token() === 86 /* ClassKeyword */ || token() === 100 /* FunctionKeyword */ || token() === 120 /* InterfaceKeyword */ || token() === 60 /* AtToken */ || token() === 128 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine) || token() === 134 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine);
|
|
@@ -38163,7 +38184,7 @@ function convertToTSConfig(configParseResult, configFileName, host) {
|
|
|
38163
38184
|
const providedKeys = new Set(optionMap.keys());
|
|
38164
38185
|
const impliedCompilerOptions = {};
|
|
38165
38186
|
for (const option in computedOptions) {
|
|
38166
|
-
if (!providedKeys.has(option) &&
|
|
38187
|
+
if (!providedKeys.has(option) && optionDependsOn(option, providedKeys)) {
|
|
38167
38188
|
const implied = computedOptions[option].computeValue(configParseResult.options);
|
|
38168
38189
|
const defaultValue = computedOptions[option].computeValue({});
|
|
38169
38190
|
if (implied !== defaultValue) {
|
|
@@ -38174,6 +38195,17 @@ function convertToTSConfig(configParseResult, configFileName, host) {
|
|
|
38174
38195
|
assign(config.compilerOptions, optionMapToObject(serializeCompilerOptions(impliedCompilerOptions, pathOptions)));
|
|
38175
38196
|
return config;
|
|
38176
38197
|
}
|
|
38198
|
+
function optionDependsOn(option, dependsOn) {
|
|
38199
|
+
const seen = /* @__PURE__ */ new Set();
|
|
38200
|
+
return optionDependsOnRecursive(option);
|
|
38201
|
+
function optionDependsOnRecursive(option2) {
|
|
38202
|
+
var _a;
|
|
38203
|
+
if (addToSeen(seen, option2)) {
|
|
38204
|
+
return some((_a = computedOptions[option2]) == null ? void 0 : _a.dependencies, (dep) => dependsOn.has(dep) || optionDependsOnRecursive(dep));
|
|
38205
|
+
}
|
|
38206
|
+
return false;
|
|
38207
|
+
}
|
|
38208
|
+
}
|
|
38177
38209
|
function optionMapToObject(optionMap) {
|
|
38178
38210
|
return Object.fromEntries(optionMap);
|
|
38179
38211
|
}
|
|
@@ -40474,25 +40506,28 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
|
|
|
40474
40506
|
return toSearchResult({ resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
|
|
40475
40507
|
}
|
|
40476
40508
|
if (!isExternalModuleNameRelative(moduleName)) {
|
|
40477
|
-
let resolved2;
|
|
40478
40509
|
if (features & 2 /* Imports */ && startsWith(moduleName, "#")) {
|
|
40479
|
-
|
|
40480
|
-
|
|
40481
|
-
|
|
40482
|
-
|
|
40510
|
+
const resolved3 = loadModuleFromImports(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
40511
|
+
if (resolved3) {
|
|
40512
|
+
return resolved3.value && { value: { resolved: resolved3.value, isExternalLibraryImport: false } };
|
|
40513
|
+
}
|
|
40483
40514
|
}
|
|
40484
|
-
if (
|
|
40485
|
-
|
|
40486
|
-
|
|
40487
|
-
|
|
40488
|
-
}
|
|
40489
|
-
return void 0;
|
|
40515
|
+
if (features & 4 /* SelfName */) {
|
|
40516
|
+
const resolved3 = loadModuleFromSelfNameReference(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
40517
|
+
if (resolved3) {
|
|
40518
|
+
return resolved3.value && { value: { resolved: resolved3.value, isExternalLibraryImport: false } };
|
|
40490
40519
|
}
|
|
40520
|
+
}
|
|
40521
|
+
if (moduleName.includes(":")) {
|
|
40491
40522
|
if (traceEnabled) {
|
|
40492
|
-
trace(host, Diagnostics.
|
|
40523
|
+
trace(host, Diagnostics.Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1, moduleName, formatExtensions(extensions2));
|
|
40493
40524
|
}
|
|
40494
|
-
|
|
40525
|
+
return void 0;
|
|
40495
40526
|
}
|
|
40527
|
+
if (traceEnabled) {
|
|
40528
|
+
trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_types_Colon_1, moduleName, formatExtensions(extensions2));
|
|
40529
|
+
}
|
|
40530
|
+
let resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
40496
40531
|
if (extensions2 & 4 /* Declaration */) {
|
|
40497
40532
|
resolved2 ?? (resolved2 = resolveFromTypeRoot(moduleName, state2));
|
|
40498
40533
|
}
|
|
@@ -40920,7 +40955,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
|
40920
40955
|
mainExport = scope.contents.packageJsonContent.exports["."];
|
|
40921
40956
|
}
|
|
40922
40957
|
if (mainExport) {
|
|
40923
|
-
const
|
|
40958
|
+
const loadModuleFromTargetExportOrImport = getLoadModuleFromTargetExportOrImport(
|
|
40924
40959
|
extensions,
|
|
40925
40960
|
state,
|
|
40926
40961
|
cache,
|
|
@@ -40930,7 +40965,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
|
40930
40965
|
/*isImports*/
|
|
40931
40966
|
false
|
|
40932
40967
|
);
|
|
40933
|
-
return
|
|
40968
|
+
return loadModuleFromTargetExportOrImport(
|
|
40934
40969
|
mainExport,
|
|
40935
40970
|
"",
|
|
40936
40971
|
/*pattern*/
|
|
@@ -40948,7 +40983,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
|
40948
40983
|
void 0
|
|
40949
40984
|
);
|
|
40950
40985
|
}
|
|
40951
|
-
const result =
|
|
40986
|
+
const result = loadModuleFromExportsOrImports(
|
|
40952
40987
|
extensions,
|
|
40953
40988
|
state,
|
|
40954
40989
|
cache,
|
|
@@ -41002,7 +41037,7 @@ function loadModuleFromImports(extensions, moduleName, directory, state, cache,
|
|
|
41002
41037
|
void 0
|
|
41003
41038
|
);
|
|
41004
41039
|
}
|
|
41005
|
-
const result =
|
|
41040
|
+
const result = loadModuleFromExportsOrImports(
|
|
41006
41041
|
extensions,
|
|
41007
41042
|
state,
|
|
41008
41043
|
cache,
|
|
@@ -41037,11 +41072,11 @@ function comparePatternKeys(a, b) {
|
|
|
41037
41072
|
if (b.length > a.length) return 1 /* GreaterThan */;
|
|
41038
41073
|
return 0 /* EqualTo */;
|
|
41039
41074
|
}
|
|
41040
|
-
function
|
|
41041
|
-
const
|
|
41075
|
+
function loadModuleFromExportsOrImports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
41076
|
+
const loadModuleFromTargetExportOrImport = getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
41042
41077
|
if (!endsWith(moduleName, directorySeparator) && !moduleName.includes("*") && hasProperty(lookupTable, moduleName)) {
|
|
41043
41078
|
const target = lookupTable[moduleName];
|
|
41044
|
-
return
|
|
41079
|
+
return loadModuleFromTargetExportOrImport(
|
|
41045
41080
|
target,
|
|
41046
41081
|
/*subpath*/
|
|
41047
41082
|
"",
|
|
@@ -41056,7 +41091,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
|
41056
41091
|
const target = lookupTable[potentialTarget];
|
|
41057
41092
|
const starPos = potentialTarget.indexOf("*");
|
|
41058
41093
|
const subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
41059
|
-
return
|
|
41094
|
+
return loadModuleFromTargetExportOrImport(
|
|
41060
41095
|
target,
|
|
41061
41096
|
subpath,
|
|
41062
41097
|
/*pattern*/
|
|
@@ -41066,7 +41101,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
|
41066
41101
|
} else if (endsWith(potentialTarget, "*") && startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
41067
41102
|
const target = lookupTable[potentialTarget];
|
|
41068
41103
|
const subpath = moduleName.substring(potentialTarget.length - 1);
|
|
41069
|
-
return
|
|
41104
|
+
return loadModuleFromTargetExportOrImport(
|
|
41070
41105
|
target,
|
|
41071
41106
|
subpath,
|
|
41072
41107
|
/*pattern*/
|
|
@@ -41076,7 +41111,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
|
41076
41111
|
} else if (startsWith(moduleName, potentialTarget)) {
|
|
41077
41112
|
const target = lookupTable[potentialTarget];
|
|
41078
41113
|
const subpath = moduleName.substring(potentialTarget.length);
|
|
41079
|
-
return
|
|
41114
|
+
return loadModuleFromTargetExportOrImport(
|
|
41080
41115
|
target,
|
|
41081
41116
|
subpath,
|
|
41082
41117
|
/*pattern*/
|
|
@@ -41096,9 +41131,9 @@ function hasOneAsterisk(patternKey) {
|
|
|
41096
41131
|
const firstStar = patternKey.indexOf("*");
|
|
41097
41132
|
return firstStar !== -1 && firstStar === patternKey.lastIndexOf("*");
|
|
41098
41133
|
}
|
|
41099
|
-
function
|
|
41100
|
-
return
|
|
41101
|
-
function
|
|
41134
|
+
function getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
41135
|
+
return loadModuleFromTargetExportOrImport;
|
|
41136
|
+
function loadModuleFromTargetExportOrImport(target, subpath, pattern, key) {
|
|
41102
41137
|
if (typeof target === "string") {
|
|
41103
41138
|
if (!pattern && subpath.length > 0 && !endsWith(target, "/")) {
|
|
41104
41139
|
if (state.traceEnabled) {
|
|
@@ -41188,7 +41223,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
|
41188
41223
|
if (condition === "default" || state.conditions.includes(condition) || isApplicableVersionedTypesKey(state.conditions, condition)) {
|
|
41189
41224
|
traceIfEnabled(state, Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
|
|
41190
41225
|
const subTarget = target[condition];
|
|
41191
|
-
const result =
|
|
41226
|
+
const result = loadModuleFromTargetExportOrImport(subTarget, subpath, pattern, key);
|
|
41192
41227
|
if (result) {
|
|
41193
41228
|
traceIfEnabled(state, Diagnostics.Resolved_under_condition_0, condition);
|
|
41194
41229
|
traceIfEnabled(state, Diagnostics.Exiting_conditional_exports);
|
|
@@ -41213,7 +41248,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
|
41213
41248
|
);
|
|
41214
41249
|
}
|
|
41215
41250
|
for (const elem of target) {
|
|
41216
|
-
const result =
|
|
41251
|
+
const result = loadModuleFromTargetExportOrImport(elem, subpath, pattern, key);
|
|
41217
41252
|
if (result) {
|
|
41218
41253
|
return result;
|
|
41219
41254
|
}
|
|
@@ -41873,7 +41908,6 @@ function createBinder() {
|
|
|
41873
41908
|
var preSwitchCaseFlow;
|
|
41874
41909
|
var activeLabelList;
|
|
41875
41910
|
var hasExplicitReturn;
|
|
41876
|
-
var inReturnStatement;
|
|
41877
41911
|
var hasFlowEffects;
|
|
41878
41912
|
var emitFlags;
|
|
41879
41913
|
var inStrictMode;
|
|
@@ -41946,7 +41980,6 @@ function createBinder() {
|
|
|
41946
41980
|
currentExceptionTarget = void 0;
|
|
41947
41981
|
activeLabelList = void 0;
|
|
41948
41982
|
hasExplicitReturn = false;
|
|
41949
|
-
inReturnStatement = false;
|
|
41950
41983
|
hasFlowEffects = false;
|
|
41951
41984
|
inAssignmentPattern = false;
|
|
41952
41985
|
emitFlags = 0 /* None */;
|
|
@@ -42711,10 +42744,7 @@ function createBinder() {
|
|
|
42711
42744
|
currentFlow = finishFlowLabel(postIfLabel);
|
|
42712
42745
|
}
|
|
42713
42746
|
function bindReturnOrThrow(node) {
|
|
42714
|
-
const oldInReturnStatement = inReturnStatement;
|
|
42715
|
-
inReturnStatement = true;
|
|
42716
42747
|
bind(node.expression);
|
|
42717
|
-
inReturnStatement = oldInReturnStatement;
|
|
42718
42748
|
if (node.kind === 253 /* ReturnStatement */) {
|
|
42719
42749
|
hasExplicitReturn = true;
|
|
42720
42750
|
if (currentReturnTarget) {
|
|
@@ -43075,16 +43105,10 @@ function createBinder() {
|
|
|
43075
43105
|
hasFlowEffects = false;
|
|
43076
43106
|
bindCondition(node.condition, trueLabel, falseLabel);
|
|
43077
43107
|
currentFlow = finishFlowLabel(trueLabel);
|
|
43078
|
-
if (inReturnStatement) {
|
|
43079
|
-
node.flowNodeWhenTrue = currentFlow;
|
|
43080
|
-
}
|
|
43081
43108
|
bind(node.questionToken);
|
|
43082
43109
|
bind(node.whenTrue);
|
|
43083
43110
|
addAntecedent(postExpressionLabel, currentFlow);
|
|
43084
43111
|
currentFlow = finishFlowLabel(falseLabel);
|
|
43085
|
-
if (inReturnStatement) {
|
|
43086
|
-
node.flowNodeWhenFalse = currentFlow;
|
|
43087
|
-
}
|
|
43088
43112
|
bind(node.colonToken);
|
|
43089
43113
|
bind(node.whenFalse);
|
|
43090
43114
|
addAntecedent(postExpressionLabel, currentFlow);
|
|
@@ -45017,31 +45041,29 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
|
|
|
45017
45041
|
return { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true };
|
|
45018
45042
|
}
|
|
45019
45043
|
}
|
|
45020
|
-
|
|
45021
|
-
|
|
45022
|
-
|
|
45023
|
-
|
|
45024
|
-
|
|
45025
|
-
|
|
45026
|
-
|
|
45027
|
-
|
|
45028
|
-
|
|
45029
|
-
|
|
45030
|
-
|
|
45031
|
-
|
|
45032
|
-
|
|
45033
|
-
|
|
45034
|
-
|
|
45035
|
-
|
|
45036
|
-
|
|
45037
|
-
if (pathContainsNodeModules(local)) {
|
|
45038
|
-
relativeSpecifiers = append(relativeSpecifiers, local);
|
|
45039
|
-
} else {
|
|
45040
|
-
pathsSpecifiers = append(pathsSpecifiers, local);
|
|
45041
|
-
}
|
|
45042
|
-
} else if (forAutoImport || !importedFileIsInNodeModules || modulePath.isInNodeModules) {
|
|
45044
|
+
const local = getLocalModuleSpecifier(
|
|
45045
|
+
modulePath.path,
|
|
45046
|
+
info,
|
|
45047
|
+
compilerOptions,
|
|
45048
|
+
host,
|
|
45049
|
+
options.overrideImportMode || importingSourceFile.impliedNodeFormat,
|
|
45050
|
+
preferences,
|
|
45051
|
+
/*pathsOnly*/
|
|
45052
|
+
modulePath.isRedirect || !!specifier
|
|
45053
|
+
);
|
|
45054
|
+
if (!local || forAutoImport && isExcludedByRegex(local, preferences.excludeRegexes)) {
|
|
45055
|
+
continue;
|
|
45056
|
+
}
|
|
45057
|
+
if (modulePath.isRedirect) {
|
|
45058
|
+
redirectPathsSpecifiers = append(redirectPathsSpecifiers, local);
|
|
45059
|
+
} else if (pathIsBareSpecifier(local)) {
|
|
45060
|
+
if (pathContainsNodeModules(local)) {
|
|
45043
45061
|
relativeSpecifiers = append(relativeSpecifiers, local);
|
|
45062
|
+
} else {
|
|
45063
|
+
pathsSpecifiers = append(pathsSpecifiers, local);
|
|
45044
45064
|
}
|
|
45065
|
+
} else if (forAutoImport || !importedFileIsInNodeModules || modulePath.isInNodeModules) {
|
|
45066
|
+
relativeSpecifiers = append(relativeSpecifiers, local);
|
|
45045
45067
|
}
|
|
45046
45068
|
}
|
|
45047
45069
|
return (pathsSpecifiers == null ? void 0 : pathsSpecifiers.length) ? { kind: "paths", moduleSpecifiers: pathsSpecifiers, computedWithoutCache: true } : (redirectPathsSpecifiers == null ? void 0 : redirectPathsSpecifiers.length) ? { kind: "redirect", moduleSpecifiers: redirectPathsSpecifiers, computedWithoutCache: true } : (nodeModulesSpecifiers == null ? void 0 : nodeModulesSpecifiers.length) ? { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true } : { kind: "relative", moduleSpecifiers: relativeSpecifiers ?? emptyArray, computedWithoutCache: true };
|
|
@@ -45087,7 +45109,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
45087
45109
|
importMode,
|
|
45088
45110
|
prefersTsExtension(allowedEndings)
|
|
45089
45111
|
);
|
|
45090
|
-
const fromPaths = pathsOnly || fromPackageJsonImports === void 0 ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) : void 0;
|
|
45112
|
+
const fromPaths = pathsOnly || fromPackageJsonImports === void 0 ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, baseDirectory, getCanonicalFileName, host, compilerOptions) : void 0;
|
|
45091
45113
|
if (pathsOnly) {
|
|
45092
45114
|
return fromPaths;
|
|
45093
45115
|
}
|
|
@@ -45301,10 +45323,11 @@ function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) {
|
|
|
45301
45323
|
return ambientModuleDeclare.name.text;
|
|
45302
45324
|
}
|
|
45303
45325
|
}
|
|
45304
|
-
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
45326
|
+
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, baseDirectory, getCanonicalFileName, host, compilerOptions) {
|
|
45305
45327
|
for (const key in paths) {
|
|
45306
45328
|
for (const patternText2 of paths[key]) {
|
|
45307
|
-
const
|
|
45329
|
+
const normalized = normalizePath(patternText2);
|
|
45330
|
+
const pattern = getRelativePathIfInSameVolume(normalized, baseDirectory, getCanonicalFileName) ?? normalized;
|
|
45308
45331
|
const indexOfStar = pattern.indexOf("*");
|
|
45309
45332
|
const candidates = allowedEndings.map((ending) => ({
|
|
45310
45333
|
ending,
|
|
@@ -45633,6 +45656,8 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
45633
45656
|
subModuleName,
|
|
45634
45657
|
versionPaths.paths,
|
|
45635
45658
|
allowedEndings,
|
|
45659
|
+
packageRootPath,
|
|
45660
|
+
getCanonicalFileName,
|
|
45636
45661
|
host,
|
|
45637
45662
|
options
|
|
45638
45663
|
);
|
|
@@ -46927,7 +46952,6 @@ function createTypeChecker(host) {
|
|
|
46927
46952
|
[".jsx", ".jsx"],
|
|
46928
46953
|
[".json", ".json"]
|
|
46929
46954
|
];
|
|
46930
|
-
var narrowableReturnTypeCache = /* @__PURE__ */ new Map();
|
|
46931
46955
|
initializeTypeChecker();
|
|
46932
46956
|
return checker;
|
|
46933
46957
|
function isDefinitelyReferenceToGlobalSymbolObject(node) {
|
|
@@ -50291,6 +50315,9 @@ function createTypeChecker(host) {
|
|
|
50291
50315
|
}
|
|
50292
50316
|
}
|
|
50293
50317
|
let annotationType = getTypeFromTypeNodeWithoutContext(existing);
|
|
50318
|
+
if (isErrorType(annotationType)) {
|
|
50319
|
+
return true;
|
|
50320
|
+
}
|
|
50294
50321
|
if (requiresAddingUndefined && annotationType) {
|
|
50295
50322
|
annotationType = getOptionalType(annotationType, !isParameter(node));
|
|
50296
50323
|
}
|
|
@@ -51317,7 +51344,7 @@ function createTypeChecker(host) {
|
|
|
51317
51344
|
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */);
|
|
51318
51345
|
for (const signature of signatures) {
|
|
51319
51346
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 173 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
51320
|
-
typeElements.push(preserveCommentsOn(methodDeclaration));
|
|
51347
|
+
typeElements.push(preserveCommentsOn(methodDeclaration, signature.declaration || propertySymbol.valueDeclaration));
|
|
51321
51348
|
}
|
|
51322
51349
|
if (signatures.length || !optionalToken) {
|
|
51323
51350
|
return;
|
|
@@ -51352,8 +51379,8 @@ function createTypeChecker(host) {
|
|
|
51352
51379
|
optionalToken,
|
|
51353
51380
|
propertyTypeNode
|
|
51354
51381
|
);
|
|
51355
|
-
typeElements.push(preserveCommentsOn(propertySignature));
|
|
51356
|
-
function preserveCommentsOn(node) {
|
|
51382
|
+
typeElements.push(preserveCommentsOn(propertySignature, propertySymbol.valueDeclaration));
|
|
51383
|
+
function preserveCommentsOn(node, range) {
|
|
51357
51384
|
var _a2;
|
|
51358
51385
|
const jsdocPropertyTag = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d) => d.kind === 348 /* JSDocPropertyTag */);
|
|
51359
51386
|
if (jsdocPropertyTag) {
|
|
@@ -51361,8 +51388,8 @@ function createTypeChecker(host) {
|
|
|
51361
51388
|
if (commentText) {
|
|
51362
51389
|
setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
|
|
51363
51390
|
}
|
|
51364
|
-
} else if (
|
|
51365
|
-
setCommentRange2(context, node,
|
|
51391
|
+
} else if (range) {
|
|
51392
|
+
setCommentRange2(context, node, range);
|
|
51366
51393
|
}
|
|
51367
51394
|
return node;
|
|
51368
51395
|
}
|
|
@@ -55474,7 +55501,7 @@ function createTypeChecker(host) {
|
|
|
55474
55501
|
const getter = getDeclarationOfKind(symbol, 177 /* GetAccessor */);
|
|
55475
55502
|
const setter = getDeclarationOfKind(symbol, 178 /* SetAccessor */);
|
|
55476
55503
|
const accessor = tryCast(getDeclarationOfKind(symbol, 172 /* PropertyDeclaration */), isAutoAccessorPropertyDeclaration);
|
|
55477
|
-
let type = getter && isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || getAnnotatedAccessorType(getter) || getAnnotatedAccessorType(setter) || getAnnotatedAccessorType(accessor) || getter && getter.body && getReturnTypeFromBody(getter) || accessor &&
|
|
55504
|
+
let type = getter && isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || getAnnotatedAccessorType(getter) || getAnnotatedAccessorType(setter) || getAnnotatedAccessorType(accessor) || getter && getter.body && getReturnTypeFromBody(getter) || accessor && getWidenedTypeForVariableLikeDeclaration(
|
|
55478
55505
|
accessor,
|
|
55479
55506
|
/*reportErrors*/
|
|
55480
55507
|
true
|
|
@@ -59157,14 +59184,11 @@ function createTypeChecker(host) {
|
|
|
59157
59184
|
function isNoInferType(type) {
|
|
59158
59185
|
return !!(type.flags & 33554432 /* Substitution */ && type.constraint.flags & 2 /* Unknown */);
|
|
59159
59186
|
}
|
|
59160
|
-
function
|
|
59161
|
-
return
|
|
59187
|
+
function getSubstitutionType(baseType, constraint) {
|
|
59188
|
+
return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint);
|
|
59162
59189
|
}
|
|
59163
|
-
function
|
|
59164
|
-
|
|
59165
|
-
}
|
|
59166
|
-
function getOrCreateSubstitutionType(baseType, constraint, isNarrowed) {
|
|
59167
|
-
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}${isNarrowed ? ">N" : ""}`;
|
|
59190
|
+
function getOrCreateSubstitutionType(baseType, constraint) {
|
|
59191
|
+
const id = `${getTypeId(baseType)}>${getTypeId(constraint)}`;
|
|
59168
59192
|
const cached = substitutionTypes.get(id);
|
|
59169
59193
|
if (cached) {
|
|
59170
59194
|
return cached;
|
|
@@ -59172,9 +59196,6 @@ function createTypeChecker(host) {
|
|
|
59172
59196
|
const result = createType(33554432 /* Substitution */);
|
|
59173
59197
|
result.baseType = baseType;
|
|
59174
59198
|
result.constraint = constraint;
|
|
59175
|
-
if (isNarrowed) {
|
|
59176
|
-
result.objectFlags |= 16777216 /* IsNarrowedType */;
|
|
59177
|
-
}
|
|
59178
59199
|
substitutionTypes.set(id, result);
|
|
59179
59200
|
return result;
|
|
59180
59201
|
}
|
|
@@ -61377,7 +61398,7 @@ function createTypeChecker(host) {
|
|
|
61377
61398
|
function isDeferredType(type, checkTuples) {
|
|
61378
61399
|
return isGenericType(type) || checkTuples && isTupleType(type) && some(getElementTypes(type), isGenericType);
|
|
61379
61400
|
}
|
|
61380
|
-
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments
|
|
61401
|
+
function getConditionalType(root, mapper, forConstraint, aliasSymbol, aliasTypeArguments) {
|
|
61381
61402
|
let result;
|
|
61382
61403
|
let extraTypes;
|
|
61383
61404
|
let tailCount = 0;
|
|
@@ -61394,11 +61415,10 @@ function createTypeChecker(host) {
|
|
|
61394
61415
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
61395
61416
|
return wildcardType;
|
|
61396
61417
|
}
|
|
61397
|
-
const effectiveCheckType = forNarrowing && isNarrowingSubstitutionType(checkType) ? checkType.constraint : checkType;
|
|
61398
61418
|
const checkTypeNode = skipTypeParentheses(root.node.checkType);
|
|
61399
61419
|
const extendsTypeNode = skipTypeParentheses(root.node.extendsType);
|
|
61400
61420
|
const checkTuples = isSimpleTupleType(checkTypeNode) && isSimpleTupleType(extendsTypeNode) && length(checkTypeNode.elements) === length(extendsTypeNode.elements);
|
|
61401
|
-
const checkTypeDeferred = isDeferredType(
|
|
61421
|
+
const checkTypeDeferred = isDeferredType(checkType, checkTuples);
|
|
61402
61422
|
let combinedMapper;
|
|
61403
61423
|
if (root.inferTypeParameters) {
|
|
61404
61424
|
const context = createInferenceContext(
|
|
@@ -61417,8 +61437,8 @@ function createTypeChecker(host) {
|
|
|
61417
61437
|
}
|
|
61418
61438
|
const inferredExtendsType = combinedMapper ? instantiateType(root.extendsType, combinedMapper) : extendsType;
|
|
61419
61439
|
if (!checkTypeDeferred && !isDeferredType(inferredExtendsType, checkTuples)) {
|
|
61420
|
-
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (
|
|
61421
|
-
if (
|
|
61440
|
+
if (!(inferredExtendsType.flags & 3 /* AnyOrUnknown */) && (checkType.flags & 1 /* Any */ || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
|
|
61441
|
+
if (checkType.flags & 1 /* Any */ || forConstraint && !(inferredExtendsType.flags & 131072 /* Never */) && someType(getPermissiveInstantiation(inferredExtendsType), (t) => isTypeAssignableTo(t, getPermissiveInstantiation(checkType)))) {
|
|
61422
61442
|
(extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
|
|
61423
61443
|
}
|
|
61424
61444
|
const falseType2 = getTypeFromTypeNode(root.node.falseType);
|
|
@@ -61435,7 +61455,7 @@ function createTypeChecker(host) {
|
|
|
61435
61455
|
result = instantiateType(falseType2, mapper);
|
|
61436
61456
|
break;
|
|
61437
61457
|
}
|
|
61438
|
-
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(
|
|
61458
|
+
if (inferredExtendsType.flags & 3 /* AnyOrUnknown */ || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
|
|
61439
61459
|
const trueType2 = getTypeFromTypeNode(root.node.trueType);
|
|
61440
61460
|
const trueMapper = combinedMapper || mapper;
|
|
61441
61461
|
if (canTailRecurse(trueType2, trueMapper)) {
|
|
@@ -61626,7 +61646,7 @@ function createTypeChecker(host) {
|
|
|
61626
61646
|
const links = getNodeLinks(node);
|
|
61627
61647
|
if (!links.resolvedType) {
|
|
61628
61648
|
const aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
61629
|
-
if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
|
|
61649
|
+
if (!node.symbol || getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
|
|
61630
61650
|
links.resolvedType = emptyTypeLiteralType;
|
|
61631
61651
|
} else {
|
|
61632
61652
|
let type = createObjectType(16 /* Anonymous */, node.symbol);
|
|
@@ -62401,44 +62421,8 @@ function createTypeChecker(host) {
|
|
|
62401
62421
|
if (!result) {
|
|
62402
62422
|
const newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
|
|
62403
62423
|
const checkType = root.checkType;
|
|
62404
|
-
|
|
62405
|
-
|
|
62406
|
-
const forNarrowing = distributionType && isNarrowingSubstitutionType(distributionType) && isNarrowableConditionalType(type, mapper);
|
|
62407
|
-
if (forNarrowing) {
|
|
62408
|
-
narrowingBaseType = distributionType.baseType;
|
|
62409
|
-
distributionType = getReducedType(distributionType.constraint);
|
|
62410
|
-
}
|
|
62411
|
-
if (distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */)) {
|
|
62412
|
-
const mapperCallback = narrowingBaseType ? (t) => getConditionalType(
|
|
62413
|
-
root,
|
|
62414
|
-
prependTypeMapping(checkType, getSubstitutionType(
|
|
62415
|
-
narrowingBaseType,
|
|
62416
|
-
t,
|
|
62417
|
-
/*isNarrowed*/
|
|
62418
|
-
true
|
|
62419
|
-
), newMapper),
|
|
62420
|
-
forConstraint,
|
|
62421
|
-
/*aliasSymbol*/
|
|
62422
|
-
void 0,
|
|
62423
|
-
/*aliasTypeArguments*/
|
|
62424
|
-
void 0,
|
|
62425
|
-
forNarrowing
|
|
62426
|
-
) : (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint);
|
|
62427
|
-
if (narrowingBaseType) {
|
|
62428
|
-
result = mapType(
|
|
62429
|
-
distributionType,
|
|
62430
|
-
mapperCallback,
|
|
62431
|
-
/*noReductions*/
|
|
62432
|
-
void 0,
|
|
62433
|
-
/*toIntersection*/
|
|
62434
|
-
true
|
|
62435
|
-
);
|
|
62436
|
-
} else {
|
|
62437
|
-
result = mapTypeWithAlias(distributionType, mapperCallback, aliasSymbol, aliasTypeArguments);
|
|
62438
|
-
}
|
|
62439
|
-
} else {
|
|
62440
|
-
result = getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing);
|
|
62441
|
-
}
|
|
62424
|
+
const distributionType = root.isDistributive ? getReducedType(getMappedType(checkType, newMapper)) : void 0;
|
|
62425
|
+
result = distributionType && checkType !== distributionType && distributionType.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments) : getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments);
|
|
62442
62426
|
root.instantiations.set(id, result);
|
|
62443
62427
|
}
|
|
62444
62428
|
return result;
|
|
@@ -62551,9 +62535,6 @@ function createTypeChecker(host) {
|
|
|
62551
62535
|
}
|
|
62552
62536
|
return type;
|
|
62553
62537
|
}
|
|
62554
|
-
function isGenericIndexedOrConditionalReturnType(type) {
|
|
62555
|
-
return !!(type.flags & (8388608 /* IndexedAccess */ | 16777216 /* Conditional */) && couldContainTypeVariables(type));
|
|
62556
|
-
}
|
|
62557
62538
|
function instantiateReverseMappedType(type, mapper) {
|
|
62558
62539
|
const innerMappedType = instantiateType(type.mappedType, mapper);
|
|
62559
62540
|
if (!(getObjectFlags(innerMappedType) & 32 /* Mapped */)) {
|
|
@@ -63584,12 +63565,10 @@ function createTypeChecker(host) {
|
|
|
63584
63565
|
function shouldNormalizeIntersection(type) {
|
|
63585
63566
|
let hasInstantiable = false;
|
|
63586
63567
|
let hasNullableOrEmpty = false;
|
|
63587
|
-
let hasSubstitution = false;
|
|
63588
63568
|
for (const t of type.types) {
|
|
63589
63569
|
hasInstantiable || (hasInstantiable = !!(t.flags & 465829888 /* Instantiable */));
|
|
63590
63570
|
hasNullableOrEmpty || (hasNullableOrEmpty = !!(t.flags & 98304 /* Nullable */) || isEmptyAnonymousObjectType(t));
|
|
63591
|
-
|
|
63592
|
-
if (hasInstantiable && hasNullableOrEmpty || hasSubstitution) return true;
|
|
63571
|
+
if (hasInstantiable && hasNullableOrEmpty) return true;
|
|
63593
63572
|
}
|
|
63594
63573
|
return false;
|
|
63595
63574
|
}
|
|
@@ -68724,7 +68703,7 @@ function createTypeChecker(host) {
|
|
|
68724
68703
|
function countTypes(type) {
|
|
68725
68704
|
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
68726
68705
|
}
|
|
68727
|
-
function mapType(type, mapper, noReductions
|
|
68706
|
+
function mapType(type, mapper, noReductions) {
|
|
68728
68707
|
if (type.flags & 131072 /* Never */) {
|
|
68729
68708
|
return type;
|
|
68730
68709
|
}
|
|
@@ -68746,7 +68725,7 @@ function createTypeChecker(host) {
|
|
|
68746
68725
|
}
|
|
68747
68726
|
}
|
|
68748
68727
|
}
|
|
68749
|
-
return changed ? mappedTypes &&
|
|
68728
|
+
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
|
68750
68729
|
}
|
|
68751
68730
|
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
68752
68731
|
return type.flags & 1048576 /* Union */ && aliasSymbol ? getUnionType(map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper);
|
|
@@ -70099,12 +70078,14 @@ function createTypeChecker(host) {
|
|
|
70099
70078
|
case 80 /* Identifier */:
|
|
70100
70079
|
if (!isMatchingReference(reference, expr) && inlineLevel < 5) {
|
|
70101
70080
|
const symbol = getResolvedSymbol(expr);
|
|
70102
|
-
|
|
70103
|
-
|
|
70104
|
-
|
|
70105
|
-
|
|
70106
|
-
|
|
70107
|
-
|
|
70081
|
+
if (isConstantVariable(symbol)) {
|
|
70082
|
+
const declaration = symbol.valueDeclaration;
|
|
70083
|
+
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isConstantReference(reference)) {
|
|
70084
|
+
inlineLevel++;
|
|
70085
|
+
const result = narrowType(type, declaration.initializer, assumeTrue);
|
|
70086
|
+
inlineLevel--;
|
|
70087
|
+
return result;
|
|
70088
|
+
}
|
|
70108
70089
|
}
|
|
70109
70090
|
}
|
|
70110
70091
|
// falls through
|
|
@@ -70139,14 +70120,6 @@ function createTypeChecker(host) {
|
|
|
70139
70120
|
return type;
|
|
70140
70121
|
}
|
|
70141
70122
|
}
|
|
70142
|
-
function getNarrowableInlineExpression(symbol) {
|
|
70143
|
-
if (isConstantVariable(symbol)) {
|
|
70144
|
-
const declaration = symbol.valueDeclaration;
|
|
70145
|
-
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer) {
|
|
70146
|
-
return declaration.initializer;
|
|
70147
|
-
}
|
|
70148
|
-
}
|
|
70149
|
-
}
|
|
70150
70123
|
function getTypeOfSymbolAtLocation(symbol, location) {
|
|
70151
70124
|
symbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
70152
70125
|
if (location.kind === 80 /* Identifier */ || location.kind === 81 /* PrivateIdentifier */) {
|
|
@@ -70336,11 +70309,11 @@ function createTypeChecker(host) {
|
|
|
70336
70309
|
));
|
|
70337
70310
|
return contextualType && !isGenericType(contextualType);
|
|
70338
70311
|
}
|
|
70339
|
-
function getNarrowableTypeForReference(type, reference, checkMode
|
|
70312
|
+
function getNarrowableTypeForReference(type, reference, checkMode) {
|
|
70340
70313
|
if (isNoInferType(type)) {
|
|
70341
70314
|
type = type.baseType;
|
|
70342
70315
|
}
|
|
70343
|
-
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (
|
|
70316
|
+
const substituteConstraints = !(checkMode && checkMode & 2 /* Inferential */) && someType(type, isGenericTypeWithUnionConstraint) && (isConstraintPosition(type, reference) || hasContextualTypeWithNoGenericTypes(reference, checkMode));
|
|
70344
70317
|
return substituteConstraints ? mapType(type, getBaseConstraintOrType) : type;
|
|
70345
70318
|
}
|
|
70346
70319
|
function isExportOrExportExpression(location) {
|
|
@@ -71465,16 +71438,9 @@ function createTypeChecker(host) {
|
|
|
71465
71438
|
function getContextualTypeForReturnExpression(node, contextFlags) {
|
|
71466
71439
|
const func = getContainingFunction(node);
|
|
71467
71440
|
if (func) {
|
|
71468
|
-
const functionFlags = getFunctionFlags(func);
|
|
71469
|
-
const links = getNodeLinks(node);
|
|
71470
|
-
if (links.contextualReturnType) {
|
|
71471
|
-
if (functionFlags & 2 /* Async */) {
|
|
71472
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
71473
|
-
}
|
|
71474
|
-
return links.contextualReturnType;
|
|
71475
|
-
}
|
|
71476
71441
|
let contextualReturnType = getContextualReturnType(func, contextFlags);
|
|
71477
71442
|
if (contextualReturnType) {
|
|
71443
|
+
const functionFlags = getFunctionFlags(func);
|
|
71478
71444
|
if (functionFlags & 1 /* Generator */) {
|
|
71479
71445
|
const isAsyncGenerator = (functionFlags & 2 /* Async */) !== 0;
|
|
71480
71446
|
if (contextualReturnType.flags & 1048576 /* Union */) {
|
|
@@ -72172,13 +72138,6 @@ function createTypeChecker(host) {
|
|
|
72172
72138
|
if (index >= 0) {
|
|
72173
72139
|
return contextualTypes[index];
|
|
72174
72140
|
}
|
|
72175
|
-
const links = getNodeLinks(node);
|
|
72176
|
-
if (links.contextualReturnType) {
|
|
72177
|
-
if (node.flags & 65536 /* AwaitContext */) {
|
|
72178
|
-
return getUnionType([links.contextualReturnType, createPromiseLikeType(links.contextualReturnType)]);
|
|
72179
|
-
}
|
|
72180
|
-
return links.contextualReturnType;
|
|
72181
|
-
}
|
|
72182
72141
|
const { parent } = node;
|
|
72183
72142
|
switch (parent.kind) {
|
|
72184
72143
|
case 260 /* VariableDeclaration */:
|
|
@@ -82618,7 +82577,7 @@ function createTypeChecker(host) {
|
|
|
82618
82577
|
return anyIterationTypes;
|
|
82619
82578
|
}
|
|
82620
82579
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
82621
|
-
const errorOutputContainer = errorNode ? { errors: void 0 } : void 0;
|
|
82580
|
+
const errorOutputContainer = errorNode ? { errors: void 0, skipLogging: true } : void 0;
|
|
82622
82581
|
const iterationTypes2 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
|
|
82623
82582
|
if (iterationTypes2 === noIterationTypes) {
|
|
82624
82583
|
if (errorNode) {
|
|
@@ -82786,11 +82745,27 @@ function createTypeChecker(host) {
|
|
|
82786
82745
|
if (isTypeAny(methodType)) {
|
|
82787
82746
|
return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
82788
82747
|
}
|
|
82789
|
-
const
|
|
82790
|
-
|
|
82748
|
+
const allSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : void 0;
|
|
82749
|
+
const validSignatures = filter(allSignatures, (sig) => getMinArgumentCount(sig) === 0);
|
|
82750
|
+
if (!some(validSignatures)) {
|
|
82751
|
+
if (errorNode && some(allSignatures)) {
|
|
82752
|
+
checkTypeAssignableTo(
|
|
82753
|
+
type,
|
|
82754
|
+
resolver.getGlobalIterableType(
|
|
82755
|
+
/*reportErrors*/
|
|
82756
|
+
true
|
|
82757
|
+
),
|
|
82758
|
+
errorNode,
|
|
82759
|
+
/*headMessage*/
|
|
82760
|
+
void 0,
|
|
82761
|
+
/*containingMessageChain*/
|
|
82762
|
+
void 0,
|
|
82763
|
+
errorOutputContainer
|
|
82764
|
+
);
|
|
82765
|
+
}
|
|
82791
82766
|
return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
82792
82767
|
}
|
|
82793
|
-
const iteratorType = getIntersectionType(map(
|
|
82768
|
+
const iteratorType = getIntersectionType(map(validSignatures, getReturnTypeOfSignature));
|
|
82794
82769
|
const iterationTypes = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache) ?? noIterationTypes;
|
|
82795
82770
|
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
82796
82771
|
}
|
|
@@ -83068,234 +83043,34 @@ function createTypeChecker(host) {
|
|
|
83068
83043
|
}
|
|
83069
83044
|
const signature = getSignatureFromDeclaration(container);
|
|
83070
83045
|
const returnType = getReturnTypeOfSignature(signature);
|
|
83046
|
+
const functionFlags = getFunctionFlags(container);
|
|
83071
83047
|
if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) {
|
|
83048
|
+
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
83072
83049
|
if (container.kind === 178 /* SetAccessor */) {
|
|
83073
83050
|
if (node.expression) {
|
|
83074
83051
|
error(node, Diagnostics.Setters_cannot_return_a_value);
|
|
83075
83052
|
}
|
|
83076
83053
|
} else if (container.kind === 176 /* Constructor */) {
|
|
83077
|
-
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
83078
83054
|
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
|
|
83079
83055
|
error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
|
|
83080
83056
|
}
|
|
83081
83057
|
} else if (getReturnTypeFromAnnotation(container)) {
|
|
83082
|
-
|
|
83058
|
+
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
|
|
83059
|
+
const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
83060
|
+
exprType,
|
|
83061
|
+
/*withAlias*/
|
|
83062
|
+
false,
|
|
83063
|
+
node,
|
|
83064
|
+
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
83065
|
+
) : exprType;
|
|
83066
|
+
if (unwrappedReturnType) {
|
|
83067
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
|
|
83068
|
+
}
|
|
83083
83069
|
}
|
|
83084
83070
|
} else if (container.kind !== 176 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
|
|
83085
83071
|
error(node, Diagnostics.Not_all_code_paths_return_a_value);
|
|
83086
83072
|
}
|
|
83087
83073
|
}
|
|
83088
|
-
function checkReturnStatementExpression(container, returnType, node, expr) {
|
|
83089
|
-
const functionFlags = getFunctionFlags(container);
|
|
83090
|
-
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
|
|
83091
|
-
if (expr) {
|
|
83092
|
-
const unwrappedExpr = skipParentheses(expr);
|
|
83093
|
-
if (isConditionalExpression(unwrappedExpr)) {
|
|
83094
|
-
return checkReturnConditionalExpression(container, returnType, node, unwrappedExpr);
|
|
83095
|
-
}
|
|
83096
|
-
}
|
|
83097
|
-
const exprType = expr ? checkExpressionCached(expr) : undefinedType;
|
|
83098
|
-
const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
83099
|
-
exprType,
|
|
83100
|
-
/*withAlias*/
|
|
83101
|
-
false,
|
|
83102
|
-
node,
|
|
83103
|
-
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
83104
|
-
) : exprType;
|
|
83105
|
-
const errorNode = node.expression && isConditionalExpression(skipParentheses(node.expression)) ? expr : node;
|
|
83106
|
-
if (checkTypeAssignableTo(
|
|
83107
|
-
unwrappedExprType,
|
|
83108
|
-
unwrappedReturnType,
|
|
83109
|
-
/*errorNode*/
|
|
83110
|
-
void 0
|
|
83111
|
-
)) {
|
|
83112
|
-
return;
|
|
83113
|
-
}
|
|
83114
|
-
if (!isGenericIndexedOrConditionalReturnType(unwrappedReturnType)) {
|
|
83115
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, expr);
|
|
83116
|
-
return;
|
|
83117
|
-
}
|
|
83118
|
-
const allTypeParameters = appendTypeParameters(getOuterTypeParameters(
|
|
83119
|
-
container,
|
|
83120
|
-
/*includeThisTypes*/
|
|
83121
|
-
false
|
|
83122
|
-
), getEffectiveTypeParameterDeclarations(container));
|
|
83123
|
-
const narrowableTypeParameters = allTypeParameters && getNarrowableTypeParameters(allTypeParameters);
|
|
83124
|
-
if (!narrowableTypeParameters || !narrowableTypeParameters.length || !isNarrowableReturnType(unwrappedReturnType)) {
|
|
83125
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, expr);
|
|
83126
|
-
return;
|
|
83127
|
-
}
|
|
83128
|
-
let narrowPosition = node;
|
|
83129
|
-
let narrowFlowNode = node.flowNode;
|
|
83130
|
-
if (expr && isConditionalExpression(expr.parent)) {
|
|
83131
|
-
narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
|
|
83132
|
-
narrowPosition = expr;
|
|
83133
|
-
}
|
|
83134
|
-
if (!narrowFlowNode) {
|
|
83135
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, expr);
|
|
83136
|
-
return;
|
|
83137
|
-
}
|
|
83138
|
-
const narrowed = mapDefined(narrowableTypeParameters, ([typeParam, symbol, reference]) => {
|
|
83139
|
-
const narrowReference = factory.cloneNode(reference);
|
|
83140
|
-
narrowReference.id = void 0;
|
|
83141
|
-
getNodeLinks(narrowReference).resolvedSymbol = symbol;
|
|
83142
|
-
setParent(narrowReference, narrowPosition.parent);
|
|
83143
|
-
narrowReference.flowNode = narrowFlowNode;
|
|
83144
|
-
const initialType = getNarrowableTypeForReference(
|
|
83145
|
-
typeParam,
|
|
83146
|
-
narrowReference,
|
|
83147
|
-
/*checkMode*/
|
|
83148
|
-
void 0,
|
|
83149
|
-
/*forReturnTypeNarrowing*/
|
|
83150
|
-
true
|
|
83151
|
-
);
|
|
83152
|
-
if (initialType === typeParam) {
|
|
83153
|
-
return void 0;
|
|
83154
|
-
}
|
|
83155
|
-
const flowType = getFlowTypeOfReference(narrowReference, initialType);
|
|
83156
|
-
const exprType2 = getTypeFromFlowType(flowType);
|
|
83157
|
-
if (isTypeAny(exprType2) || isErrorType(exprType2) || exprType2 === typeParam || exprType2 === mapType(typeParam, getBaseConstraintOrType)) {
|
|
83158
|
-
return void 0;
|
|
83159
|
-
}
|
|
83160
|
-
const narrowedType = getSubstitutionType(
|
|
83161
|
-
typeParam,
|
|
83162
|
-
exprType2,
|
|
83163
|
-
/*isNarrowed*/
|
|
83164
|
-
true
|
|
83165
|
-
);
|
|
83166
|
-
return [typeParam, narrowedType];
|
|
83167
|
-
});
|
|
83168
|
-
const narrowMapper = createTypeMapper(narrowed.map(([tp, _]) => tp), narrowed.map(([_, t]) => t));
|
|
83169
|
-
const narrowedReturnType = instantiateType(
|
|
83170
|
-
unwrappedReturnType,
|
|
83171
|
-
narrowMapper
|
|
83172
|
-
);
|
|
83173
|
-
if (expr) {
|
|
83174
|
-
const links = getNodeLinks(expr);
|
|
83175
|
-
if (!links.contextualReturnType) {
|
|
83176
|
-
links.contextualReturnType = narrowedReturnType;
|
|
83177
|
-
}
|
|
83178
|
-
}
|
|
83179
|
-
const narrowedExprType = expr ? checkExpression(expr) : undefinedType;
|
|
83180
|
-
const narrowedUnwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
83181
|
-
narrowedExprType,
|
|
83182
|
-
/*withAlias*/
|
|
83183
|
-
false,
|
|
83184
|
-
node,
|
|
83185
|
-
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
83186
|
-
) : narrowedExprType;
|
|
83187
|
-
checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, expr);
|
|
83188
|
-
}
|
|
83189
|
-
function checkReturnConditionalExpression(container, returnType, node, expr) {
|
|
83190
|
-
checkExpression(expr.condition);
|
|
83191
|
-
checkReturnStatementExpression(container, returnType, node, expr.whenTrue);
|
|
83192
|
-
checkReturnStatementExpression(container, returnType, node, expr.whenFalse);
|
|
83193
|
-
}
|
|
83194
|
-
function getNarrowableTypeParameters(candidates) {
|
|
83195
|
-
const narrowableParams = [];
|
|
83196
|
-
for (const typeParam of candidates) {
|
|
83197
|
-
const constraint = getConstraintOfTypeParameter(typeParam);
|
|
83198
|
-
if (!constraint || !(constraint.flags & 1048576 /* Union */)) continue;
|
|
83199
|
-
if (typeParam.symbol && typeParam.symbol.declarations && typeParam.symbol.declarations.length === 1) {
|
|
83200
|
-
const container = typeParam.symbol.declarations[0].parent;
|
|
83201
|
-
if (!isFunctionLike(container)) continue;
|
|
83202
|
-
let reference;
|
|
83203
|
-
let hasInvalidReference = false;
|
|
83204
|
-
for (const paramDecl of container.parameters) {
|
|
83205
|
-
const typeNode = paramDecl.type;
|
|
83206
|
-
if (!typeNode) continue;
|
|
83207
|
-
if (isTypeParameterReferenced(typeParam, typeNode)) {
|
|
83208
|
-
let candidateReference;
|
|
83209
|
-
if (isTypeReferenceNode(typeNode) && isReferenceToTypeParameter(typeParam, typeNode) && (candidateReference = getValidParameterReference(paramDecl, constraint))) {
|
|
83210
|
-
if (reference) {
|
|
83211
|
-
hasInvalidReference = true;
|
|
83212
|
-
break;
|
|
83213
|
-
}
|
|
83214
|
-
reference = candidateReference;
|
|
83215
|
-
continue;
|
|
83216
|
-
}
|
|
83217
|
-
hasInvalidReference = true;
|
|
83218
|
-
break;
|
|
83219
|
-
}
|
|
83220
|
-
}
|
|
83221
|
-
if (!hasInvalidReference && reference) {
|
|
83222
|
-
const symbol = getResolvedSymbol(reference);
|
|
83223
|
-
if (symbol !== unknownSymbol) narrowableParams.push([typeParam, symbol, reference]);
|
|
83224
|
-
}
|
|
83225
|
-
}
|
|
83226
|
-
}
|
|
83227
|
-
return narrowableParams;
|
|
83228
|
-
function getValidParameterReference(paramDecl, constraint) {
|
|
83229
|
-
if (!isIdentifier(paramDecl.name)) return;
|
|
83230
|
-
if (paramDecl.questionToken && !containsUndefinedType(constraint)) return;
|
|
83231
|
-
return paramDecl.name;
|
|
83232
|
-
}
|
|
83233
|
-
function isReferenceToTypeParameter(typeParam, node) {
|
|
83234
|
-
return getTypeFromTypeReference(node) === typeParam;
|
|
83235
|
-
}
|
|
83236
|
-
function isTypeParameterReferenced(typeParam, node) {
|
|
83237
|
-
return isReferenced(node);
|
|
83238
|
-
function isReferenced(node2) {
|
|
83239
|
-
if (isTypeReferenceNode(node2)) {
|
|
83240
|
-
return isReferenceToTypeParameter(typeParam, node2);
|
|
83241
|
-
}
|
|
83242
|
-
if (isTypeQueryNode(node2)) {
|
|
83243
|
-
return isTypeParameterPossiblyReferenced(typeParam, node2);
|
|
83244
|
-
}
|
|
83245
|
-
return !!forEachChild(node2, isReferenced);
|
|
83246
|
-
}
|
|
83247
|
-
}
|
|
83248
|
-
}
|
|
83249
|
-
function isNarrowableReturnType(returnType) {
|
|
83250
|
-
return isConditionalType(returnType) ? isNarrowableConditionalType(returnType) : !!(returnType.indexType.flags & 262144 /* TypeParameter */);
|
|
83251
|
-
}
|
|
83252
|
-
function isNarrowableConditionalType(type, mapper) {
|
|
83253
|
-
const typeArguments = mapper && map(type.root.outerTypeParameters, (t) => {
|
|
83254
|
-
const mapped = getMappedType(t, mapper);
|
|
83255
|
-
if (isNarrowingSubstitutionType(mapped)) {
|
|
83256
|
-
return mapped.baseType;
|
|
83257
|
-
}
|
|
83258
|
-
return mapped;
|
|
83259
|
-
});
|
|
83260
|
-
const id = `${type.id}:${getTypeListId(typeArguments)}`;
|
|
83261
|
-
let result = narrowableReturnTypeCache.get(id);
|
|
83262
|
-
if (result === void 0) {
|
|
83263
|
-
const nonNarrowingMapper = type.root.outerTypeParameters && typeArguments && createTypeMapper(type.root.outerTypeParameters, typeArguments);
|
|
83264
|
-
const instantiatedType = instantiateType(type, nonNarrowingMapper);
|
|
83265
|
-
result = isConditionalType(instantiatedType) && isNarrowableConditionalTypeWorker(instantiatedType);
|
|
83266
|
-
narrowableReturnTypeCache.set(id, result);
|
|
83267
|
-
}
|
|
83268
|
-
return result;
|
|
83269
|
-
}
|
|
83270
|
-
function isNarrowableConditionalTypeWorker(type) {
|
|
83271
|
-
if (!type.root.isDistributive) {
|
|
83272
|
-
return false;
|
|
83273
|
-
}
|
|
83274
|
-
if (type.root.inferTypeParameters) {
|
|
83275
|
-
return false;
|
|
83276
|
-
}
|
|
83277
|
-
if (!(type.checkType.flags & 262144 /* TypeParameter */)) {
|
|
83278
|
-
return false;
|
|
83279
|
-
}
|
|
83280
|
-
const constraintType = getConstraintOfTypeParameter(type.checkType);
|
|
83281
|
-
if (!constraintType || !(constraintType.flags & 1048576 /* Union */)) {
|
|
83282
|
-
return false;
|
|
83283
|
-
}
|
|
83284
|
-
if (!everyType(type.extendsType, (extendsType) => some(
|
|
83285
|
-
constraintType.types,
|
|
83286
|
-
(constraintType2) => isTypeIdenticalTo(constraintType2, extendsType)
|
|
83287
|
-
))) {
|
|
83288
|
-
return false;
|
|
83289
|
-
}
|
|
83290
|
-
const trueType2 = getTrueTypeFromConditionalType(type);
|
|
83291
|
-
const falseType2 = getFalseTypeFromConditionalType(type);
|
|
83292
|
-
const isValidTrueType = isConditionalType(trueType2) ? isNarrowableConditionalType(trueType2) : true;
|
|
83293
|
-
const isValidFalseType = isConditionalType(falseType2) ? isNarrowableConditionalType(falseType2) : falseType2 === neverType;
|
|
83294
|
-
return isValidTrueType && isValidFalseType;
|
|
83295
|
-
}
|
|
83296
|
-
function isConditionalType(type) {
|
|
83297
|
-
return !!(type.flags & 16777216 /* Conditional */);
|
|
83298
|
-
}
|
|
83299
83074
|
function checkWithStatement(node) {
|
|
83300
83075
|
if (!checkGrammarStatementInAmbientContext(node)) {
|
|
83301
83076
|
if (node.flags & 65536 /* AwaitContext */) {
|
|
@@ -84224,6 +83999,9 @@ function createTypeChecker(host) {
|
|
|
84224
83999
|
}
|
|
84225
84000
|
function checkInterfaceDeclaration(node) {
|
|
84226
84001
|
if (!checkGrammarModifiers(node)) checkGrammarInterfaceDeclaration(node);
|
|
84002
|
+
if (!allowBlockDeclarations(node.parent)) {
|
|
84003
|
+
grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, "interface");
|
|
84004
|
+
}
|
|
84227
84005
|
checkTypeParameters(node.typeParameters);
|
|
84228
84006
|
addLazyDiagnostic(() => {
|
|
84229
84007
|
checkTypeNameIsReserved(node.name, Diagnostics.Interface_name_cannot_be_0);
|
|
@@ -84258,6 +84036,9 @@ function createTypeChecker(host) {
|
|
|
84258
84036
|
function checkTypeAliasDeclaration(node) {
|
|
84259
84037
|
checkGrammarModifiers(node);
|
|
84260
84038
|
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
|
|
84039
|
+
if (!allowBlockDeclarations(node.parent)) {
|
|
84040
|
+
grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, "type");
|
|
84041
|
+
}
|
|
84261
84042
|
checkExportsOnMergedDeclarations(node);
|
|
84262
84043
|
checkTypeParameters(node.typeParameters);
|
|
84263
84044
|
if (node.type.kind === 141 /* IntrinsicKeyword */) {
|
|
@@ -86644,7 +86425,7 @@ function createTypeChecker(host) {
|
|
|
86644
86425
|
const typeNode = getNonlocalEffectiveTypeAnnotationNode(parameter);
|
|
86645
86426
|
if (!typeNode) return false;
|
|
86646
86427
|
const type = getTypeFromTypeNode(typeNode);
|
|
86647
|
-
return containsUndefinedType(type);
|
|
86428
|
+
return isErrorType(type) || containsUndefinedType(type);
|
|
86648
86429
|
}
|
|
86649
86430
|
function requiresAddingImplicitUndefined(parameter, enclosingDeclaration) {
|
|
86650
86431
|
return (isRequiredInitializedParameter(parameter, enclosingDeclaration) || isOptionalUninitializedParameterProperty(parameter)) && !declaredParameterTypeContainsUndefined(parameter);
|
|
@@ -88670,7 +88451,7 @@ function createTypeChecker(host) {
|
|
|
88670
88451
|
}
|
|
88671
88452
|
return false;
|
|
88672
88453
|
}
|
|
88673
|
-
function
|
|
88454
|
+
function allowBlockDeclarations(parent) {
|
|
88674
88455
|
switch (parent.kind) {
|
|
88675
88456
|
case 245 /* IfStatement */:
|
|
88676
88457
|
case 246 /* DoStatement */:
|
|
@@ -88681,12 +88462,12 @@ function createTypeChecker(host) {
|
|
|
88681
88462
|
case 250 /* ForOfStatement */:
|
|
88682
88463
|
return false;
|
|
88683
88464
|
case 256 /* LabeledStatement */:
|
|
88684
|
-
return
|
|
88465
|
+
return allowBlockDeclarations(parent.parent);
|
|
88685
88466
|
}
|
|
88686
88467
|
return true;
|
|
88687
88468
|
}
|
|
88688
88469
|
function checkGrammarForDisallowedBlockScopedVariableStatement(node) {
|
|
88689
|
-
if (!
|
|
88470
|
+
if (!allowBlockDeclarations(node.parent)) {
|
|
88690
88471
|
const blockScopeKind = getCombinedNodeFlagsCached(node.declarationList) & 7 /* BlockScoped */;
|
|
88691
88472
|
if (blockScopeKind) {
|
|
88692
88473
|
const keyword = blockScopeKind === 1 /* Let */ ? "let" : blockScopeKind === 2 /* Const */ ? "const" : blockScopeKind === 4 /* Using */ ? "using" : blockScopeKind === 6 /* AwaitUsing */ ? "await using" : Debug.fail("Unknown BlockScope flag");
|
|
@@ -91292,9 +91073,9 @@ function getDecoratorsOfParameters(node) {
|
|
|
91292
91073
|
}
|
|
91293
91074
|
return decorators;
|
|
91294
91075
|
}
|
|
91295
|
-
function getAllDecoratorsOfClass(node) {
|
|
91076
|
+
function getAllDecoratorsOfClass(node, useLegacyDecorators) {
|
|
91296
91077
|
const decorators = getDecorators(node);
|
|
91297
|
-
const parameters = getDecoratorsOfParameters(getFirstConstructorWithBody(node));
|
|
91078
|
+
const parameters = useLegacyDecorators ? getDecoratorsOfParameters(getFirstConstructorWithBody(node)) : void 0;
|
|
91298
91079
|
if (!some(decorators) && !some(parameters)) {
|
|
91299
91080
|
return void 0;
|
|
91300
91081
|
}
|
|
@@ -91308,18 +91089,27 @@ function getAllDecoratorsOfClassElement(member, parent, useLegacyDecorators) {
|
|
|
91308
91089
|
case 177 /* GetAccessor */:
|
|
91309
91090
|
case 178 /* SetAccessor */:
|
|
91310
91091
|
if (!useLegacyDecorators) {
|
|
91311
|
-
return getAllDecoratorsOfMethod(
|
|
91092
|
+
return getAllDecoratorsOfMethod(
|
|
91093
|
+
member,
|
|
91094
|
+
/*useLegacyDecorators*/
|
|
91095
|
+
false
|
|
91096
|
+
);
|
|
91312
91097
|
}
|
|
91313
|
-
return getAllDecoratorsOfAccessors(
|
|
91098
|
+
return getAllDecoratorsOfAccessors(
|
|
91099
|
+
member,
|
|
91100
|
+
parent,
|
|
91101
|
+
/*useLegacyDecorators*/
|
|
91102
|
+
true
|
|
91103
|
+
);
|
|
91314
91104
|
case 174 /* MethodDeclaration */:
|
|
91315
|
-
return getAllDecoratorsOfMethod(member);
|
|
91105
|
+
return getAllDecoratorsOfMethod(member, useLegacyDecorators);
|
|
91316
91106
|
case 172 /* PropertyDeclaration */:
|
|
91317
91107
|
return getAllDecoratorsOfProperty(member);
|
|
91318
91108
|
default:
|
|
91319
91109
|
return void 0;
|
|
91320
91110
|
}
|
|
91321
91111
|
}
|
|
91322
|
-
function getAllDecoratorsOfAccessors(accessor, parent) {
|
|
91112
|
+
function getAllDecoratorsOfAccessors(accessor, parent, useLegacyDecorators) {
|
|
91323
91113
|
if (!accessor.body) {
|
|
91324
91114
|
return void 0;
|
|
91325
91115
|
}
|
|
@@ -91329,7 +91119,7 @@ function getAllDecoratorsOfAccessors(accessor, parent) {
|
|
|
91329
91119
|
return void 0;
|
|
91330
91120
|
}
|
|
91331
91121
|
const decorators = getDecorators(firstAccessorWithDecorators);
|
|
91332
|
-
const parameters = getDecoratorsOfParameters(setAccessor);
|
|
91122
|
+
const parameters = useLegacyDecorators ? getDecoratorsOfParameters(setAccessor) : void 0;
|
|
91333
91123
|
if (!some(decorators) && !some(parameters)) {
|
|
91334
91124
|
return void 0;
|
|
91335
91125
|
}
|
|
@@ -91340,12 +91130,12 @@ function getAllDecoratorsOfAccessors(accessor, parent) {
|
|
|
91340
91130
|
setDecorators: setAccessor && getDecorators(setAccessor)
|
|
91341
91131
|
};
|
|
91342
91132
|
}
|
|
91343
|
-
function getAllDecoratorsOfMethod(method) {
|
|
91133
|
+
function getAllDecoratorsOfMethod(method, useLegacyDecorators) {
|
|
91344
91134
|
if (!method.body) {
|
|
91345
91135
|
return void 0;
|
|
91346
91136
|
}
|
|
91347
91137
|
const decorators = getDecorators(method);
|
|
91348
|
-
const parameters = getDecoratorsOfParameters(method);
|
|
91138
|
+
const parameters = useLegacyDecorators ? getDecoratorsOfParameters(method) : void 0;
|
|
91349
91139
|
if (!some(decorators) && !some(parameters)) {
|
|
91350
91140
|
return void 0;
|
|
91351
91141
|
}
|
|
@@ -96979,7 +96769,11 @@ function transformLegacyDecorators(context) {
|
|
|
96979
96769
|
}
|
|
96980
96770
|
}
|
|
96981
96771
|
function generateConstructorDecorationExpression(node) {
|
|
96982
|
-
const allDecorators = getAllDecoratorsOfClass(
|
|
96772
|
+
const allDecorators = getAllDecoratorsOfClass(
|
|
96773
|
+
node,
|
|
96774
|
+
/*useLegacyDecorators*/
|
|
96775
|
+
true
|
|
96776
|
+
);
|
|
96983
96777
|
const decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
|
|
96984
96778
|
if (!decoratorExpressions) {
|
|
96985
96779
|
return void 0;
|
|
@@ -97491,7 +97285,11 @@ function transformESDecorators(context) {
|
|
|
97491
97285
|
let syntheticConstructor;
|
|
97492
97286
|
let heritageClauses;
|
|
97493
97287
|
let shouldTransformPrivateStaticElementsInClass = false;
|
|
97494
|
-
const classDecorators = transformAllDecoratorsOfDeclaration(getAllDecoratorsOfClass(
|
|
97288
|
+
const classDecorators = transformAllDecoratorsOfDeclaration(getAllDecoratorsOfClass(
|
|
97289
|
+
node,
|
|
97290
|
+
/*useLegacyDecorators*/
|
|
97291
|
+
false
|
|
97292
|
+
));
|
|
97495
97293
|
if (classDecorators) {
|
|
97496
97294
|
classInfo2.classDecoratorsName = factory2.createUniqueName("_classDecorators", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
97497
97295
|
classInfo2.classDescriptorName = factory2.createUniqueName("_classDescriptor", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
@@ -116986,15 +116784,88 @@ function createPrinter(printerOptions = {}, handlers = {}) {
|
|
|
116986
116784
|
return false;
|
|
116987
116785
|
}
|
|
116988
116786
|
function parenthesizeExpressionForNoAsi(node) {
|
|
116989
|
-
if (!commentsDisabled
|
|
116990
|
-
|
|
116991
|
-
|
|
116992
|
-
|
|
116993
|
-
|
|
116994
|
-
|
|
116995
|
-
|
|
116787
|
+
if (!commentsDisabled) {
|
|
116788
|
+
switch (node.kind) {
|
|
116789
|
+
case 355 /* PartiallyEmittedExpression */:
|
|
116790
|
+
if (willEmitLeadingNewLine(node)) {
|
|
116791
|
+
const parseNode = getParseTreeNode(node);
|
|
116792
|
+
if (parseNode && isParenthesizedExpression(parseNode)) {
|
|
116793
|
+
const parens = factory.createParenthesizedExpression(node.expression);
|
|
116794
|
+
setOriginalNode(parens, node);
|
|
116795
|
+
setTextRange(parens, parseNode);
|
|
116796
|
+
return parens;
|
|
116797
|
+
}
|
|
116798
|
+
return factory.createParenthesizedExpression(node);
|
|
116799
|
+
}
|
|
116800
|
+
return factory.updatePartiallyEmittedExpression(
|
|
116801
|
+
node,
|
|
116802
|
+
parenthesizeExpressionForNoAsi(node.expression)
|
|
116803
|
+
);
|
|
116804
|
+
case 211 /* PropertyAccessExpression */:
|
|
116805
|
+
return factory.updatePropertyAccessExpression(
|
|
116806
|
+
node,
|
|
116807
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
116808
|
+
node.name
|
|
116809
|
+
);
|
|
116810
|
+
case 212 /* ElementAccessExpression */:
|
|
116811
|
+
return factory.updateElementAccessExpression(
|
|
116812
|
+
node,
|
|
116813
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
116814
|
+
node.argumentExpression
|
|
116815
|
+
);
|
|
116816
|
+
case 213 /* CallExpression */:
|
|
116817
|
+
return factory.updateCallExpression(
|
|
116818
|
+
node,
|
|
116819
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
116820
|
+
node.typeArguments,
|
|
116821
|
+
node.arguments
|
|
116822
|
+
);
|
|
116823
|
+
case 215 /* TaggedTemplateExpression */:
|
|
116824
|
+
return factory.updateTaggedTemplateExpression(
|
|
116825
|
+
node,
|
|
116826
|
+
parenthesizeExpressionForNoAsi(node.tag),
|
|
116827
|
+
node.typeArguments,
|
|
116828
|
+
node.template
|
|
116829
|
+
);
|
|
116830
|
+
case 225 /* PostfixUnaryExpression */:
|
|
116831
|
+
return factory.updatePostfixUnaryExpression(
|
|
116832
|
+
node,
|
|
116833
|
+
parenthesizeExpressionForNoAsi(node.operand)
|
|
116834
|
+
);
|
|
116835
|
+
case 226 /* BinaryExpression */:
|
|
116836
|
+
return factory.updateBinaryExpression(
|
|
116837
|
+
node,
|
|
116838
|
+
parenthesizeExpressionForNoAsi(node.left),
|
|
116839
|
+
node.operatorToken,
|
|
116840
|
+
node.right
|
|
116841
|
+
);
|
|
116842
|
+
case 227 /* ConditionalExpression */:
|
|
116843
|
+
return factory.updateConditionalExpression(
|
|
116844
|
+
node,
|
|
116845
|
+
parenthesizeExpressionForNoAsi(node.condition),
|
|
116846
|
+
node.questionToken,
|
|
116847
|
+
node.whenTrue,
|
|
116848
|
+
node.colonToken,
|
|
116849
|
+
node.whenFalse
|
|
116850
|
+
);
|
|
116851
|
+
case 234 /* AsExpression */:
|
|
116852
|
+
return factory.updateAsExpression(
|
|
116853
|
+
node,
|
|
116854
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
116855
|
+
node.type
|
|
116856
|
+
);
|
|
116857
|
+
case 238 /* SatisfiesExpression */:
|
|
116858
|
+
return factory.updateSatisfiesExpression(
|
|
116859
|
+
node,
|
|
116860
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
116861
|
+
node.type
|
|
116862
|
+
);
|
|
116863
|
+
case 235 /* NonNullExpression */:
|
|
116864
|
+
return factory.updateNonNullExpression(
|
|
116865
|
+
node,
|
|
116866
|
+
parenthesizeExpressionForNoAsi(node.expression)
|
|
116867
|
+
);
|
|
116996
116868
|
}
|
|
116997
|
-
return factory.createParenthesizedExpression(node);
|
|
116998
116869
|
}
|
|
116999
116870
|
return node;
|
|
117000
116871
|
}
|