@typescript-deploys/pr-build 5.7.0-pr-56941-53 → 5.8.0-pr-52972-10
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 +623 -297
- package/lib/_tsserver.js +43 -7
- 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.decorators.d.ts +13 -15
- package/lib/lib.es2020.bigint.d.ts +2 -0
- package/lib/lib.es2024.sharedmemory.d.ts +1 -1
- package/lib/lib.esnext.d.ts +1 -0
- package/lib/lib.esnext.promise.d.ts +34 -0
- 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.d.ts +13 -14
- package/lib/typescript.js +1065 -509
- 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/cancellationToken.js +0 -90
package/lib/_tsc.js
CHANGED
|
@@ -17,8 +17,8 @@ and limitations under the License.
|
|
|
17
17
|
"use strict";
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
|
-
var versionMajorMinor = "5.
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
20
|
+
var versionMajorMinor = "5.8";
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20241127`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -3680,7 +3680,7 @@ 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["
|
|
3683
|
+
ObjectFlags3[ObjectFlags3["IsNarrowingType"] = 16777216] = "IsNarrowingType";
|
|
3684
3684
|
ObjectFlags3[ObjectFlags3["ContainsIntersections"] = 16777216] = "ContainsIntersections";
|
|
3685
3685
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnionComputed"] = 33554432] = "IsUnknownLikeUnionComputed";
|
|
3686
3686
|
ObjectFlags3[ObjectFlags3["IsUnknownLikeUnion"] = 67108864] = "IsUnknownLikeUnion";
|
|
@@ -15068,7 +15068,7 @@ function tryGetModuleSpecifierFromDeclaration(node) {
|
|
|
15068
15068
|
}
|
|
15069
15069
|
}
|
|
15070
15070
|
function shouldRewriteModuleSpecifier(specifier, compilerOptions) {
|
|
15071
|
-
return !!compilerOptions.rewriteRelativeImportExtensions && pathIsRelative(specifier) && !isDeclarationFileName(specifier);
|
|
15071
|
+
return !!compilerOptions.rewriteRelativeImportExtensions && pathIsRelative(specifier) && !isDeclarationFileName(specifier) && hasTSFileExtension(specifier);
|
|
15072
15072
|
}
|
|
15073
15073
|
function getExternalModuleName(node) {
|
|
15074
15074
|
switch (node.kind) {
|
|
@@ -15158,12 +15158,12 @@ function canHaveFlowNode(node) {
|
|
|
15158
15158
|
case 80 /* Identifier */:
|
|
15159
15159
|
case 110 /* ThisKeyword */:
|
|
15160
15160
|
case 108 /* SuperKeyword */:
|
|
15161
|
-
case 212 /* ElementAccessExpression */:
|
|
15162
|
-
case 211 /* PropertyAccessExpression */:
|
|
15163
|
-
case 218 /* FunctionExpression */:
|
|
15164
15161
|
case 166 /* QualifiedName */:
|
|
15165
15162
|
case 236 /* MetaProperty */:
|
|
15163
|
+
case 212 /* ElementAccessExpression */:
|
|
15164
|
+
case 211 /* PropertyAccessExpression */:
|
|
15166
15165
|
case 208 /* BindingElement */:
|
|
15166
|
+
case 218 /* FunctionExpression */:
|
|
15167
15167
|
case 219 /* ArrowFunction */:
|
|
15168
15168
|
case 174 /* MethodDeclaration */:
|
|
15169
15169
|
case 177 /* GetAccessor */:
|
|
@@ -16086,7 +16086,7 @@ function hasInvalidEscape(template) {
|
|
|
16086
16086
|
}
|
|
16087
16087
|
var doubleQuoteEscapedCharsRegExp = /[\\"\u0000-\u001f\u2028\u2029\u0085]/g;
|
|
16088
16088
|
var singleQuoteEscapedCharsRegExp = /[\\'\u0000-\u001f\u2028\u2029\u0085]/g;
|
|
16089
|
-
var backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u001f\u2028\u2029\u0085]/g;
|
|
16089
|
+
var backtickQuoteEscapedCharsRegExp = /\r\n|[\\`\u0000-\u0009\u000b-\u001f\u2028\u2029\u0085]/g;
|
|
16090
16090
|
var escapedCharsMap = new Map(Object.entries({
|
|
16091
16091
|
" ": "\\t",
|
|
16092
16092
|
"\v": "\\v",
|
|
@@ -17377,6 +17377,13 @@ function getLastChild(node) {
|
|
|
17377
17377
|
});
|
|
17378
17378
|
return lastChild;
|
|
17379
17379
|
}
|
|
17380
|
+
function addToSeen(seen, key) {
|
|
17381
|
+
if (seen.has(key)) {
|
|
17382
|
+
return false;
|
|
17383
|
+
}
|
|
17384
|
+
seen.add(key);
|
|
17385
|
+
return true;
|
|
17386
|
+
}
|
|
17380
17387
|
function isTypeNodeKind(kind) {
|
|
17381
17388
|
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
17389
|
}
|
|
@@ -22447,6 +22454,8 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
22447
22454
|
node.colonToken = colonToken ?? createToken(59 /* ColonToken */);
|
|
22448
22455
|
node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse);
|
|
22449
22456
|
node.transformFlags |= propagateChildFlags(node.condition) | propagateChildFlags(node.questionToken) | propagateChildFlags(node.whenTrue) | propagateChildFlags(node.colonToken) | propagateChildFlags(node.whenFalse);
|
|
22457
|
+
node.flowNodeWhenFalse = void 0;
|
|
22458
|
+
node.flowNodeWhenTrue = void 0;
|
|
22450
22459
|
return node;
|
|
22451
22460
|
}
|
|
22452
22461
|
function updateConditionalExpression(node, condition, questionToken, whenTrue, colonToken, whenFalse) {
|
|
@@ -24250,7 +24259,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
24250
24259
|
function isIgnorableParen(node) {
|
|
24251
24260
|
return isParenthesizedExpression(node) && nodeIsSynthesized(node) && nodeIsSynthesized(getSourceMapRange(node)) && nodeIsSynthesized(getCommentRange(node)) && !some(getSyntheticLeadingComments(node)) && !some(getSyntheticTrailingComments(node));
|
|
24252
24261
|
}
|
|
24253
|
-
function restoreOuterExpressions(outerExpression, innerExpression, kinds =
|
|
24262
|
+
function restoreOuterExpressions(outerExpression, innerExpression, kinds = 63 /* All */) {
|
|
24254
24263
|
if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
|
|
24255
24264
|
return updateOuterExpression(
|
|
24256
24265
|
outerExpression,
|
|
@@ -24296,7 +24305,7 @@ function createNodeFactory(flags, baseFactory2) {
|
|
|
24296
24305
|
}
|
|
24297
24306
|
}
|
|
24298
24307
|
function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers = false) {
|
|
24299
|
-
const callee = skipOuterExpressions(expression,
|
|
24308
|
+
const callee = skipOuterExpressions(expression, 63 /* All */);
|
|
24300
24309
|
let thisArg;
|
|
24301
24310
|
let target;
|
|
24302
24311
|
if (isSuperProperty(callee)) {
|
|
@@ -26006,13 +26015,23 @@ var importStarHelper = {
|
|
|
26006
26015
|
dependencies: [createBindingHelper, setModuleDefaultHelper],
|
|
26007
26016
|
priority: 2,
|
|
26008
26017
|
text: `
|
|
26009
|
-
var __importStar = (this && this.__importStar) || function (
|
|
26010
|
-
|
|
26011
|
-
|
|
26012
|
-
|
|
26013
|
-
|
|
26014
|
-
|
|
26015
|
-
|
|
26018
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26019
|
+
var ownKeys = function(o) {
|
|
26020
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26021
|
+
var ar = [];
|
|
26022
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26023
|
+
return ar;
|
|
26024
|
+
};
|
|
26025
|
+
return ownKeys(o);
|
|
26026
|
+
};
|
|
26027
|
+
return function (mod) {
|
|
26028
|
+
if (mod && mod.__esModule) return mod;
|
|
26029
|
+
var result = {};
|
|
26030
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
26031
|
+
__setModuleDefault(result, mod);
|
|
26032
|
+
return result;
|
|
26033
|
+
};
|
|
26034
|
+
})();`
|
|
26016
26035
|
};
|
|
26017
26036
|
var importDefaultHelper = {
|
|
26018
26037
|
name: "typescript:commonjsimportdefault",
|
|
@@ -27155,7 +27174,7 @@ function getJSDocTypeAssertionType(node) {
|
|
|
27155
27174
|
Debug.assertIsDefined(type);
|
|
27156
27175
|
return type;
|
|
27157
27176
|
}
|
|
27158
|
-
function isOuterExpression(node, kinds =
|
|
27177
|
+
function isOuterExpression(node, kinds = 63 /* All */) {
|
|
27159
27178
|
switch (node.kind) {
|
|
27160
27179
|
case 217 /* ParenthesizedExpression */:
|
|
27161
27180
|
if (kinds & -2147483648 /* ExcludeJSDocTypeAssertion */ && isJSDocTypeAssertion(node)) {
|
|
@@ -27164,8 +27183,9 @@ function isOuterExpression(node, kinds = 31 /* All */) {
|
|
|
27164
27183
|
return (kinds & 1 /* Parentheses */) !== 0;
|
|
27165
27184
|
case 216 /* TypeAssertionExpression */:
|
|
27166
27185
|
case 234 /* AsExpression */:
|
|
27167
|
-
case 238 /* SatisfiesExpression */:
|
|
27168
27186
|
return (kinds & 2 /* TypeAssertions */) !== 0;
|
|
27187
|
+
case 238 /* SatisfiesExpression */:
|
|
27188
|
+
return (kinds & (2 /* TypeAssertions */ | 32 /* Satisfies */)) !== 0;
|
|
27169
27189
|
case 233 /* ExpressionWithTypeArguments */:
|
|
27170
27190
|
return (kinds & 16 /* ExpressionsWithTypeArguments */) !== 0;
|
|
27171
27191
|
case 235 /* NonNullExpression */:
|
|
@@ -27175,13 +27195,13 @@ function isOuterExpression(node, kinds = 31 /* All */) {
|
|
|
27175
27195
|
}
|
|
27176
27196
|
return false;
|
|
27177
27197
|
}
|
|
27178
|
-
function skipOuterExpressions(node, kinds =
|
|
27198
|
+
function skipOuterExpressions(node, kinds = 63 /* All */) {
|
|
27179
27199
|
while (isOuterExpression(node, kinds)) {
|
|
27180
27200
|
node = node.expression;
|
|
27181
27201
|
}
|
|
27182
27202
|
return node;
|
|
27183
27203
|
}
|
|
27184
|
-
function walkUpOuterExpressions(node, kinds =
|
|
27204
|
+
function walkUpOuterExpressions(node, kinds = 63 /* All */) {
|
|
27185
27205
|
let parent = node.parent;
|
|
27186
27206
|
while (isOuterExpression(parent, kinds)) {
|
|
27187
27207
|
parent = parent.parent;
|
|
@@ -29532,10 +29552,12 @@ var Parser;
|
|
|
29532
29552
|
case 90 /* DefaultKeyword */:
|
|
29533
29553
|
return nextTokenCanFollowDefaultKeyword();
|
|
29534
29554
|
case 126 /* StaticKeyword */:
|
|
29555
|
+
nextToken();
|
|
29556
|
+
return canFollowModifier();
|
|
29535
29557
|
case 139 /* GetKeyword */:
|
|
29536
29558
|
case 153 /* SetKeyword */:
|
|
29537
29559
|
nextToken();
|
|
29538
|
-
return
|
|
29560
|
+
return canFollowGetOrSetKeyword();
|
|
29539
29561
|
default:
|
|
29540
29562
|
return nextTokenIsOnSameLineAndCanFollowModifier();
|
|
29541
29563
|
}
|
|
@@ -29553,6 +29575,9 @@ var Parser;
|
|
|
29553
29575
|
function canFollowModifier() {
|
|
29554
29576
|
return token() === 23 /* OpenBracketToken */ || token() === 19 /* OpenBraceToken */ || token() === 42 /* AsteriskToken */ || token() === 26 /* DotDotDotToken */ || isLiteralPropertyName();
|
|
29555
29577
|
}
|
|
29578
|
+
function canFollowGetOrSetKeyword() {
|
|
29579
|
+
return token() === 23 /* OpenBracketToken */ || isLiteralPropertyName();
|
|
29580
|
+
}
|
|
29556
29581
|
function nextTokenCanFollowDefaultKeyword() {
|
|
29557
29582
|
nextToken();
|
|
29558
29583
|
return token() === 86 /* ClassKeyword */ || token() === 100 /* FunctionKeyword */ || token() === 120 /* InterfaceKeyword */ || token() === 60 /* AtToken */ || token() === 128 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine) || token() === 134 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine);
|
|
@@ -36078,6 +36103,7 @@ var libEntries = [
|
|
|
36078
36103
|
["esnext.regexp", "lib.es2024.regexp.d.ts"],
|
|
36079
36104
|
["esnext.string", "lib.es2024.string.d.ts"],
|
|
36080
36105
|
["esnext.iterator", "lib.esnext.iterator.d.ts"],
|
|
36106
|
+
["esnext.promise", "lib.esnext.promise.d.ts"],
|
|
36081
36107
|
["decorators", "lib.decorators.d.ts"],
|
|
36082
36108
|
["decorators.legacy", "lib.decorators.legacy.d.ts"]
|
|
36083
36109
|
];
|
|
@@ -38163,7 +38189,7 @@ function convertToTSConfig(configParseResult, configFileName, host) {
|
|
|
38163
38189
|
const providedKeys = new Set(optionMap.keys());
|
|
38164
38190
|
const impliedCompilerOptions = {};
|
|
38165
38191
|
for (const option in computedOptions) {
|
|
38166
|
-
if (!providedKeys.has(option) &&
|
|
38192
|
+
if (!providedKeys.has(option) && optionDependsOn(option, providedKeys)) {
|
|
38167
38193
|
const implied = computedOptions[option].computeValue(configParseResult.options);
|
|
38168
38194
|
const defaultValue = computedOptions[option].computeValue({});
|
|
38169
38195
|
if (implied !== defaultValue) {
|
|
@@ -38174,6 +38200,17 @@ function convertToTSConfig(configParseResult, configFileName, host) {
|
|
|
38174
38200
|
assign(config.compilerOptions, optionMapToObject(serializeCompilerOptions(impliedCompilerOptions, pathOptions)));
|
|
38175
38201
|
return config;
|
|
38176
38202
|
}
|
|
38203
|
+
function optionDependsOn(option, dependsOn) {
|
|
38204
|
+
const seen = /* @__PURE__ */ new Set();
|
|
38205
|
+
return optionDependsOnRecursive(option);
|
|
38206
|
+
function optionDependsOnRecursive(option2) {
|
|
38207
|
+
var _a;
|
|
38208
|
+
if (addToSeen(seen, option2)) {
|
|
38209
|
+
return some((_a = computedOptions[option2]) == null ? void 0 : _a.dependencies, (dep) => dependsOn.has(dep) || optionDependsOnRecursive(dep));
|
|
38210
|
+
}
|
|
38211
|
+
return false;
|
|
38212
|
+
}
|
|
38213
|
+
}
|
|
38177
38214
|
function optionMapToObject(optionMap) {
|
|
38178
38215
|
return Object.fromEntries(optionMap);
|
|
38179
38216
|
}
|
|
@@ -40474,25 +40511,28 @@ function nodeModuleNameResolverWorker(features, moduleName, containingDirectory,
|
|
|
40474
40511
|
return toSearchResult({ resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
|
|
40475
40512
|
}
|
|
40476
40513
|
if (!isExternalModuleNameRelative(moduleName)) {
|
|
40477
|
-
let resolved2;
|
|
40478
40514
|
if (features & 2 /* Imports */ && startsWith(moduleName, "#")) {
|
|
40479
|
-
|
|
40480
|
-
|
|
40481
|
-
|
|
40482
|
-
|
|
40515
|
+
const resolved3 = loadModuleFromImports(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
40516
|
+
if (resolved3) {
|
|
40517
|
+
return resolved3.value && { value: { resolved: resolved3.value, isExternalLibraryImport: false } };
|
|
40518
|
+
}
|
|
40483
40519
|
}
|
|
40484
|
-
if (
|
|
40485
|
-
|
|
40486
|
-
|
|
40487
|
-
|
|
40488
|
-
}
|
|
40489
|
-
return void 0;
|
|
40520
|
+
if (features & 4 /* SelfName */) {
|
|
40521
|
+
const resolved3 = loadModuleFromSelfNameReference(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
40522
|
+
if (resolved3) {
|
|
40523
|
+
return resolved3.value && { value: { resolved: resolved3.value, isExternalLibraryImport: false } };
|
|
40490
40524
|
}
|
|
40525
|
+
}
|
|
40526
|
+
if (moduleName.includes(":")) {
|
|
40491
40527
|
if (traceEnabled) {
|
|
40492
|
-
trace(host, Diagnostics.
|
|
40528
|
+
trace(host, Diagnostics.Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1, moduleName, formatExtensions(extensions2));
|
|
40493
40529
|
}
|
|
40494
|
-
|
|
40530
|
+
return void 0;
|
|
40495
40531
|
}
|
|
40532
|
+
if (traceEnabled) {
|
|
40533
|
+
trace(host, Diagnostics.Loading_module_0_from_node_modules_folder_target_file_types_Colon_1, moduleName, formatExtensions(extensions2));
|
|
40534
|
+
}
|
|
40535
|
+
let resolved2 = loadModuleFromNearestNodeModulesDirectory(extensions2, moduleName, containingDirectory, state2, cache, redirectedReference);
|
|
40496
40536
|
if (extensions2 & 4 /* Declaration */) {
|
|
40497
40537
|
resolved2 ?? (resolved2 = resolveFromTypeRoot(moduleName, state2));
|
|
40498
40538
|
}
|
|
@@ -40920,7 +40960,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
|
40920
40960
|
mainExport = scope.contents.packageJsonContent.exports["."];
|
|
40921
40961
|
}
|
|
40922
40962
|
if (mainExport) {
|
|
40923
|
-
const
|
|
40963
|
+
const loadModuleFromTargetExportOrImport = getLoadModuleFromTargetExportOrImport(
|
|
40924
40964
|
extensions,
|
|
40925
40965
|
state,
|
|
40926
40966
|
cache,
|
|
@@ -40930,7 +40970,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
|
40930
40970
|
/*isImports*/
|
|
40931
40971
|
false
|
|
40932
40972
|
);
|
|
40933
|
-
return
|
|
40973
|
+
return loadModuleFromTargetExportOrImport(
|
|
40934
40974
|
mainExport,
|
|
40935
40975
|
"",
|
|
40936
40976
|
/*pattern*/
|
|
@@ -40948,7 +40988,7 @@ function loadModuleFromExports(scope, extensions, subpath, state, cache, redirec
|
|
|
40948
40988
|
void 0
|
|
40949
40989
|
);
|
|
40950
40990
|
}
|
|
40951
|
-
const result =
|
|
40991
|
+
const result = loadModuleFromExportsOrImports(
|
|
40952
40992
|
extensions,
|
|
40953
40993
|
state,
|
|
40954
40994
|
cache,
|
|
@@ -41002,7 +41042,7 @@ function loadModuleFromImports(extensions, moduleName, directory, state, cache,
|
|
|
41002
41042
|
void 0
|
|
41003
41043
|
);
|
|
41004
41044
|
}
|
|
41005
|
-
const result =
|
|
41045
|
+
const result = loadModuleFromExportsOrImports(
|
|
41006
41046
|
extensions,
|
|
41007
41047
|
state,
|
|
41008
41048
|
cache,
|
|
@@ -41037,11 +41077,11 @@ function comparePatternKeys(a, b) {
|
|
|
41037
41077
|
if (b.length > a.length) return 1 /* GreaterThan */;
|
|
41038
41078
|
return 0 /* EqualTo */;
|
|
41039
41079
|
}
|
|
41040
|
-
function
|
|
41041
|
-
const
|
|
41080
|
+
function loadModuleFromExportsOrImports(extensions, state, cache, redirectedReference, moduleName, lookupTable, scope, isImports) {
|
|
41081
|
+
const loadModuleFromTargetExportOrImport = getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
41042
41082
|
if (!endsWith(moduleName, directorySeparator) && !moduleName.includes("*") && hasProperty(lookupTable, moduleName)) {
|
|
41043
41083
|
const target = lookupTable[moduleName];
|
|
41044
|
-
return
|
|
41084
|
+
return loadModuleFromTargetExportOrImport(
|
|
41045
41085
|
target,
|
|
41046
41086
|
/*subpath*/
|
|
41047
41087
|
"",
|
|
@@ -41056,7 +41096,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
|
41056
41096
|
const target = lookupTable[potentialTarget];
|
|
41057
41097
|
const starPos = potentialTarget.indexOf("*");
|
|
41058
41098
|
const subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
41059
|
-
return
|
|
41099
|
+
return loadModuleFromTargetExportOrImport(
|
|
41060
41100
|
target,
|
|
41061
41101
|
subpath,
|
|
41062
41102
|
/*pattern*/
|
|
@@ -41066,7 +41106,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
|
41066
41106
|
} else if (endsWith(potentialTarget, "*") && startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
41067
41107
|
const target = lookupTable[potentialTarget];
|
|
41068
41108
|
const subpath = moduleName.substring(potentialTarget.length - 1);
|
|
41069
|
-
return
|
|
41109
|
+
return loadModuleFromTargetExportOrImport(
|
|
41070
41110
|
target,
|
|
41071
41111
|
subpath,
|
|
41072
41112
|
/*pattern*/
|
|
@@ -41076,7 +41116,7 @@ function loadModuleFromImportsOrExports(extensions, state, cache, redirectedRefe
|
|
|
41076
41116
|
} else if (startsWith(moduleName, potentialTarget)) {
|
|
41077
41117
|
const target = lookupTable[potentialTarget];
|
|
41078
41118
|
const subpath = moduleName.substring(potentialTarget.length);
|
|
41079
|
-
return
|
|
41119
|
+
return loadModuleFromTargetExportOrImport(
|
|
41080
41120
|
target,
|
|
41081
41121
|
subpath,
|
|
41082
41122
|
/*pattern*/
|
|
@@ -41096,9 +41136,9 @@ function hasOneAsterisk(patternKey) {
|
|
|
41096
41136
|
const firstStar = patternKey.indexOf("*");
|
|
41097
41137
|
return firstStar !== -1 && firstStar === patternKey.lastIndexOf("*");
|
|
41098
41138
|
}
|
|
41099
|
-
function
|
|
41100
|
-
return
|
|
41101
|
-
function
|
|
41139
|
+
function getLoadModuleFromTargetExportOrImport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
41140
|
+
return loadModuleFromTargetExportOrImport;
|
|
41141
|
+
function loadModuleFromTargetExportOrImport(target, subpath, pattern, key) {
|
|
41102
41142
|
if (typeof target === "string") {
|
|
41103
41143
|
if (!pattern && subpath.length > 0 && !endsWith(target, "/")) {
|
|
41104
41144
|
if (state.traceEnabled) {
|
|
@@ -41188,7 +41228,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
|
41188
41228
|
if (condition === "default" || state.conditions.includes(condition) || isApplicableVersionedTypesKey(state.conditions, condition)) {
|
|
41189
41229
|
traceIfEnabled(state, Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
|
|
41190
41230
|
const subTarget = target[condition];
|
|
41191
|
-
const result =
|
|
41231
|
+
const result = loadModuleFromTargetExportOrImport(subTarget, subpath, pattern, key);
|
|
41192
41232
|
if (result) {
|
|
41193
41233
|
traceIfEnabled(state, Diagnostics.Resolved_under_condition_0, condition);
|
|
41194
41234
|
traceIfEnabled(state, Diagnostics.Exiting_conditional_exports);
|
|
@@ -41213,7 +41253,7 @@ function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirec
|
|
|
41213
41253
|
);
|
|
41214
41254
|
}
|
|
41215
41255
|
for (const elem of target) {
|
|
41216
|
-
const result =
|
|
41256
|
+
const result = loadModuleFromTargetExportOrImport(elem, subpath, pattern, key);
|
|
41217
41257
|
if (result) {
|
|
41218
41258
|
return result;
|
|
41219
41259
|
}
|
|
@@ -41873,7 +41913,7 @@ function createBinder() {
|
|
|
41873
41913
|
var preSwitchCaseFlow;
|
|
41874
41914
|
var activeLabelList;
|
|
41875
41915
|
var hasExplicitReturn;
|
|
41876
|
-
var
|
|
41916
|
+
var inReturnPosition;
|
|
41877
41917
|
var hasFlowEffects;
|
|
41878
41918
|
var emitFlags;
|
|
41879
41919
|
var inStrictMode;
|
|
@@ -41946,7 +41986,7 @@ function createBinder() {
|
|
|
41946
41986
|
currentExceptionTarget = void 0;
|
|
41947
41987
|
activeLabelList = void 0;
|
|
41948
41988
|
hasExplicitReturn = false;
|
|
41949
|
-
|
|
41989
|
+
inReturnPosition = false;
|
|
41950
41990
|
hasFlowEffects = false;
|
|
41951
41991
|
inAssignmentPattern = false;
|
|
41952
41992
|
emitFlags = 0 /* None */;
|
|
@@ -42183,6 +42223,8 @@ function createBinder() {
|
|
|
42183
42223
|
const saveContainer = container;
|
|
42184
42224
|
const saveThisParentContainer = thisParentContainer;
|
|
42185
42225
|
const savedBlockScopeContainer = blockScopeContainer;
|
|
42226
|
+
const savedInReturnPosition = inReturnPosition;
|
|
42227
|
+
if (node.kind === 219 /* ArrowFunction */ && node.body.kind !== 241 /* Block */) inReturnPosition = true;
|
|
42186
42228
|
if (containerFlags & 1 /* IsContainer */) {
|
|
42187
42229
|
if (node.kind !== 219 /* ArrowFunction */) {
|
|
42188
42230
|
thisParentContainer = container;
|
|
@@ -42260,6 +42302,7 @@ function createBinder() {
|
|
|
42260
42302
|
} else {
|
|
42261
42303
|
bindChildren(node);
|
|
42262
42304
|
}
|
|
42305
|
+
inReturnPosition = savedInReturnPosition;
|
|
42263
42306
|
container = saveContainer;
|
|
42264
42307
|
thisParentContainer = saveThisParentContainer;
|
|
42265
42308
|
blockScopeContainer = savedBlockScopeContainer;
|
|
@@ -42711,10 +42754,10 @@ function createBinder() {
|
|
|
42711
42754
|
currentFlow = finishFlowLabel(postIfLabel);
|
|
42712
42755
|
}
|
|
42713
42756
|
function bindReturnOrThrow(node) {
|
|
42714
|
-
const
|
|
42715
|
-
|
|
42757
|
+
const savedInReturnPosition = inReturnPosition;
|
|
42758
|
+
inReturnPosition = true;
|
|
42716
42759
|
bind(node.expression);
|
|
42717
|
-
|
|
42760
|
+
inReturnPosition = savedInReturnPosition;
|
|
42718
42761
|
if (node.kind === 253 /* ReturnStatement */) {
|
|
42719
42762
|
hasExplicitReturn = true;
|
|
42720
42763
|
if (currentReturnTarget) {
|
|
@@ -43075,14 +43118,14 @@ function createBinder() {
|
|
|
43075
43118
|
hasFlowEffects = false;
|
|
43076
43119
|
bindCondition(node.condition, trueLabel, falseLabel);
|
|
43077
43120
|
currentFlow = finishFlowLabel(trueLabel);
|
|
43078
|
-
if (
|
|
43121
|
+
if (inReturnPosition) {
|
|
43079
43122
|
node.flowNodeWhenTrue = currentFlow;
|
|
43080
43123
|
}
|
|
43081
43124
|
bind(node.questionToken);
|
|
43082
43125
|
bind(node.whenTrue);
|
|
43083
43126
|
addAntecedent(postExpressionLabel, currentFlow);
|
|
43084
43127
|
currentFlow = finishFlowLabel(falseLabel);
|
|
43085
|
-
if (
|
|
43128
|
+
if (inReturnPosition) {
|
|
43086
43129
|
node.flowNodeWhenFalse = currentFlow;
|
|
43087
43130
|
}
|
|
43088
43131
|
bind(node.colonToken);
|
|
@@ -45017,31 +45060,29 @@ function computeModuleSpecifiers(modulePaths, compilerOptions, importingSourceFi
|
|
|
45017
45060
|
return { kind: "node_modules", moduleSpecifiers: nodeModulesSpecifiers, computedWithoutCache: true };
|
|
45018
45061
|
}
|
|
45019
45062
|
}
|
|
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) {
|
|
45063
|
+
const local = getLocalModuleSpecifier(
|
|
45064
|
+
modulePath.path,
|
|
45065
|
+
info,
|
|
45066
|
+
compilerOptions,
|
|
45067
|
+
host,
|
|
45068
|
+
options.overrideImportMode || importingSourceFile.impliedNodeFormat,
|
|
45069
|
+
preferences,
|
|
45070
|
+
/*pathsOnly*/
|
|
45071
|
+
modulePath.isRedirect || !!specifier
|
|
45072
|
+
);
|
|
45073
|
+
if (!local || forAutoImport && isExcludedByRegex(local, preferences.excludeRegexes)) {
|
|
45074
|
+
continue;
|
|
45075
|
+
}
|
|
45076
|
+
if (modulePath.isRedirect) {
|
|
45077
|
+
redirectPathsSpecifiers = append(redirectPathsSpecifiers, local);
|
|
45078
|
+
} else if (pathIsBareSpecifier(local)) {
|
|
45079
|
+
if (pathContainsNodeModules(local)) {
|
|
45043
45080
|
relativeSpecifiers = append(relativeSpecifiers, local);
|
|
45081
|
+
} else {
|
|
45082
|
+
pathsSpecifiers = append(pathsSpecifiers, local);
|
|
45044
45083
|
}
|
|
45084
|
+
} else if (forAutoImport || !importedFileIsInNodeModules || modulePath.isInNodeModules) {
|
|
45085
|
+
relativeSpecifiers = append(relativeSpecifiers, local);
|
|
45045
45086
|
}
|
|
45046
45087
|
}
|
|
45047
45088
|
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 +45128,7 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
45087
45128
|
importMode,
|
|
45088
45129
|
prefersTsExtension(allowedEndings)
|
|
45089
45130
|
);
|
|
45090
|
-
const fromPaths = pathsOnly || fromPackageJsonImports === void 0 ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) : void 0;
|
|
45131
|
+
const fromPaths = pathsOnly || fromPackageJsonImports === void 0 ? paths && tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, baseDirectory, getCanonicalFileName, host, compilerOptions) : void 0;
|
|
45091
45132
|
if (pathsOnly) {
|
|
45092
45133
|
return fromPaths;
|
|
45093
45134
|
}
|
|
@@ -45301,10 +45342,11 @@ function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) {
|
|
|
45301
45342
|
return ambientModuleDeclare.name.text;
|
|
45302
45343
|
}
|
|
45303
45344
|
}
|
|
45304
|
-
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
45345
|
+
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, baseDirectory, getCanonicalFileName, host, compilerOptions) {
|
|
45305
45346
|
for (const key in paths) {
|
|
45306
45347
|
for (const patternText2 of paths[key]) {
|
|
45307
|
-
const
|
|
45348
|
+
const normalized = normalizePath(patternText2);
|
|
45349
|
+
const pattern = getRelativePathIfInSameVolume(normalized, baseDirectory, getCanonicalFileName) ?? normalized;
|
|
45308
45350
|
const indexOfStar = pattern.indexOf("*");
|
|
45309
45351
|
const candidates = allowedEndings.map((ending) => ({
|
|
45310
45352
|
ending,
|
|
@@ -45633,6 +45675,8 @@ function tryGetModuleNameAsNodeModule({ path, isRedirect }, { getCanonicalFileNa
|
|
|
45633
45675
|
subModuleName,
|
|
45634
45676
|
versionPaths.paths,
|
|
45635
45677
|
allowedEndings,
|
|
45678
|
+
packageRootPath,
|
|
45679
|
+
getCanonicalFileName,
|
|
45636
45680
|
host,
|
|
45637
45681
|
options
|
|
45638
45682
|
);
|
|
@@ -46140,8 +46184,8 @@ function createTypeChecker(host) {
|
|
|
46140
46184
|
writeSignature: (signature, enclosingDeclaration, flags, kind, writer) => {
|
|
46141
46185
|
return signatureToString(signature, getParseTreeNode(enclosingDeclaration), flags, kind, writer);
|
|
46142
46186
|
},
|
|
46143
|
-
writeType: (type, enclosingDeclaration, flags, writer) => {
|
|
46144
|
-
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer);
|
|
46187
|
+
writeType: (type, enclosingDeclaration, flags, writer, verbosityLevel, out) => {
|
|
46188
|
+
return typeToString(type, getParseTreeNode(enclosingDeclaration), flags, writer, verbosityLevel, out);
|
|
46145
46189
|
},
|
|
46146
46190
|
writeSymbol: (symbol, enclosingDeclaration, meaning, flags, writer) => {
|
|
46147
46191
|
return symbolToString(symbol, getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
|
|
@@ -47791,9 +47835,9 @@ function createTypeChecker(host) {
|
|
|
47791
47835
|
const containerKind = grandparent.parent.kind;
|
|
47792
47836
|
if (containerKind === 264 /* InterfaceDeclaration */ && heritageKind === 96 /* ExtendsKeyword */) {
|
|
47793
47837
|
error(errorLocation, Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_It_can_only_extend_other_named_object_types, unescapeLeadingUnderscores(name));
|
|
47794
|
-
} else if (
|
|
47838
|
+
} else if (isClassLike(grandparent.parent) && heritageKind === 96 /* ExtendsKeyword */) {
|
|
47795
47839
|
error(errorLocation, Diagnostics.A_class_cannot_extend_a_primitive_type_like_0_Classes_can_only_extend_constructable_values, unescapeLeadingUnderscores(name));
|
|
47796
|
-
} else if (
|
|
47840
|
+
} else if (isClassLike(grandparent.parent) && heritageKind === 119 /* ImplementsKeyword */) {
|
|
47797
47841
|
error(errorLocation, Diagnostics.A_class_cannot_implement_a_primitive_type_like_0_It_can_only_implement_other_named_object_types, unescapeLeadingUnderscores(name));
|
|
47798
47842
|
}
|
|
47799
47843
|
} else {
|
|
@@ -49666,7 +49710,7 @@ function createTypeChecker(host) {
|
|
|
49666
49710
|
const links = getSymbolLinks(symbol);
|
|
49667
49711
|
const cache = links.accessibleChainCache || (links.accessibleChainCache = /* @__PURE__ */ new Map());
|
|
49668
49712
|
const firstRelevantLocation = forEachSymbolTableInScope(enclosingDeclaration, (_, __, ___, node) => node);
|
|
49669
|
-
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation
|
|
49713
|
+
const key = `${useOnlyExternalAliasing ? 0 : 1}|${firstRelevantLocation ? getNodeId(firstRelevantLocation) : 0}|${meaning}`;
|
|
49670
49714
|
if (cache.has(key)) {
|
|
49671
49715
|
return cache.get(key);
|
|
49672
49716
|
}
|
|
@@ -50063,14 +50107,18 @@ function createTypeChecker(host) {
|
|
|
50063
50107
|
return writer2;
|
|
50064
50108
|
}
|
|
50065
50109
|
}
|
|
50066
|
-
function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter("")) {
|
|
50067
|
-
const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation
|
|
50110
|
+
function typeToString(type, enclosingDeclaration, flags = 1048576 /* AllowUniqueESSymbolType */ | 16384 /* UseAliasDefinedOutsideCurrentScope */, writer = createTextWriter(""), verbosityLevel, out) {
|
|
50111
|
+
const noTruncation = compilerOptions.noErrorTruncation || flags & 1 /* NoTruncation */ || verbosityLevel !== void 0;
|
|
50068
50112
|
const typeNode = nodeBuilder.typeToTypeNode(
|
|
50069
50113
|
type,
|
|
50070
50114
|
enclosingDeclaration,
|
|
50071
|
-
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0
|
|
50115
|
+
toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | (noTruncation ? 1 /* NoTruncation */ : 0),
|
|
50072
50116
|
/*internalFlags*/
|
|
50073
|
-
void 0
|
|
50117
|
+
void 0,
|
|
50118
|
+
/*tracker*/
|
|
50119
|
+
void 0,
|
|
50120
|
+
verbosityLevel,
|
|
50121
|
+
out
|
|
50074
50122
|
);
|
|
50075
50123
|
if (typeNode === void 0) return Debug.fail("should always get typenode");
|
|
50076
50124
|
const printer = type !== unresolvedType ? createPrinterWithRemoveComments() : createPrinterWithDefaults();
|
|
@@ -50210,12 +50258,7 @@ function createTypeChecker(host) {
|
|
|
50210
50258
|
enterNewScope(context, node) {
|
|
50211
50259
|
if (isFunctionLike(node) || isJSDocSignature(node)) {
|
|
50212
50260
|
const signature = getSignatureFromDeclaration(node);
|
|
50213
|
-
|
|
50214
|
-
signature,
|
|
50215
|
-
/*skipUnionExpanding*/
|
|
50216
|
-
true
|
|
50217
|
-
)[0];
|
|
50218
|
-
return enterNewScope(context, node, expandedParams, signature.typeParameters);
|
|
50261
|
+
return enterNewScope(context, node, signature.parameters, signature.typeParameters);
|
|
50219
50262
|
} else {
|
|
50220
50263
|
const typeParameters = isConditionalTypeNode(node) ? getInferTypeParameters(node) : [getDeclaredTypeOfTypeParameter(getSymbolOfDeclaration(node.typeParameter))];
|
|
50221
50264
|
return enterNewScope(
|
|
@@ -50291,6 +50334,9 @@ function createTypeChecker(host) {
|
|
|
50291
50334
|
}
|
|
50292
50335
|
}
|
|
50293
50336
|
let annotationType = getTypeFromTypeNodeWithoutContext(existing);
|
|
50337
|
+
if (isErrorType(annotationType)) {
|
|
50338
|
+
return true;
|
|
50339
|
+
}
|
|
50294
50340
|
if (requiresAddingUndefined && annotationType) {
|
|
50295
50341
|
annotationType = getOptionalType(annotationType, !isParameter(node));
|
|
50296
50342
|
}
|
|
@@ -50299,31 +50345,127 @@ function createTypeChecker(host) {
|
|
|
50299
50345
|
};
|
|
50300
50346
|
return {
|
|
50301
50347
|
syntacticBuilderResolver,
|
|
50302
|
-
typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker) => withContext(enclosingDeclaration, flags, internalFlags, tracker, (context) => typeToTypeNodeHelper(type, context)),
|
|
50303
|
-
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50304
|
-
|
|
50305
|
-
|
|
50306
|
-
|
|
50307
|
-
|
|
50308
|
-
|
|
50309
|
-
|
|
50310
|
-
|
|
50311
|
-
|
|
50312
|
-
)
|
|
50313
|
-
|
|
50314
|
-
|
|
50315
|
-
|
|
50316
|
-
|
|
50317
|
-
|
|
50318
|
-
|
|
50319
|
-
|
|
50320
|
-
)
|
|
50321
|
-
|
|
50322
|
-
|
|
50323
|
-
|
|
50324
|
-
|
|
50325
|
-
|
|
50326
|
-
|
|
50348
|
+
typeToTypeNode: (type, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, out) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeToTypeNodeHelper(type, context), out),
|
|
50349
|
+
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50350
|
+
enclosingDeclaration,
|
|
50351
|
+
flags,
|
|
50352
|
+
internalFlags,
|
|
50353
|
+
tracker,
|
|
50354
|
+
/*verbosityLevel*/
|
|
50355
|
+
void 0,
|
|
50356
|
+
(context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)
|
|
50357
|
+
),
|
|
50358
|
+
serializeTypeForDeclaration: (declaration, symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50359
|
+
enclosingDeclaration,
|
|
50360
|
+
flags,
|
|
50361
|
+
internalFlags,
|
|
50362
|
+
tracker,
|
|
50363
|
+
/*verbosityLevel*/
|
|
50364
|
+
void 0,
|
|
50365
|
+
(context) => syntacticNodeBuilder.serializeTypeOfDeclaration(declaration, symbol, context)
|
|
50366
|
+
),
|
|
50367
|
+
serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50368
|
+
enclosingDeclaration,
|
|
50369
|
+
flags,
|
|
50370
|
+
internalFlags,
|
|
50371
|
+
tracker,
|
|
50372
|
+
/*verbosityLevel*/
|
|
50373
|
+
void 0,
|
|
50374
|
+
(context) => syntacticNodeBuilder.serializeReturnTypeForSignature(signature, getSymbolOfDeclaration(signature), context)
|
|
50375
|
+
),
|
|
50376
|
+
serializeTypeForExpression: (expr, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50377
|
+
enclosingDeclaration,
|
|
50378
|
+
flags,
|
|
50379
|
+
internalFlags,
|
|
50380
|
+
tracker,
|
|
50381
|
+
/*verbosityLevel*/
|
|
50382
|
+
void 0,
|
|
50383
|
+
(context) => syntacticNodeBuilder.serializeTypeOfExpression(expr, context)
|
|
50384
|
+
),
|
|
50385
|
+
indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50386
|
+
enclosingDeclaration,
|
|
50387
|
+
flags,
|
|
50388
|
+
internalFlags,
|
|
50389
|
+
tracker,
|
|
50390
|
+
/*verbosityLevel*/
|
|
50391
|
+
void 0,
|
|
50392
|
+
(context) => indexInfoToIndexSignatureDeclarationHelper(
|
|
50393
|
+
indexInfo,
|
|
50394
|
+
context,
|
|
50395
|
+
/*typeNode*/
|
|
50396
|
+
void 0
|
|
50397
|
+
)
|
|
50398
|
+
),
|
|
50399
|
+
signatureToSignatureDeclaration: (signature, kind, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50400
|
+
enclosingDeclaration,
|
|
50401
|
+
flags,
|
|
50402
|
+
internalFlags,
|
|
50403
|
+
tracker,
|
|
50404
|
+
/*verbosityLevel*/
|
|
50405
|
+
void 0,
|
|
50406
|
+
(context) => signatureToSignatureDeclarationHelper(signature, kind, context)
|
|
50407
|
+
),
|
|
50408
|
+
symbolToEntityName: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50409
|
+
enclosingDeclaration,
|
|
50410
|
+
flags,
|
|
50411
|
+
internalFlags,
|
|
50412
|
+
tracker,
|
|
50413
|
+
/*verbosityLevel*/
|
|
50414
|
+
void 0,
|
|
50415
|
+
(context) => symbolToName(
|
|
50416
|
+
symbol,
|
|
50417
|
+
context,
|
|
50418
|
+
meaning,
|
|
50419
|
+
/*expectsIdentifier*/
|
|
50420
|
+
false
|
|
50421
|
+
)
|
|
50422
|
+
),
|
|
50423
|
+
symbolToExpression: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50424
|
+
enclosingDeclaration,
|
|
50425
|
+
flags,
|
|
50426
|
+
internalFlags,
|
|
50427
|
+
tracker,
|
|
50428
|
+
/*verbosityLevel*/
|
|
50429
|
+
void 0,
|
|
50430
|
+
(context) => symbolToExpression(symbol, context, meaning)
|
|
50431
|
+
),
|
|
50432
|
+
symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50433
|
+
enclosingDeclaration,
|
|
50434
|
+
flags,
|
|
50435
|
+
internalFlags,
|
|
50436
|
+
tracker,
|
|
50437
|
+
/*verbosityLevel*/
|
|
50438
|
+
void 0,
|
|
50439
|
+
(context) => typeParametersToTypeParameterDeclarations(symbol, context)
|
|
50440
|
+
),
|
|
50441
|
+
symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50442
|
+
enclosingDeclaration,
|
|
50443
|
+
flags,
|
|
50444
|
+
internalFlags,
|
|
50445
|
+
tracker,
|
|
50446
|
+
/*verbosityLevel*/
|
|
50447
|
+
void 0,
|
|
50448
|
+
(context) => symbolToParameterDeclaration(symbol, context)
|
|
50449
|
+
),
|
|
50450
|
+
typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel) => withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, (context) => typeParameterToDeclaration(parameter, context)),
|
|
50451
|
+
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50452
|
+
enclosingDeclaration,
|
|
50453
|
+
flags,
|
|
50454
|
+
internalFlags,
|
|
50455
|
+
tracker,
|
|
50456
|
+
/*verbosityLevel*/
|
|
50457
|
+
void 0,
|
|
50458
|
+
(context) => symbolTableToDeclarationStatements(symbolTable, context)
|
|
50459
|
+
),
|
|
50460
|
+
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, internalFlags, tracker) => withContext(
|
|
50461
|
+
enclosingDeclaration,
|
|
50462
|
+
flags,
|
|
50463
|
+
internalFlags,
|
|
50464
|
+
tracker,
|
|
50465
|
+
/*verbosityLevel*/
|
|
50466
|
+
void 0,
|
|
50467
|
+
(context) => symbolToNode(symbol, context, meaning)
|
|
50468
|
+
)
|
|
50327
50469
|
};
|
|
50328
50470
|
function getTypeFromTypeNode2(context, node, noMappedTypes) {
|
|
50329
50471
|
const type = getTypeFromTypeNodeWithoutContext(node);
|
|
@@ -50365,7 +50507,7 @@ function createTypeChecker(host) {
|
|
|
50365
50507
|
}
|
|
50366
50508
|
return symbolToExpression(symbol, context, meaning);
|
|
50367
50509
|
}
|
|
50368
|
-
function withContext(enclosingDeclaration, flags, internalFlags, tracker, cb) {
|
|
50510
|
+
function withContext(enclosingDeclaration, flags, internalFlags, tracker, verbosityLevel, cb, out) {
|
|
50369
50511
|
const moduleResolverHost = (tracker == null ? void 0 : tracker.trackSymbol) ? tracker.moduleResolverHost : (internalFlags || 0 /* None */) & 4 /* DoNotIncludeSymbolChain */ ? createBasicNodeBuilderModuleSpecifierResolutionHost(host) : void 0;
|
|
50370
50512
|
const context = {
|
|
50371
50513
|
enclosingDeclaration,
|
|
@@ -50373,6 +50515,7 @@ function createTypeChecker(host) {
|
|
|
50373
50515
|
flags: flags || 0 /* None */,
|
|
50374
50516
|
internalFlags: internalFlags || 0 /* None */,
|
|
50375
50517
|
tracker: void 0,
|
|
50518
|
+
unfoldDepth: verbosityLevel ?? -1,
|
|
50376
50519
|
encounteredError: false,
|
|
50377
50520
|
suppressReportInferenceFallback: false,
|
|
50378
50521
|
reportedDiagnostic: false,
|
|
@@ -50394,13 +50537,18 @@ function createTypeChecker(host) {
|
|
|
50394
50537
|
typeParameterNamesByText: void 0,
|
|
50395
50538
|
typeParameterNamesByTextNextNameCount: void 0,
|
|
50396
50539
|
enclosingSymbolTypes: /* @__PURE__ */ new Map(),
|
|
50397
|
-
mapper: void 0
|
|
50540
|
+
mapper: void 0,
|
|
50541
|
+
depth: 0,
|
|
50542
|
+
couldUnfoldMore: false
|
|
50398
50543
|
};
|
|
50399
50544
|
context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
|
|
50400
50545
|
const resultingNode = cb(context);
|
|
50401
50546
|
if (context.truncating && context.flags & 1 /* NoTruncation */) {
|
|
50402
50547
|
context.tracker.reportTruncationError();
|
|
50403
50548
|
}
|
|
50549
|
+
if (out) {
|
|
50550
|
+
out.couldUnfoldMore = context.couldUnfoldMore;
|
|
50551
|
+
}
|
|
50404
50552
|
return context.encounteredError ? void 0 : resultingNode;
|
|
50405
50553
|
}
|
|
50406
50554
|
function addSymbolTypeToContext(context, symbol, type) {
|
|
@@ -50419,16 +50567,36 @@ function createTypeChecker(host) {
|
|
|
50419
50567
|
function saveRestoreFlags(context) {
|
|
50420
50568
|
const flags = context.flags;
|
|
50421
50569
|
const internalFlags = context.internalFlags;
|
|
50570
|
+
const depth = context.depth;
|
|
50422
50571
|
return restore;
|
|
50423
50572
|
function restore() {
|
|
50424
50573
|
context.flags = flags;
|
|
50425
50574
|
context.internalFlags = internalFlags;
|
|
50575
|
+
context.depth = depth;
|
|
50426
50576
|
}
|
|
50427
50577
|
}
|
|
50428
50578
|
function checkTruncationLength(context) {
|
|
50429
50579
|
if (context.truncating) return context.truncating;
|
|
50430
50580
|
return context.truncating = context.approximateLength > (context.flags & 1 /* NoTruncation */ ? noTruncationMaximumTruncationLength : defaultMaximumTruncationLength);
|
|
50431
50581
|
}
|
|
50582
|
+
function couldUnfoldType(type, context) {
|
|
50583
|
+
var _a;
|
|
50584
|
+
if ((_a = context.visitedTypes) == null ? void 0 : _a.has(type.id)) {
|
|
50585
|
+
return false;
|
|
50586
|
+
}
|
|
50587
|
+
return context.depth < context.unfoldDepth || context.depth === context.unfoldDepth && !context.couldUnfoldMore;
|
|
50588
|
+
}
|
|
50589
|
+
function canUnfoldType(type, context) {
|
|
50590
|
+
var _a;
|
|
50591
|
+
if ((_a = context.visitedTypes) == null ? void 0 : _a.has(type.id)) {
|
|
50592
|
+
return false;
|
|
50593
|
+
}
|
|
50594
|
+
const result = context.depth < context.unfoldDepth;
|
|
50595
|
+
if (!result) {
|
|
50596
|
+
context.couldUnfoldMore = true;
|
|
50597
|
+
}
|
|
50598
|
+
return result;
|
|
50599
|
+
}
|
|
50432
50600
|
function typeToTypeNodeHelper(type, context) {
|
|
50433
50601
|
const restoreFlags = saveRestoreFlags(context);
|
|
50434
50602
|
const typeNode = typeToTypeNodeWorker(type, context);
|
|
@@ -50576,16 +50744,27 @@ function createTypeChecker(host) {
|
|
|
50576
50744
|
return factory.createThisTypeNode();
|
|
50577
50745
|
}
|
|
50578
50746
|
if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
|
|
50579
|
-
|
|
50580
|
-
|
|
50581
|
-
|
|
50582
|
-
|
|
50747
|
+
if (!canUnfoldType(type, context)) {
|
|
50748
|
+
const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
|
|
50749
|
+
if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) return factory.createTypeReferenceNode(factory.createIdentifier(""), typeArgumentNodes);
|
|
50750
|
+
if (length(typeArgumentNodes) === 1 && type.aliasSymbol === globalArrayType.symbol) {
|
|
50751
|
+
return factory.createArrayTypeNode(typeArgumentNodes[0]);
|
|
50752
|
+
}
|
|
50753
|
+
return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes);
|
|
50583
50754
|
}
|
|
50584
|
-
|
|
50755
|
+
context.depth += 1;
|
|
50585
50756
|
}
|
|
50586
50757
|
const objectFlags = getObjectFlags(type);
|
|
50587
50758
|
if (objectFlags & 4 /* Reference */) {
|
|
50588
50759
|
Debug.assert(!!(type.flags & 524288 /* Object */));
|
|
50760
|
+
if (canUnfoldType(type, context)) {
|
|
50761
|
+
context.depth += 1;
|
|
50762
|
+
return createAnonymousTypeNode(
|
|
50763
|
+
type,
|
|
50764
|
+
/*forceClassExpansion*/
|
|
50765
|
+
true
|
|
50766
|
+
);
|
|
50767
|
+
}
|
|
50589
50768
|
return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
|
|
50590
50769
|
}
|
|
50591
50770
|
if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) {
|
|
@@ -50615,6 +50794,14 @@ function createTypeChecker(host) {
|
|
|
50615
50794
|
void 0
|
|
50616
50795
|
);
|
|
50617
50796
|
}
|
|
50797
|
+
if (objectFlags & 3 /* ClassOrInterface */ && canUnfoldType(type, context)) {
|
|
50798
|
+
context.depth += 1;
|
|
50799
|
+
return createAnonymousTypeNode(
|
|
50800
|
+
type,
|
|
50801
|
+
/*forceClassExpansion*/
|
|
50802
|
+
true
|
|
50803
|
+
);
|
|
50804
|
+
}
|
|
50618
50805
|
if (type.symbol) {
|
|
50619
50806
|
return symbolToTypeNode(type.symbol, context, 788968 /* Type */);
|
|
50620
50807
|
}
|
|
@@ -50818,7 +51005,7 @@ function createTypeChecker(host) {
|
|
|
50818
51005
|
}
|
|
50819
51006
|
return result;
|
|
50820
51007
|
}
|
|
50821
|
-
function createAnonymousTypeNode(type2) {
|
|
51008
|
+
function createAnonymousTypeNode(type2, forceClassExpansion = false) {
|
|
50822
51009
|
var _a2, _b2;
|
|
50823
51010
|
const typeId = type2.id;
|
|
50824
51011
|
const symbol = type2.symbol;
|
|
@@ -50841,7 +51028,7 @@ function createTypeChecker(host) {
|
|
|
50841
51028
|
const isInstanceType = isClassInstanceSide(type2) ? 788968 /* Type */ : 111551 /* Value */;
|
|
50842
51029
|
if (isJSConstructor(symbol.valueDeclaration)) {
|
|
50843
51030
|
return symbolToTypeNode(symbol, context, isInstanceType);
|
|
50844
|
-
} else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
|
|
51031
|
+
} else if (symbol.flags & 32 /* Class */ && !forceClassExpansion && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration && isClassLike(symbol.valueDeclaration) && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ && (!isClassDeclaration(symbol.valueDeclaration) || isSymbolAccessible(
|
|
50845
51032
|
symbol,
|
|
50846
51033
|
context.enclosingDeclaration,
|
|
50847
51034
|
isInstanceType,
|
|
@@ -50885,7 +51072,7 @@ function createTypeChecker(host) {
|
|
|
50885
51072
|
if (id && !context.symbolDepth) {
|
|
50886
51073
|
context.symbolDepth = /* @__PURE__ */ new Map();
|
|
50887
51074
|
}
|
|
50888
|
-
const links = context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
|
|
51075
|
+
const links = context.unfoldDepth >= 0 ? void 0 : context.enclosingDeclaration && getNodeLinks(context.enclosingDeclaration);
|
|
50889
51076
|
const key = `${getTypeId(type2)}|${context.flags}|${context.internalFlags}`;
|
|
50890
51077
|
if (links) {
|
|
50891
51078
|
links.serializedTypes || (links.serializedTypes = /* @__PURE__ */ new Map());
|
|
@@ -51317,7 +51504,7 @@ function createTypeChecker(host) {
|
|
|
51317
51504
|
const signatures = getSignaturesOfType(filterType(propertyType, (t) => !(t.flags & 32768 /* Undefined */)), 0 /* Call */);
|
|
51318
51505
|
for (const signature of signatures) {
|
|
51319
51506
|
const methodDeclaration = signatureToSignatureDeclarationHelper(signature, 173 /* MethodSignature */, context, { name: propertyName, questionToken: optionalToken });
|
|
51320
|
-
typeElements.push(preserveCommentsOn(methodDeclaration));
|
|
51507
|
+
typeElements.push(preserveCommentsOn(methodDeclaration, signature.declaration || propertySymbol.valueDeclaration));
|
|
51321
51508
|
}
|
|
51322
51509
|
if (signatures.length || !optionalToken) {
|
|
51323
51510
|
return;
|
|
@@ -51352,8 +51539,8 @@ function createTypeChecker(host) {
|
|
|
51352
51539
|
optionalToken,
|
|
51353
51540
|
propertyTypeNode
|
|
51354
51541
|
);
|
|
51355
|
-
typeElements.push(preserveCommentsOn(propertySignature));
|
|
51356
|
-
function preserveCommentsOn(node) {
|
|
51542
|
+
typeElements.push(preserveCommentsOn(propertySignature, propertySymbol.valueDeclaration));
|
|
51543
|
+
function preserveCommentsOn(node, range) {
|
|
51357
51544
|
var _a2;
|
|
51358
51545
|
const jsdocPropertyTag = (_a2 = propertySymbol.declarations) == null ? void 0 : _a2.find((d) => d.kind === 348 /* JSDocPropertyTag */);
|
|
51359
51546
|
if (jsdocPropertyTag) {
|
|
@@ -51361,8 +51548,8 @@ function createTypeChecker(host) {
|
|
|
51361
51548
|
if (commentText) {
|
|
51362
51549
|
setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
|
|
51363
51550
|
}
|
|
51364
|
-
} else if (
|
|
51365
|
-
setCommentRange2(context, node,
|
|
51551
|
+
} else if (range) {
|
|
51552
|
+
setCommentRange2(context, node, range);
|
|
51366
51553
|
}
|
|
51367
51554
|
return node;
|
|
51368
51555
|
}
|
|
@@ -51800,7 +51987,7 @@ function createTypeChecker(host) {
|
|
|
51800
51987
|
return factory.createTypeParameterDeclaration(modifiers, name, constraintNode, defaultParameterNode);
|
|
51801
51988
|
}
|
|
51802
51989
|
function typeToTypeNodeHelperWithPossibleReusableTypeNode(type, typeNode, context) {
|
|
51803
|
-
return typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
|
|
51990
|
+
return !couldUnfoldType(type, context) && typeNode && getTypeFromTypeNode2(context, typeNode) === type && syntacticNodeBuilder.tryReuseExistingTypeNode(context, typeNode) || typeToTypeNodeHelper(type, context);
|
|
51804
51991
|
}
|
|
51805
51992
|
function typeParameterToDeclaration(type, context, constraint = getConstraintOfTypeParameter(type)) {
|
|
51806
51993
|
const constraintNode = constraint && typeToTypeNodeHelperWithPossibleReusableTypeNode(constraint, getConstraintDeclaration(type), context);
|
|
@@ -52434,7 +52621,7 @@ function createTypeChecker(host) {
|
|
|
52434
52621
|
let result;
|
|
52435
52622
|
const addUndefinedForParameter = declaration && (isParameter(declaration) || isJSDocParameterTag(declaration)) && requiresAddingImplicitUndefined(declaration, context.enclosingDeclaration);
|
|
52436
52623
|
const decl = declaration ?? symbol.valueDeclaration ?? getDeclarationWithTypeAnnotation(symbol) ?? ((_a = symbol.declarations) == null ? void 0 : _a[0]);
|
|
52437
|
-
if (decl) {
|
|
52624
|
+
if (!couldUnfoldType(type, context) && decl) {
|
|
52438
52625
|
if (isAccessor(decl)) {
|
|
52439
52626
|
result = syntacticNodeBuilder.serializeTypeOfAccessor(decl, symbol, context);
|
|
52440
52627
|
} else if (hasInferredType(decl) && !nodeIsSynthesized(decl) && !(getObjectFlags(type) & 196608 /* RequiresWidening */)) {
|
|
@@ -55229,7 +55416,6 @@ function createTypeChecker(host) {
|
|
|
55229
55416
|
const flags = 4 /* Property */ | (e.initializer ? 16777216 /* Optional */ : 0);
|
|
55230
55417
|
const symbol = createSymbol(flags, text);
|
|
55231
55418
|
symbol.links.type = getTypeFromBindingElement(e, includePatternInType, reportErrors2);
|
|
55232
|
-
symbol.links.bindingElement = e;
|
|
55233
55419
|
members.set(symbol.escapedName, symbol);
|
|
55234
55420
|
});
|
|
55235
55421
|
const result = createAnonymousType(
|
|
@@ -55474,7 +55660,7 @@ function createTypeChecker(host) {
|
|
|
55474
55660
|
const getter = getDeclarationOfKind(symbol, 177 /* GetAccessor */);
|
|
55475
55661
|
const setter = getDeclarationOfKind(symbol, 178 /* SetAccessor */);
|
|
55476
55662
|
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 &&
|
|
55663
|
+
let type = getter && isInJSFile(getter) && getTypeForDeclarationFromJSDocComment(getter) || getAnnotatedAccessorType(getter) || getAnnotatedAccessorType(setter) || getAnnotatedAccessorType(accessor) || getter && getter.body && getReturnTypeFromBody(getter) || accessor && getWidenedTypeForVariableLikeDeclaration(
|
|
55478
55664
|
accessor,
|
|
55479
55665
|
/*reportErrors*/
|
|
55480
55666
|
true
|
|
@@ -57156,12 +57342,20 @@ function createTypeChecker(host) {
|
|
|
57156
57342
|
const indexInfos = indexInfo ? [createIndexInfo(stringType, inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType) || unknownType, readonlyMask && indexInfo.isReadonly)] : emptyArray;
|
|
57157
57343
|
const members = createSymbolTable();
|
|
57158
57344
|
const limitedConstraint = getLimitedConstraint(type);
|
|
57345
|
+
const nameType = getNameTypeFromMappedType(type.mappedType);
|
|
57159
57346
|
for (const prop of getPropertiesOfType(type.source)) {
|
|
57160
|
-
if (limitedConstraint) {
|
|
57347
|
+
if (limitedConstraint || nameType) {
|
|
57161
57348
|
const propertyNameType = getLiteralTypeFromProperty(prop, 8576 /* StringOrNumberLiteralOrUnique */);
|
|
57162
|
-
if (!isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
57349
|
+
if (limitedConstraint && !isTypeAssignableTo(propertyNameType, limitedConstraint)) {
|
|
57163
57350
|
continue;
|
|
57164
57351
|
}
|
|
57352
|
+
if (nameType) {
|
|
57353
|
+
const nameMapper = appendTypeMapping(type.mappedType.mapper, getTypeParameterFromMappedType(type.mappedType), propertyNameType);
|
|
57354
|
+
const instantiatedNameType = instantiateType(nameType, nameMapper);
|
|
57355
|
+
if (instantiatedNameType.flags & 131072 /* Never */) {
|
|
57356
|
+
continue;
|
|
57357
|
+
}
|
|
57358
|
+
}
|
|
57165
57359
|
}
|
|
57166
57360
|
const checkFlags = 8192 /* ReverseMapped */ | (readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0);
|
|
57167
57361
|
const inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.escapedName, checkFlags);
|
|
@@ -59158,7 +59352,7 @@ function createTypeChecker(host) {
|
|
|
59158
59352
|
return !!(type.flags & 33554432 /* Substitution */ && type.constraint.flags & 2 /* Unknown */);
|
|
59159
59353
|
}
|
|
59160
59354
|
function isNarrowingSubstitutionType(type) {
|
|
59161
|
-
return !!(type.flags & 33554432 /* Substitution */ && type.objectFlags & 16777216 /*
|
|
59355
|
+
return !!(type.flags & 33554432 /* Substitution */ && type.objectFlags & 16777216 /* IsNarrowingType */);
|
|
59162
59356
|
}
|
|
59163
59357
|
function getSubstitutionType(baseType, constraint, isNarrowed) {
|
|
59164
59358
|
return constraint.flags & 3 /* AnyOrUnknown */ || constraint === baseType || baseType.flags & 1 /* Any */ ? baseType : getOrCreateSubstitutionType(baseType, constraint, isNarrowed);
|
|
@@ -59173,7 +59367,7 @@ function createTypeChecker(host) {
|
|
|
59173
59367
|
result.baseType = baseType;
|
|
59174
59368
|
result.constraint = constraint;
|
|
59175
59369
|
if (isNarrowed) {
|
|
59176
|
-
result.objectFlags |= 16777216 /*
|
|
59370
|
+
result.objectFlags |= 16777216 /* IsNarrowingType */;
|
|
59177
59371
|
}
|
|
59178
59372
|
substitutionTypes.set(id, result);
|
|
59179
59373
|
return result;
|
|
@@ -61626,7 +61820,7 @@ function createTypeChecker(host) {
|
|
|
61626
61820
|
const links = getNodeLinks(node);
|
|
61627
61821
|
if (!links.resolvedType) {
|
|
61628
61822
|
const aliasSymbol = getAliasSymbolForTypeNode(node);
|
|
61629
|
-
if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
|
|
61823
|
+
if (!node.symbol || getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
|
|
61630
61824
|
links.resolvedType = emptyTypeLiteralType;
|
|
61631
61825
|
} else {
|
|
61632
61826
|
let type = createObjectType(16 /* Anonymous */, node.symbol);
|
|
@@ -62409,32 +62603,27 @@ function createTypeChecker(host) {
|
|
|
62409
62603
|
distributionType = getReducedType(distributionType.constraint);
|
|
62410
62604
|
}
|
|
62411
62605
|
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
62606
|
if (narrowingBaseType) {
|
|
62428
|
-
result =
|
|
62607
|
+
result = mapTypeToIntersection(
|
|
62429
62608
|
distributionType,
|
|
62430
|
-
|
|
62431
|
-
|
|
62432
|
-
|
|
62433
|
-
|
|
62434
|
-
|
|
62609
|
+
(t) => getConditionalType(
|
|
62610
|
+
root,
|
|
62611
|
+
prependTypeMapping(checkType, getSubstitutionType(
|
|
62612
|
+
narrowingBaseType,
|
|
62613
|
+
t,
|
|
62614
|
+
/*isNarrowed*/
|
|
62615
|
+
true
|
|
62616
|
+
), newMapper),
|
|
62617
|
+
forConstraint,
|
|
62618
|
+
/*aliasSymbol*/
|
|
62619
|
+
void 0,
|
|
62620
|
+
/*aliasTypeArguments*/
|
|
62621
|
+
void 0,
|
|
62622
|
+
forNarrowing
|
|
62623
|
+
)
|
|
62435
62624
|
);
|
|
62436
62625
|
} else {
|
|
62437
|
-
result = mapTypeWithAlias(distributionType,
|
|
62626
|
+
result = mapTypeWithAlias(distributionType, (t) => getConditionalType(root, prependTypeMapping(checkType, t, newMapper), forConstraint), aliasSymbol, aliasTypeArguments);
|
|
62438
62627
|
}
|
|
62439
62628
|
} else {
|
|
62440
62629
|
result = getConditionalType(root, newMapper, forConstraint, aliasSymbol, aliasTypeArguments, forNarrowing);
|
|
@@ -62551,9 +62740,6 @@ function createTypeChecker(host) {
|
|
|
62551
62740
|
}
|
|
62552
62741
|
return type;
|
|
62553
62742
|
}
|
|
62554
|
-
function isGenericIndexedOrConditionalReturnType(type) {
|
|
62555
|
-
return !!(type.flags & (8388608 /* IndexedAccess */ | 16777216 /* Conditional */) && couldContainTypeVariables(type));
|
|
62556
|
-
}
|
|
62557
62743
|
function instantiateReverseMappedType(type, mapper) {
|
|
62558
62744
|
const innerMappedType = instantiateType(type.mappedType, mapper);
|
|
62559
62745
|
if (!(getObjectFlags(innerMappedType) & 32 /* Mapped */)) {
|
|
@@ -67797,10 +67983,13 @@ function createTypeChecker(host) {
|
|
|
67797
67983
|
if (isGenericMappedType(source) && isGenericMappedType(target)) {
|
|
67798
67984
|
inferFromGenericMappedTypes(source, target);
|
|
67799
67985
|
}
|
|
67800
|
-
if (getObjectFlags(target) & 32 /* Mapped */
|
|
67801
|
-
const
|
|
67802
|
-
if (
|
|
67803
|
-
|
|
67986
|
+
if (getObjectFlags(target) & 32 /* Mapped */) {
|
|
67987
|
+
const mappedType = target;
|
|
67988
|
+
if (getMappedTypeNameTypeKind(mappedType) !== 2 /* Remapping */) {
|
|
67989
|
+
const constraintType = getConstraintTypeFromMappedType(mappedType);
|
|
67990
|
+
if (inferToMappedType(source, mappedType, constraintType)) {
|
|
67991
|
+
return;
|
|
67992
|
+
}
|
|
67804
67993
|
}
|
|
67805
67994
|
}
|
|
67806
67995
|
if (!typesDefinitelyUnrelated(source, target)) {
|
|
@@ -68724,7 +68913,7 @@ function createTypeChecker(host) {
|
|
|
68724
68913
|
function countTypes(type) {
|
|
68725
68914
|
return type.flags & 1048576 /* Union */ ? type.types.length : 1;
|
|
68726
68915
|
}
|
|
68727
|
-
function mapType(type, mapper, noReductions
|
|
68916
|
+
function mapType(type, mapper, noReductions) {
|
|
68728
68917
|
if (type.flags & 131072 /* Never */) {
|
|
68729
68918
|
return type;
|
|
68730
68919
|
}
|
|
@@ -68746,7 +68935,19 @@ function createTypeChecker(host) {
|
|
|
68746
68935
|
}
|
|
68747
68936
|
}
|
|
68748
68937
|
}
|
|
68749
|
-
return changed ? mappedTypes &&
|
|
68938
|
+
return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 /* None */ : 1 /* Literal */) : type;
|
|
68939
|
+
}
|
|
68940
|
+
function mapTypeToIntersection(type, mapper) {
|
|
68941
|
+
if (type.flags & 131072 /* Never */) {
|
|
68942
|
+
return type;
|
|
68943
|
+
}
|
|
68944
|
+
if (!(type.flags & 1048576 /* Union */)) {
|
|
68945
|
+
return mapper(type);
|
|
68946
|
+
}
|
|
68947
|
+
const origin = type.origin;
|
|
68948
|
+
const types = origin && origin.flags & 1048576 /* Union */ ? origin.types : type.types;
|
|
68949
|
+
const mappedTypes = types.map((t) => t.flags & 1048576 /* Union */ ? mapTypeToIntersection(t, mapper) : mapper(t));
|
|
68950
|
+
return getIntersectionType(mappedTypes);
|
|
68750
68951
|
}
|
|
68751
68952
|
function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
|
|
68752
68953
|
return type.flags & 1048576 /* Union */ && aliasSymbol ? getUnionType(map(type.types, mapper), 1 /* Literal */, aliasSymbol, aliasTypeArguments) : mapType(type, mapper);
|
|
@@ -70099,12 +70300,14 @@ function createTypeChecker(host) {
|
|
|
70099
70300
|
case 80 /* Identifier */:
|
|
70100
70301
|
if (!isMatchingReference(reference, expr) && inlineLevel < 5) {
|
|
70101
70302
|
const symbol = getResolvedSymbol(expr);
|
|
70102
|
-
|
|
70103
|
-
|
|
70104
|
-
|
|
70105
|
-
|
|
70106
|
-
|
|
70107
|
-
|
|
70303
|
+
if (isConstantVariable(symbol)) {
|
|
70304
|
+
const declaration = symbol.valueDeclaration;
|
|
70305
|
+
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isConstantReference(reference)) {
|
|
70306
|
+
inlineLevel++;
|
|
70307
|
+
const result = narrowType(type, declaration.initializer, assumeTrue);
|
|
70308
|
+
inlineLevel--;
|
|
70309
|
+
return result;
|
|
70310
|
+
}
|
|
70108
70311
|
}
|
|
70109
70312
|
}
|
|
70110
70313
|
// falls through
|
|
@@ -70139,14 +70342,6 @@ function createTypeChecker(host) {
|
|
|
70139
70342
|
return type;
|
|
70140
70343
|
}
|
|
70141
70344
|
}
|
|
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
70345
|
function getTypeOfSymbolAtLocation(symbol, location) {
|
|
70151
70346
|
symbol = getExportSymbolOfValueSymbolIfExported(symbol);
|
|
70152
70347
|
if (location.kind === 80 /* Identifier */ || location.kind === 81 /* PrivateIdentifier */) {
|
|
@@ -70493,7 +70688,7 @@ function createTypeChecker(host) {
|
|
|
70493
70688
|
jsxFactorySym = resolveName(
|
|
70494
70689
|
jsxFactoryLocation,
|
|
70495
70690
|
jsxFactoryNamespace,
|
|
70496
|
-
compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
70691
|
+
compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
70497
70692
|
jsxFactoryRefErr,
|
|
70498
70693
|
/*isUse*/
|
|
70499
70694
|
true
|
|
@@ -70512,7 +70707,7 @@ function createTypeChecker(host) {
|
|
|
70512
70707
|
resolveName(
|
|
70513
70708
|
jsxFactoryLocation,
|
|
70514
70709
|
localJsxNamespace,
|
|
70515
|
-
compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
70710
|
+
compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
70516
70711
|
jsxFactoryRefErr,
|
|
70517
70712
|
/*isUse*/
|
|
70518
70713
|
true
|
|
@@ -74855,8 +75050,8 @@ function createTypeChecker(host) {
|
|
|
74855
75050
|
}
|
|
74856
75051
|
}
|
|
74857
75052
|
function getEffectiveCheckNode(argument) {
|
|
74858
|
-
|
|
74859
|
-
return
|
|
75053
|
+
const flags = isInJSFile(argument) ? 1 /* Parentheses */ | 32 /* Satisfies */ | -2147483648 /* ExcludeJSDocTypeAssertion */ : 1 /* Parentheses */ | 32 /* Satisfies */;
|
|
75054
|
+
return skipOuterExpressions(argument, flags);
|
|
74860
75055
|
}
|
|
74861
75056
|
function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain, inferenceContext) {
|
|
74862
75057
|
const errorOutputContainer = { errors: void 0, skipLogging: true };
|
|
@@ -75281,11 +75476,16 @@ function createTypeChecker(host) {
|
|
|
75281
75476
|
if (!result) {
|
|
75282
75477
|
result = chooseOverload(candidates, assignableRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
|
|
75283
75478
|
}
|
|
75479
|
+
const links = getNodeLinks(node);
|
|
75480
|
+
if (links.resolvedSignature !== resolvingSignature && !candidatesOutArray) {
|
|
75481
|
+
Debug.assert(links.resolvedSignature);
|
|
75482
|
+
return links.resolvedSignature;
|
|
75483
|
+
}
|
|
75284
75484
|
if (result) {
|
|
75285
75485
|
return result;
|
|
75286
75486
|
}
|
|
75287
75487
|
result = getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray, checkMode);
|
|
75288
|
-
|
|
75488
|
+
links.resolvedSignature = result;
|
|
75289
75489
|
if (reportErrors2) {
|
|
75290
75490
|
if (!headMessage && isInstanceof) {
|
|
75291
75491
|
headMessage = Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_assignable_to_the_first_argument_of_the_right_hand_side_s_Symbol_hasInstance_method;
|
|
@@ -76050,7 +76250,7 @@ function createTypeChecker(host) {
|
|
|
76050
76250
|
const jsxFactorySymbol = getJsxNamespaceContainerForImplicitImport(node) ?? resolveName(
|
|
76051
76251
|
node,
|
|
76052
76252
|
jsxFragmentFactoryName,
|
|
76053
|
-
compilerOptions.jsx === 1 /* Preserve */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
76253
|
+
compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */ ? 111551 /* Value */ & ~384 /* Enum */ : 111551 /* Value */,
|
|
76054
76254
|
/*nameNotFoundMessage*/
|
|
76055
76255
|
jsxFactoryRefErr,
|
|
76056
76256
|
/*isUse*/
|
|
@@ -76169,12 +76369,9 @@ function createTypeChecker(host) {
|
|
|
76169
76369
|
resolutionStart = resolutionTargets.length;
|
|
76170
76370
|
}
|
|
76171
76371
|
links.resolvedSignature = resolvingSignature;
|
|
76172
|
-
|
|
76372
|
+
const result = resolveSignature(node, candidatesOutArray, checkMode || 0 /* Normal */);
|
|
76173
76373
|
resolutionStart = saveResolutionStart;
|
|
76174
76374
|
if (result !== resolvingSignature) {
|
|
76175
|
-
if (links.resolvedSignature !== resolvingSignature) {
|
|
76176
|
-
result = links.resolvedSignature;
|
|
76177
|
-
}
|
|
76178
76375
|
links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
|
|
76179
76376
|
}
|
|
76180
76377
|
return result;
|
|
@@ -77702,7 +77899,7 @@ function createTypeChecker(host) {
|
|
|
77702
77899
|
});
|
|
77703
77900
|
}
|
|
77704
77901
|
function checkIfExpressionRefinesParameter(func, expr, param, initType) {
|
|
77705
|
-
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
|
|
77902
|
+
const antecedent = canHaveFlowNode(expr) && expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || createFlowNode(
|
|
77706
77903
|
2 /* Start */,
|
|
77707
77904
|
/*node*/
|
|
77708
77905
|
void 0,
|
|
@@ -77850,19 +78047,7 @@ function createTypeChecker(host) {
|
|
|
77850
78047
|
const exprType = checkExpression(node.body);
|
|
77851
78048
|
const returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
|
|
77852
78049
|
if (returnOrPromisedType) {
|
|
77853
|
-
|
|
77854
|
-
if ((functionFlags & 3 /* AsyncGenerator */) === 2 /* Async */) {
|
|
77855
|
-
const awaitedType = checkAwaitedType(
|
|
77856
|
-
exprType,
|
|
77857
|
-
/*withAlias*/
|
|
77858
|
-
false,
|
|
77859
|
-
effectiveCheckNode,
|
|
77860
|
-
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
77861
|
-
);
|
|
77862
|
-
checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, effectiveCheckNode, effectiveCheckNode);
|
|
77863
|
-
} else {
|
|
77864
|
-
checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, effectiveCheckNode, effectiveCheckNode);
|
|
77865
|
-
}
|
|
78050
|
+
checkReturnExpression(node, returnOrPromisedType, node.body, node.body, exprType);
|
|
77866
78051
|
}
|
|
77867
78052
|
}
|
|
77868
78053
|
}
|
|
@@ -77945,7 +78130,7 @@ function createTypeChecker(host) {
|
|
|
77945
78130
|
return false;
|
|
77946
78131
|
}
|
|
77947
78132
|
function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
|
|
77948
|
-
const node = skipOuterExpressions(expr,
|
|
78133
|
+
const node = skipOuterExpressions(expr, 38 /* Assertions */ | 1 /* Parentheses */);
|
|
77949
78134
|
if (node.kind !== 80 /* Identifier */ && !isAccessExpression(node)) {
|
|
77950
78135
|
error(expr, invalidReferenceMessage);
|
|
77951
78136
|
return false;
|
|
@@ -78596,7 +78781,7 @@ function createTypeChecker(host) {
|
|
|
78596
78781
|
if (isBinaryExpression(right) && (right.operatorToken.kind === 57 /* BarBarToken */ || right.operatorToken.kind === 56 /* AmpersandAmpersandToken */)) {
|
|
78597
78782
|
grammarErrorOnNode(right, Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, tokenToString(right.operatorToken.kind), tokenToString(operatorToken.kind));
|
|
78598
78783
|
}
|
|
78599
|
-
const leftTarget = skipOuterExpressions(left,
|
|
78784
|
+
const leftTarget = skipOuterExpressions(left, 63 /* All */);
|
|
78600
78785
|
const nullishSemantics = getSyntacticNullishnessSemantics(leftTarget);
|
|
78601
78786
|
if (nullishSemantics !== 3 /* Sometimes */) {
|
|
78602
78787
|
if (node.parent.kind === 226 /* BinaryExpression */) {
|
|
@@ -78616,7 +78801,9 @@ function createTypeChecker(host) {
|
|
|
78616
78801
|
switch (node.kind) {
|
|
78617
78802
|
case 223 /* AwaitExpression */:
|
|
78618
78803
|
case 213 /* CallExpression */:
|
|
78804
|
+
case 215 /* TaggedTemplateExpression */:
|
|
78619
78805
|
case 212 /* ElementAccessExpression */:
|
|
78806
|
+
case 236 /* MetaProperty */:
|
|
78620
78807
|
case 214 /* NewExpression */:
|
|
78621
78808
|
case 211 /* PropertyAccessExpression */:
|
|
78622
78809
|
case 229 /* YieldExpression */:
|
|
@@ -78632,6 +78819,8 @@ function createTypeChecker(host) {
|
|
|
78632
78819
|
case 56 /* AmpersandAmpersandToken */:
|
|
78633
78820
|
case 77 /* AmpersandAmpersandEqualsToken */:
|
|
78634
78821
|
return 3 /* Sometimes */;
|
|
78822
|
+
case 28 /* CommaToken */:
|
|
78823
|
+
return getSyntacticNullishnessSemantics(node.right);
|
|
78635
78824
|
}
|
|
78636
78825
|
return 2 /* Never */;
|
|
78637
78826
|
case 227 /* ConditionalExpression */:
|
|
@@ -82618,7 +82807,7 @@ function createTypeChecker(host) {
|
|
|
82618
82807
|
return anyIterationTypes;
|
|
82619
82808
|
}
|
|
82620
82809
|
if (!(type.flags & 1048576 /* Union */)) {
|
|
82621
|
-
const errorOutputContainer = errorNode ? { errors: void 0 } : void 0;
|
|
82810
|
+
const errorOutputContainer = errorNode ? { errors: void 0, skipLogging: true } : void 0;
|
|
82622
82811
|
const iterationTypes2 = getIterationTypesOfIterableWorker(type, use, errorNode, errorOutputContainer);
|
|
82623
82812
|
if (iterationTypes2 === noIterationTypes) {
|
|
82624
82813
|
if (errorNode) {
|
|
@@ -82786,11 +82975,27 @@ function createTypeChecker(host) {
|
|
|
82786
82975
|
if (isTypeAny(methodType)) {
|
|
82787
82976
|
return noCache ? anyIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
|
|
82788
82977
|
}
|
|
82789
|
-
const
|
|
82790
|
-
|
|
82978
|
+
const allSignatures = methodType ? getSignaturesOfType(methodType, 0 /* Call */) : void 0;
|
|
82979
|
+
const validSignatures = filter(allSignatures, (sig) => getMinArgumentCount(sig) === 0);
|
|
82980
|
+
if (!some(validSignatures)) {
|
|
82981
|
+
if (errorNode && some(allSignatures)) {
|
|
82982
|
+
checkTypeAssignableTo(
|
|
82983
|
+
type,
|
|
82984
|
+
resolver.getGlobalIterableType(
|
|
82985
|
+
/*reportErrors*/
|
|
82986
|
+
true
|
|
82987
|
+
),
|
|
82988
|
+
errorNode,
|
|
82989
|
+
/*headMessage*/
|
|
82990
|
+
void 0,
|
|
82991
|
+
/*containingMessageChain*/
|
|
82992
|
+
void 0,
|
|
82993
|
+
errorOutputContainer
|
|
82994
|
+
);
|
|
82995
|
+
}
|
|
82791
82996
|
return noCache ? noIterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
|
|
82792
82997
|
}
|
|
82793
|
-
const iteratorType = getIntersectionType(map(
|
|
82998
|
+
const iteratorType = getIntersectionType(map(validSignatures, getReturnTypeOfSignature));
|
|
82794
82999
|
const iterationTypes = getIterationTypesOfIteratorWorker(iteratorType, resolver, errorNode, errorOutputContainer, noCache) ?? noIterationTypes;
|
|
82795
83000
|
return noCache ? iterationTypes : setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
|
|
82796
83001
|
}
|
|
@@ -83069,32 +83274,52 @@ function createTypeChecker(host) {
|
|
|
83069
83274
|
const signature = getSignatureFromDeclaration(container);
|
|
83070
83275
|
const returnType = getReturnTypeOfSignature(signature);
|
|
83071
83276
|
if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) {
|
|
83277
|
+
const exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
83072
83278
|
if (container.kind === 178 /* SetAccessor */) {
|
|
83073
83279
|
if (node.expression) {
|
|
83074
83280
|
error(node, Diagnostics.Setters_cannot_return_a_value);
|
|
83075
83281
|
}
|
|
83076
83282
|
} else if (container.kind === 176 /* Constructor */) {
|
|
83077
|
-
const
|
|
83078
|
-
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(
|
|
83283
|
+
const exprType2 = node.expression ? checkExpressionCached(node.expression) : undefinedType;
|
|
83284
|
+
if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType2, returnType, node, node.expression)) {
|
|
83079
83285
|
error(node, Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
|
|
83080
83286
|
}
|
|
83081
83287
|
} else if (getReturnTypeFromAnnotation(container)) {
|
|
83082
|
-
|
|
83288
|
+
const unwrappedReturnType = unwrapReturnType(returnType, getFunctionFlags(container)) ?? returnType;
|
|
83289
|
+
checkReturnExpression(container, unwrappedReturnType, node, node.expression, exprType);
|
|
83083
83290
|
}
|
|
83084
83291
|
} else if (container.kind !== 176 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeUndefinedVoidOrAny(container, returnType)) {
|
|
83085
83292
|
error(node, Diagnostics.Not_all_code_paths_return_a_value);
|
|
83086
83293
|
}
|
|
83087
83294
|
}
|
|
83088
|
-
function
|
|
83295
|
+
function checkReturnExpression(container, unwrappedReturnType, node, expr, exprType, inConditionalExpression = false) {
|
|
83296
|
+
const excludeJSDocTypeAssertions = isInJSFile(node);
|
|
83089
83297
|
const functionFlags = getFunctionFlags(container);
|
|
83090
|
-
const unwrappedReturnType = unwrapReturnType(returnType, functionFlags) ?? returnType;
|
|
83091
83298
|
if (expr) {
|
|
83092
|
-
const unwrappedExpr = skipParentheses(expr);
|
|
83299
|
+
const unwrappedExpr = skipParentheses(expr, excludeJSDocTypeAssertions);
|
|
83093
83300
|
if (isConditionalExpression(unwrappedExpr)) {
|
|
83094
|
-
|
|
83301
|
+
checkReturnExpression(
|
|
83302
|
+
container,
|
|
83303
|
+
unwrappedReturnType,
|
|
83304
|
+
node,
|
|
83305
|
+
unwrappedExpr.whenTrue,
|
|
83306
|
+
checkExpression(unwrappedExpr.whenTrue),
|
|
83307
|
+
/*inConditionalExpression*/
|
|
83308
|
+
true
|
|
83309
|
+
);
|
|
83310
|
+
checkReturnExpression(
|
|
83311
|
+
container,
|
|
83312
|
+
unwrappedReturnType,
|
|
83313
|
+
node,
|
|
83314
|
+
unwrappedExpr.whenFalse,
|
|
83315
|
+
checkExpression(unwrappedExpr.whenFalse),
|
|
83316
|
+
/*inConditionalExpression*/
|
|
83317
|
+
true
|
|
83318
|
+
);
|
|
83319
|
+
return;
|
|
83095
83320
|
}
|
|
83096
83321
|
}
|
|
83097
|
-
const
|
|
83322
|
+
const inReturnStatement = node.kind === 253 /* ReturnStatement */;
|
|
83098
83323
|
const unwrappedExprType = functionFlags & 2 /* Async */ ? checkAwaitedType(
|
|
83099
83324
|
exprType,
|
|
83100
83325
|
/*withAlias*/
|
|
@@ -83102,7 +83327,12 @@ function createTypeChecker(host) {
|
|
|
83102
83327
|
node,
|
|
83103
83328
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
83104
83329
|
) : exprType;
|
|
83105
|
-
const
|
|
83330
|
+
const effectiveExpr = expr && getEffectiveCheckNode(expr);
|
|
83331
|
+
const errorNode = inReturnStatement && !inConditionalExpression ? node : effectiveExpr;
|
|
83332
|
+
if (!(unwrappedReturnType.flags & (8388608 /* IndexedAccess */ | 16777216 /* Conditional */)) || !couldContainTypeVariables(unwrappedReturnType)) {
|
|
83333
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
83334
|
+
return;
|
|
83335
|
+
}
|
|
83106
83336
|
if (checkTypeAssignableTo(
|
|
83107
83337
|
unwrappedExprType,
|
|
83108
83338
|
unwrappedReturnType,
|
|
@@ -83111,8 +83341,14 @@ function createTypeChecker(host) {
|
|
|
83111
83341
|
)) {
|
|
83112
83342
|
return;
|
|
83113
83343
|
}
|
|
83114
|
-
|
|
83115
|
-
|
|
83344
|
+
let narrowPosition = node;
|
|
83345
|
+
let narrowFlowNode = inReturnStatement && node.flowNode;
|
|
83346
|
+
if (expr && isConditionalExpression(expr.parent)) {
|
|
83347
|
+
narrowFlowNode = expr.parent.whenTrue === expr ? expr.parent.flowNodeWhenTrue : expr.parent.flowNodeWhenFalse;
|
|
83348
|
+
narrowPosition = expr;
|
|
83349
|
+
}
|
|
83350
|
+
if (!narrowFlowNode) {
|
|
83351
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
83116
83352
|
return;
|
|
83117
83353
|
}
|
|
83118
83354
|
const allTypeParameters = appendTypeParameters(getOuterTypeParameters(
|
|
@@ -83122,20 +83358,12 @@ function createTypeChecker(host) {
|
|
|
83122
83358
|
), getEffectiveTypeParameterDeclarations(container));
|
|
83123
83359
|
const narrowableTypeParameters = allTypeParameters && getNarrowableTypeParameters(allTypeParameters);
|
|
83124
83360
|
if (!narrowableTypeParameters || !narrowableTypeParameters.length || !isNarrowableReturnType(unwrappedReturnType)) {
|
|
83125
|
-
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode,
|
|
83361
|
+
checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, errorNode, effectiveExpr);
|
|
83126
83362
|
return;
|
|
83127
83363
|
}
|
|
83128
|
-
|
|
83129
|
-
|
|
83130
|
-
|
|
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]) => {
|
|
83364
|
+
const narrowedTypeParameters = [];
|
|
83365
|
+
const narrowedTypes = [];
|
|
83366
|
+
for (const [typeParam, symbol, reference] of narrowableTypeParameters) {
|
|
83139
83367
|
const narrowReference = factory.cloneNode(reference);
|
|
83140
83368
|
narrowReference.id = void 0;
|
|
83141
83369
|
getNodeLinks(narrowReference).resolvedSymbol = symbol;
|
|
@@ -83150,12 +83378,12 @@ function createTypeChecker(host) {
|
|
|
83150
83378
|
true
|
|
83151
83379
|
);
|
|
83152
83380
|
if (initialType === typeParam) {
|
|
83153
|
-
|
|
83381
|
+
continue;
|
|
83154
83382
|
}
|
|
83155
83383
|
const flowType = getFlowTypeOfReference(narrowReference, initialType);
|
|
83156
83384
|
const exprType2 = getTypeFromFlowType(flowType);
|
|
83157
|
-
if (
|
|
83158
|
-
|
|
83385
|
+
if (exprType2.flags & 3 /* AnyOrUnknown */ || isErrorType(exprType2) || exprType2 === typeParam || exprType2 === mapType(typeParam, getBaseConstraintOrType)) {
|
|
83386
|
+
continue;
|
|
83159
83387
|
}
|
|
83160
83388
|
const narrowedType = getSubstitutionType(
|
|
83161
83389
|
typeParam,
|
|
@@ -83163,9 +83391,10 @@ function createTypeChecker(host) {
|
|
|
83163
83391
|
/*isNarrowed*/
|
|
83164
83392
|
true
|
|
83165
83393
|
);
|
|
83166
|
-
|
|
83167
|
-
|
|
83168
|
-
|
|
83394
|
+
narrowedTypeParameters.push(typeParam);
|
|
83395
|
+
narrowedTypes.push(narrowedType);
|
|
83396
|
+
}
|
|
83397
|
+
const narrowMapper = createTypeMapper(narrowedTypeParameters, narrowedTypes);
|
|
83169
83398
|
const narrowedReturnType = instantiateType(
|
|
83170
83399
|
unwrappedReturnType,
|
|
83171
83400
|
narrowMapper
|
|
@@ -83184,12 +83413,7 @@ function createTypeChecker(host) {
|
|
|
83184
83413
|
node,
|
|
83185
83414
|
Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member
|
|
83186
83415
|
) : narrowedExprType;
|
|
83187
|
-
checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode,
|
|
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);
|
|
83416
|
+
checkTypeAssignableToAndOptionallyElaborate(narrowedUnwrappedExprType, narrowedReturnType, errorNode, effectiveExpr);
|
|
83193
83417
|
}
|
|
83194
83418
|
function getNarrowableTypeParameters(candidates) {
|
|
83195
83419
|
const narrowableParams = [];
|
|
@@ -83197,12 +83421,13 @@ function createTypeChecker(host) {
|
|
|
83197
83421
|
const constraint = getConstraintOfTypeParameter(typeParam);
|
|
83198
83422
|
if (!constraint || !(constraint.flags & 1048576 /* Union */)) continue;
|
|
83199
83423
|
if (typeParam.symbol && typeParam.symbol.declarations && typeParam.symbol.declarations.length === 1) {
|
|
83200
|
-
const
|
|
83424
|
+
const declaration = typeParam.symbol.declarations[0];
|
|
83425
|
+
const container = isJSDocTemplateTag(declaration.parent) ? getJSDocHost(declaration.parent) : declaration.parent;
|
|
83201
83426
|
if (!isFunctionLike(container)) continue;
|
|
83202
83427
|
let reference;
|
|
83203
83428
|
let hasInvalidReference = false;
|
|
83204
83429
|
for (const paramDecl of container.parameters) {
|
|
83205
|
-
const typeNode = paramDecl
|
|
83430
|
+
const typeNode = getEffectiveTypeAnnotationNode(paramDecl);
|
|
83206
83431
|
if (!typeNode) continue;
|
|
83207
83432
|
if (isTypeParameterReferenced(typeParam, typeNode)) {
|
|
83208
83433
|
let candidateReference;
|
|
@@ -83212,10 +83437,10 @@ function createTypeChecker(host) {
|
|
|
83212
83437
|
break;
|
|
83213
83438
|
}
|
|
83214
83439
|
reference = candidateReference;
|
|
83215
|
-
|
|
83440
|
+
} else {
|
|
83441
|
+
hasInvalidReference = true;
|
|
83442
|
+
break;
|
|
83216
83443
|
}
|
|
83217
|
-
hasInvalidReference = true;
|
|
83218
|
-
break;
|
|
83219
83444
|
}
|
|
83220
83445
|
}
|
|
83221
83446
|
if (!hasInvalidReference && reference) {
|
|
@@ -83227,7 +83452,8 @@ function createTypeChecker(host) {
|
|
|
83227
83452
|
return narrowableParams;
|
|
83228
83453
|
function getValidParameterReference(paramDecl, constraint) {
|
|
83229
83454
|
if (!isIdentifier(paramDecl.name)) return;
|
|
83230
|
-
|
|
83455
|
+
const isOptional = !!paramDecl.questionToken || isJSDocOptionalParameter(paramDecl);
|
|
83456
|
+
if (isOptional && !containsUndefinedType(constraint)) return;
|
|
83231
83457
|
return paramDecl.name;
|
|
83232
83458
|
}
|
|
83233
83459
|
function isReferenceToTypeParameter(typeParam, node) {
|
|
@@ -83288,10 +83514,11 @@ function createTypeChecker(host) {
|
|
|
83288
83514
|
return false;
|
|
83289
83515
|
}
|
|
83290
83516
|
const trueType2 = getTrueTypeFromConditionalType(type);
|
|
83291
|
-
const falseType2 = getFalseTypeFromConditionalType(type);
|
|
83292
83517
|
const isValidTrueType = isConditionalType(trueType2) ? isNarrowableConditionalType(trueType2) : true;
|
|
83518
|
+
if (!isValidTrueType) return false;
|
|
83519
|
+
const falseType2 = getFalseTypeFromConditionalType(type);
|
|
83293
83520
|
const isValidFalseType = isConditionalType(falseType2) ? isNarrowableConditionalType(falseType2) : falseType2 === neverType;
|
|
83294
|
-
return
|
|
83521
|
+
return isValidFalseType;
|
|
83295
83522
|
}
|
|
83296
83523
|
function isConditionalType(type) {
|
|
83297
83524
|
return !!(type.flags & 16777216 /* Conditional */);
|
|
@@ -84224,6 +84451,9 @@ function createTypeChecker(host) {
|
|
|
84224
84451
|
}
|
|
84225
84452
|
function checkInterfaceDeclaration(node) {
|
|
84226
84453
|
if (!checkGrammarModifiers(node)) checkGrammarInterfaceDeclaration(node);
|
|
84454
|
+
if (!allowBlockDeclarations(node.parent)) {
|
|
84455
|
+
grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, "interface");
|
|
84456
|
+
}
|
|
84227
84457
|
checkTypeParameters(node.typeParameters);
|
|
84228
84458
|
addLazyDiagnostic(() => {
|
|
84229
84459
|
checkTypeNameIsReserved(node.name, Diagnostics.Interface_name_cannot_be_0);
|
|
@@ -84258,6 +84488,9 @@ function createTypeChecker(host) {
|
|
|
84258
84488
|
function checkTypeAliasDeclaration(node) {
|
|
84259
84489
|
checkGrammarModifiers(node);
|
|
84260
84490
|
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
|
|
84491
|
+
if (!allowBlockDeclarations(node.parent)) {
|
|
84492
|
+
grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, "type");
|
|
84493
|
+
}
|
|
84261
84494
|
checkExportsOnMergedDeclarations(node);
|
|
84262
84495
|
checkTypeParameters(node.typeParameters);
|
|
84263
84496
|
if (node.type.kind === 141 /* IntrinsicKeyword */) {
|
|
@@ -86644,7 +86877,7 @@ function createTypeChecker(host) {
|
|
|
86644
86877
|
const typeNode = getNonlocalEffectiveTypeAnnotationNode(parameter);
|
|
86645
86878
|
if (!typeNode) return false;
|
|
86646
86879
|
const type = getTypeFromTypeNode(typeNode);
|
|
86647
|
-
return containsUndefinedType(type);
|
|
86880
|
+
return isErrorType(type) || containsUndefinedType(type);
|
|
86648
86881
|
}
|
|
86649
86882
|
function requiresAddingImplicitUndefined(parameter, enclosingDeclaration) {
|
|
86650
86883
|
return (isRequiredInitializedParameter(parameter, enclosingDeclaration) || isOptionalUninitializedParameterProperty(parameter)) && !declaredParameterTypeContainsUndefined(parameter);
|
|
@@ -88670,7 +88903,7 @@ function createTypeChecker(host) {
|
|
|
88670
88903
|
}
|
|
88671
88904
|
return false;
|
|
88672
88905
|
}
|
|
88673
|
-
function
|
|
88906
|
+
function allowBlockDeclarations(parent) {
|
|
88674
88907
|
switch (parent.kind) {
|
|
88675
88908
|
case 245 /* IfStatement */:
|
|
88676
88909
|
case 246 /* DoStatement */:
|
|
@@ -88681,12 +88914,12 @@ function createTypeChecker(host) {
|
|
|
88681
88914
|
case 250 /* ForOfStatement */:
|
|
88682
88915
|
return false;
|
|
88683
88916
|
case 256 /* LabeledStatement */:
|
|
88684
|
-
return
|
|
88917
|
+
return allowBlockDeclarations(parent.parent);
|
|
88685
88918
|
}
|
|
88686
88919
|
return true;
|
|
88687
88920
|
}
|
|
88688
88921
|
function checkGrammarForDisallowedBlockScopedVariableStatement(node) {
|
|
88689
|
-
if (!
|
|
88922
|
+
if (!allowBlockDeclarations(node.parent)) {
|
|
88690
88923
|
const blockScopeKind = getCombinedNodeFlagsCached(node.declarationList) & 7 /* BlockScoped */;
|
|
88691
88924
|
if (blockScopeKind) {
|
|
88692
88925
|
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 +91525,9 @@ function getDecoratorsOfParameters(node) {
|
|
|
91292
91525
|
}
|
|
91293
91526
|
return decorators;
|
|
91294
91527
|
}
|
|
91295
|
-
function getAllDecoratorsOfClass(node) {
|
|
91528
|
+
function getAllDecoratorsOfClass(node, useLegacyDecorators) {
|
|
91296
91529
|
const decorators = getDecorators(node);
|
|
91297
|
-
const parameters = getDecoratorsOfParameters(getFirstConstructorWithBody(node));
|
|
91530
|
+
const parameters = useLegacyDecorators ? getDecoratorsOfParameters(getFirstConstructorWithBody(node)) : void 0;
|
|
91298
91531
|
if (!some(decorators) && !some(parameters)) {
|
|
91299
91532
|
return void 0;
|
|
91300
91533
|
}
|
|
@@ -91308,18 +91541,27 @@ function getAllDecoratorsOfClassElement(member, parent, useLegacyDecorators) {
|
|
|
91308
91541
|
case 177 /* GetAccessor */:
|
|
91309
91542
|
case 178 /* SetAccessor */:
|
|
91310
91543
|
if (!useLegacyDecorators) {
|
|
91311
|
-
return getAllDecoratorsOfMethod(
|
|
91544
|
+
return getAllDecoratorsOfMethod(
|
|
91545
|
+
member,
|
|
91546
|
+
/*useLegacyDecorators*/
|
|
91547
|
+
false
|
|
91548
|
+
);
|
|
91312
91549
|
}
|
|
91313
|
-
return getAllDecoratorsOfAccessors(
|
|
91550
|
+
return getAllDecoratorsOfAccessors(
|
|
91551
|
+
member,
|
|
91552
|
+
parent,
|
|
91553
|
+
/*useLegacyDecorators*/
|
|
91554
|
+
true
|
|
91555
|
+
);
|
|
91314
91556
|
case 174 /* MethodDeclaration */:
|
|
91315
|
-
return getAllDecoratorsOfMethod(member);
|
|
91557
|
+
return getAllDecoratorsOfMethod(member, useLegacyDecorators);
|
|
91316
91558
|
case 172 /* PropertyDeclaration */:
|
|
91317
91559
|
return getAllDecoratorsOfProperty(member);
|
|
91318
91560
|
default:
|
|
91319
91561
|
return void 0;
|
|
91320
91562
|
}
|
|
91321
91563
|
}
|
|
91322
|
-
function getAllDecoratorsOfAccessors(accessor, parent) {
|
|
91564
|
+
function getAllDecoratorsOfAccessors(accessor, parent, useLegacyDecorators) {
|
|
91323
91565
|
if (!accessor.body) {
|
|
91324
91566
|
return void 0;
|
|
91325
91567
|
}
|
|
@@ -91329,7 +91571,7 @@ function getAllDecoratorsOfAccessors(accessor, parent) {
|
|
|
91329
91571
|
return void 0;
|
|
91330
91572
|
}
|
|
91331
91573
|
const decorators = getDecorators(firstAccessorWithDecorators);
|
|
91332
|
-
const parameters = getDecoratorsOfParameters(setAccessor);
|
|
91574
|
+
const parameters = useLegacyDecorators ? getDecoratorsOfParameters(setAccessor) : void 0;
|
|
91333
91575
|
if (!some(decorators) && !some(parameters)) {
|
|
91334
91576
|
return void 0;
|
|
91335
91577
|
}
|
|
@@ -91340,12 +91582,12 @@ function getAllDecoratorsOfAccessors(accessor, parent) {
|
|
|
91340
91582
|
setDecorators: setAccessor && getDecorators(setAccessor)
|
|
91341
91583
|
};
|
|
91342
91584
|
}
|
|
91343
|
-
function getAllDecoratorsOfMethod(method) {
|
|
91585
|
+
function getAllDecoratorsOfMethod(method, useLegacyDecorators) {
|
|
91344
91586
|
if (!method.body) {
|
|
91345
91587
|
return void 0;
|
|
91346
91588
|
}
|
|
91347
91589
|
const decorators = getDecorators(method);
|
|
91348
|
-
const parameters = getDecoratorsOfParameters(method);
|
|
91590
|
+
const parameters = useLegacyDecorators ? getDecoratorsOfParameters(method) : void 0;
|
|
91349
91591
|
if (!some(decorators) && !some(parameters)) {
|
|
91350
91592
|
return void 0;
|
|
91351
91593
|
}
|
|
@@ -93254,7 +93496,7 @@ function transformTypeScript(context) {
|
|
|
93254
93496
|
return updated;
|
|
93255
93497
|
}
|
|
93256
93498
|
function visitParenthesizedExpression(node) {
|
|
93257
|
-
const innerExpression = skipOuterExpressions(node.expression, ~(
|
|
93499
|
+
const innerExpression = skipOuterExpressions(node.expression, ~(38 /* Assertions */ | 16 /* ExpressionsWithTypeArguments */));
|
|
93258
93500
|
if (isAssertionExpression(innerExpression) || isSatisfiesExpression(innerExpression)) {
|
|
93259
93501
|
const expression = visitNode(node.expression, visitor, isExpression);
|
|
93260
93502
|
Debug.assert(expression);
|
|
@@ -96979,7 +97221,11 @@ function transformLegacyDecorators(context) {
|
|
|
96979
97221
|
}
|
|
96980
97222
|
}
|
|
96981
97223
|
function generateConstructorDecorationExpression(node) {
|
|
96982
|
-
const allDecorators = getAllDecoratorsOfClass(
|
|
97224
|
+
const allDecorators = getAllDecoratorsOfClass(
|
|
97225
|
+
node,
|
|
97226
|
+
/*useLegacyDecorators*/
|
|
97227
|
+
true
|
|
97228
|
+
);
|
|
96983
97229
|
const decoratorExpressions = transformAllDecoratorsOfDeclaration(allDecorators);
|
|
96984
97230
|
if (!decoratorExpressions) {
|
|
96985
97231
|
return void 0;
|
|
@@ -97491,7 +97737,11 @@ function transformESDecorators(context) {
|
|
|
97491
97737
|
let syntheticConstructor;
|
|
97492
97738
|
let heritageClauses;
|
|
97493
97739
|
let shouldTransformPrivateStaticElementsInClass = false;
|
|
97494
|
-
const classDecorators = transformAllDecoratorsOfDeclaration(getAllDecoratorsOfClass(
|
|
97740
|
+
const classDecorators = transformAllDecoratorsOfDeclaration(getAllDecoratorsOfClass(
|
|
97741
|
+
node,
|
|
97742
|
+
/*useLegacyDecorators*/
|
|
97743
|
+
false
|
|
97744
|
+
));
|
|
97495
97745
|
if (classDecorators) {
|
|
97496
97746
|
classInfo2.classDecoratorsName = factory2.createUniqueName("_classDecorators", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
97497
97747
|
classInfo2.classDescriptorName = factory2.createUniqueName("_classDescriptor", 16 /* Optimistic */ | 32 /* FileLevel */);
|
|
@@ -116986,15 +117236,88 @@ function createPrinter(printerOptions = {}, handlers = {}) {
|
|
|
116986
117236
|
return false;
|
|
116987
117237
|
}
|
|
116988
117238
|
function parenthesizeExpressionForNoAsi(node) {
|
|
116989
|
-
if (!commentsDisabled
|
|
116990
|
-
|
|
116991
|
-
|
|
116992
|
-
|
|
116993
|
-
|
|
116994
|
-
|
|
116995
|
-
|
|
117239
|
+
if (!commentsDisabled) {
|
|
117240
|
+
switch (node.kind) {
|
|
117241
|
+
case 355 /* PartiallyEmittedExpression */:
|
|
117242
|
+
if (willEmitLeadingNewLine(node)) {
|
|
117243
|
+
const parseNode = getParseTreeNode(node);
|
|
117244
|
+
if (parseNode && isParenthesizedExpression(parseNode)) {
|
|
117245
|
+
const parens = factory.createParenthesizedExpression(node.expression);
|
|
117246
|
+
setOriginalNode(parens, node);
|
|
117247
|
+
setTextRange(parens, parseNode);
|
|
117248
|
+
return parens;
|
|
117249
|
+
}
|
|
117250
|
+
return factory.createParenthesizedExpression(node);
|
|
117251
|
+
}
|
|
117252
|
+
return factory.updatePartiallyEmittedExpression(
|
|
117253
|
+
node,
|
|
117254
|
+
parenthesizeExpressionForNoAsi(node.expression)
|
|
117255
|
+
);
|
|
117256
|
+
case 211 /* PropertyAccessExpression */:
|
|
117257
|
+
return factory.updatePropertyAccessExpression(
|
|
117258
|
+
node,
|
|
117259
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
117260
|
+
node.name
|
|
117261
|
+
);
|
|
117262
|
+
case 212 /* ElementAccessExpression */:
|
|
117263
|
+
return factory.updateElementAccessExpression(
|
|
117264
|
+
node,
|
|
117265
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
117266
|
+
node.argumentExpression
|
|
117267
|
+
);
|
|
117268
|
+
case 213 /* CallExpression */:
|
|
117269
|
+
return factory.updateCallExpression(
|
|
117270
|
+
node,
|
|
117271
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
117272
|
+
node.typeArguments,
|
|
117273
|
+
node.arguments
|
|
117274
|
+
);
|
|
117275
|
+
case 215 /* TaggedTemplateExpression */:
|
|
117276
|
+
return factory.updateTaggedTemplateExpression(
|
|
117277
|
+
node,
|
|
117278
|
+
parenthesizeExpressionForNoAsi(node.tag),
|
|
117279
|
+
node.typeArguments,
|
|
117280
|
+
node.template
|
|
117281
|
+
);
|
|
117282
|
+
case 225 /* PostfixUnaryExpression */:
|
|
117283
|
+
return factory.updatePostfixUnaryExpression(
|
|
117284
|
+
node,
|
|
117285
|
+
parenthesizeExpressionForNoAsi(node.operand)
|
|
117286
|
+
);
|
|
117287
|
+
case 226 /* BinaryExpression */:
|
|
117288
|
+
return factory.updateBinaryExpression(
|
|
117289
|
+
node,
|
|
117290
|
+
parenthesizeExpressionForNoAsi(node.left),
|
|
117291
|
+
node.operatorToken,
|
|
117292
|
+
node.right
|
|
117293
|
+
);
|
|
117294
|
+
case 227 /* ConditionalExpression */:
|
|
117295
|
+
return factory.updateConditionalExpression(
|
|
117296
|
+
node,
|
|
117297
|
+
parenthesizeExpressionForNoAsi(node.condition),
|
|
117298
|
+
node.questionToken,
|
|
117299
|
+
node.whenTrue,
|
|
117300
|
+
node.colonToken,
|
|
117301
|
+
node.whenFalse
|
|
117302
|
+
);
|
|
117303
|
+
case 234 /* AsExpression */:
|
|
117304
|
+
return factory.updateAsExpression(
|
|
117305
|
+
node,
|
|
117306
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
117307
|
+
node.type
|
|
117308
|
+
);
|
|
117309
|
+
case 238 /* SatisfiesExpression */:
|
|
117310
|
+
return factory.updateSatisfiesExpression(
|
|
117311
|
+
node,
|
|
117312
|
+
parenthesizeExpressionForNoAsi(node.expression),
|
|
117313
|
+
node.type
|
|
117314
|
+
);
|
|
117315
|
+
case 235 /* NonNullExpression */:
|
|
117316
|
+
return factory.updateNonNullExpression(
|
|
117317
|
+
node,
|
|
117318
|
+
parenthesizeExpressionForNoAsi(node.expression)
|
|
117319
|
+
);
|
|
116996
117320
|
}
|
|
116997
|
-
return factory.createParenthesizedExpression(node);
|
|
116998
117321
|
}
|
|
116999
117322
|
return node;
|
|
117000
117323
|
}
|
|
@@ -132128,18 +132451,21 @@ function createSyntacticTypeNodeBuilder(options, resolver) {
|
|
|
132128
132451
|
return failed;
|
|
132129
132452
|
}
|
|
132130
132453
|
function typeFromFunctionLikeExpression(fnNode, context) {
|
|
132131
|
-
const
|
|
132132
|
-
context.noInferenceFallback = true;
|
|
132133
|
-
createReturnFromSignature(
|
|
132454
|
+
const returnType = createReturnFromSignature(
|
|
132134
132455
|
fnNode,
|
|
132135
132456
|
/*symbol*/
|
|
132136
132457
|
void 0,
|
|
132137
132458
|
context
|
|
132138
132459
|
);
|
|
132139
|
-
reuseTypeParameters(fnNode.typeParameters, context);
|
|
132140
|
-
fnNode.parameters.map((p) => ensureParameter(p, context));
|
|
132141
|
-
|
|
132142
|
-
|
|
132460
|
+
const typeParameters = reuseTypeParameters(fnNode.typeParameters, context);
|
|
132461
|
+
const parameters = fnNode.parameters.map((p) => ensureParameter(p, context));
|
|
132462
|
+
return syntacticResult(
|
|
132463
|
+
factory.createFunctionTypeNode(
|
|
132464
|
+
typeParameters,
|
|
132465
|
+
parameters,
|
|
132466
|
+
returnType
|
|
132467
|
+
)
|
|
132468
|
+
);
|
|
132143
132469
|
}
|
|
132144
132470
|
function canGetTypeFromArrayLiteral(arrayLiteral, context, isConstContext) {
|
|
132145
132471
|
if (!isConstContext) {
|