typescript 4.9.1-beta → 4.9.2-rc
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/cs/diagnosticMessages.generated.json +6 -0
- package/lib/de/diagnosticMessages.generated.json +6 -0
- package/lib/es/diagnosticMessages.generated.json +6 -0
- package/lib/fr/diagnosticMessages.generated.json +6 -0
- package/lib/it/diagnosticMessages.generated.json +6 -0
- package/lib/ja/diagnosticMessages.generated.json +6 -0
- package/lib/ko/diagnosticMessages.generated.json +6 -0
- package/lib/lib.dom.d.ts +111 -14
- package/lib/lib.dom.iterable.d.ts +6 -2
- package/lib/lib.es2015.symbol.wellknown.d.ts +3 -3
- package/lib/lib.es5.d.ts +3 -2
- package/lib/lib.webworker.d.ts +193 -6
- package/lib/lib.webworker.iterable.d.ts +10 -2
- package/lib/pl/diagnosticMessages.generated.json +9 -3
- package/lib/protocol.d.ts +18 -5
- package/lib/pt-br/diagnosticMessages.generated.json +6 -0
- package/lib/ru/diagnosticMessages.generated.json +6 -0
- package/lib/tr/diagnosticMessages.generated.json +9 -0
- package/lib/tsc.js +507 -284
- package/lib/tsserver.js +975 -471
- package/lib/tsserverlibrary.d.ts +27 -8
- package/lib/tsserverlibrary.js +972 -471
- package/lib/typescript.d.ts +9 -2
- package/lib/typescript.js +901 -421
- package/lib/typescriptServices.d.ts +9 -2
- package/lib/typescriptServices.js +901 -421
- package/lib/typingsInstaller.js +625 -359
- package/lib/zh-cn/diagnosticMessages.generated.json +6 -0
- package/lib/zh-tw/diagnosticMessages.generated.json +6 -0
- package/package.json +6 -7
package/lib/typescript.js
CHANGED
|
@@ -44,7 +44,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
44
44
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
45
45
|
function step(op) {
|
|
46
46
|
if (f) throw new TypeError("Generator is already executing.");
|
|
47
|
-
while (_) try {
|
|
47
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
48
48
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
49
49
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
50
50
|
switch (op[0]) {
|
|
@@ -99,7 +99,7 @@ var ts;
|
|
|
99
99
|
// The following is baselined as a literal template type without intervention
|
|
100
100
|
/** The version of the TypeScript compiler release */
|
|
101
101
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
102
|
-
ts.version = "".concat(ts.versionMajorMinor, ".
|
|
102
|
+
ts.version = "".concat(ts.versionMajorMinor, ".2-rc");
|
|
103
103
|
/* @internal */
|
|
104
104
|
var Comparison;
|
|
105
105
|
(function (Comparison) {
|
|
@@ -1891,8 +1891,8 @@ var ts;
|
|
|
1891
1891
|
return compareValues(a === null || a === void 0 ? void 0 : a.start, b === null || b === void 0 ? void 0 : b.start) || compareValues(a === null || a === void 0 ? void 0 : a.length, b === null || b === void 0 ? void 0 : b.length);
|
|
1892
1892
|
}
|
|
1893
1893
|
ts.compareTextSpans = compareTextSpans;
|
|
1894
|
-
function min(
|
|
1895
|
-
return compare(
|
|
1894
|
+
function min(items, compare) {
|
|
1895
|
+
return reduceLeft(items, function (x, y) { return compare(x, y) === -1 /* Comparison.LessThan */ ? x : y; });
|
|
1896
1896
|
}
|
|
1897
1897
|
ts.min = min;
|
|
1898
1898
|
/**
|
|
@@ -3205,11 +3205,13 @@ var ts;
|
|
|
3205
3205
|
// > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers
|
|
3206
3206
|
// > MUST NOT include leading zeroes.
|
|
3207
3207
|
var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
|
|
3208
|
+
var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
|
|
3208
3209
|
// https://semver.org/#spec-item-10
|
|
3209
3210
|
// > Build metadata MAY be denoted by appending a plus sign and a series of dot separated
|
|
3210
3211
|
// > identifiers immediately following the patch or pre-release version. Identifiers MUST
|
|
3211
3212
|
// > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
|
|
3212
3213
|
var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
|
|
3214
|
+
var buildPartRegExp = /^[a-z0-9-]+$/i;
|
|
3213
3215
|
// https://semver.org/#spec-item-9
|
|
3214
3216
|
// > Numeric identifiers MUST NOT include leading zeroes.
|
|
3215
3217
|
var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
|
|
@@ -3229,13 +3231,15 @@ var ts;
|
|
|
3229
3231
|
ts.Debug.assert(major >= 0, "Invalid argument: major");
|
|
3230
3232
|
ts.Debug.assert(minor >= 0, "Invalid argument: minor");
|
|
3231
3233
|
ts.Debug.assert(patch >= 0, "Invalid argument: patch");
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
+
var prereleaseArray = prerelease ? ts.isArray(prerelease) ? prerelease : prerelease.split(".") : ts.emptyArray;
|
|
3235
|
+
var buildArray = build ? ts.isArray(build) ? build : build.split(".") : ts.emptyArray;
|
|
3236
|
+
ts.Debug.assert(ts.every(prereleaseArray, function (s) { return prereleasePartRegExp.test(s); }), "Invalid argument: prerelease");
|
|
3237
|
+
ts.Debug.assert(ts.every(buildArray, function (s) { return buildPartRegExp.test(s); }), "Invalid argument: build");
|
|
3234
3238
|
this.major = major;
|
|
3235
3239
|
this.minor = minor;
|
|
3236
3240
|
this.patch = patch;
|
|
3237
|
-
this.prerelease =
|
|
3238
|
-
this.build =
|
|
3241
|
+
this.prerelease = prereleaseArray;
|
|
3242
|
+
this.build = buildArray;
|
|
3239
3243
|
}
|
|
3240
3244
|
Version.tryParse = function (text) {
|
|
3241
3245
|
var result = tryParseComponents(text);
|
|
@@ -3274,6 +3278,10 @@ var ts;
|
|
|
3274
3278
|
default: return ts.Debug.assertNever(field);
|
|
3275
3279
|
}
|
|
3276
3280
|
};
|
|
3281
|
+
Version.prototype.with = function (fields) {
|
|
3282
|
+
var _a = fields.major, major = _a === void 0 ? this.major : _a, _b = fields.minor, minor = _b === void 0 ? this.minor : _b, _c = fields.patch, patch = _c === void 0 ? this.patch : _c, _d = fields.prerelease, prerelease = _d === void 0 ? this.prerelease : _d, _e = fields.build, build = _e === void 0 ? this.build : _e;
|
|
3283
|
+
return new Version(major, minor, patch, prerelease, build);
|
|
3284
|
+
};
|
|
3277
3285
|
Version.prototype.toString = function () {
|
|
3278
3286
|
var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
|
|
3279
3287
|
if (ts.some(this.prerelease))
|
|
@@ -3282,7 +3290,7 @@ var ts;
|
|
|
3282
3290
|
result += "+".concat(this.build.join("."));
|
|
3283
3291
|
return result;
|
|
3284
3292
|
};
|
|
3285
|
-
Version.zero = new Version(0, 0, 0);
|
|
3293
|
+
Version.zero = new Version(0, 0, 0, ["0"]);
|
|
3286
3294
|
return Version;
|
|
3287
3295
|
}());
|
|
3288
3296
|
ts.Version = Version;
|
|
@@ -3365,6 +3373,10 @@ var ts;
|
|
|
3365
3373
|
}
|
|
3366
3374
|
return undefined;
|
|
3367
3375
|
};
|
|
3376
|
+
/**
|
|
3377
|
+
* Tests whether a version matches the range. This is equivalent to `satisfies(version, range, { includePrerelease: true })`.
|
|
3378
|
+
* in `node-semver`.
|
|
3379
|
+
*/
|
|
3368
3380
|
VersionRange.prototype.test = function (version) {
|
|
3369
3381
|
if (typeof version === "string")
|
|
3370
3382
|
version = new Version(version);
|
|
@@ -3475,19 +3487,20 @@ var ts;
|
|
|
3475
3487
|
break;
|
|
3476
3488
|
case "<":
|
|
3477
3489
|
case ">=":
|
|
3478
|
-
comparators.push(createComparator(operator, version))
|
|
3490
|
+
comparators.push(isWildcard(minor) || isWildcard(patch) ? createComparator(operator, version.with({ prerelease: "0" })) :
|
|
3491
|
+
createComparator(operator, version));
|
|
3479
3492
|
break;
|
|
3480
3493
|
case "<=":
|
|
3481
3494
|
case ">":
|
|
3482
|
-
comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
|
|
3483
|
-
isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
|
|
3495
|
+
comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major").with({ prerelease: "0" })) :
|
|
3496
|
+
isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor").with({ prerelease: "0" })) :
|
|
3484
3497
|
createComparator(operator, version));
|
|
3485
3498
|
break;
|
|
3486
3499
|
case "=":
|
|
3487
3500
|
case undefined:
|
|
3488
3501
|
if (isWildcard(minor) || isWildcard(patch)) {
|
|
3489
|
-
comparators.push(createComparator(">=", version));
|
|
3490
|
-
comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
|
|
3502
|
+
comparators.push(createComparator(">=", version.with({ prerelease: "0" })));
|
|
3503
|
+
comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor").with({ prerelease: "0" })));
|
|
3491
3504
|
}
|
|
3492
3505
|
else {
|
|
3493
3506
|
comparators.push(createComparator("=", version));
|
|
@@ -5096,8 +5109,8 @@ var ts;
|
|
|
5096
5109
|
NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance";
|
|
5097
5110
|
NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic";
|
|
5098
5111
|
NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked";
|
|
5099
|
-
NodeCheckFlags[NodeCheckFlags["
|
|
5100
|
-
NodeCheckFlags[NodeCheckFlags["
|
|
5112
|
+
NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAccessInAsync"] = 2048] = "MethodWithSuperPropertyAccessInAsync";
|
|
5113
|
+
NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAssignmentInAsync"] = 4096] = "MethodWithSuperPropertyAssignmentInAsync";
|
|
5101
5114
|
NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments";
|
|
5102
5115
|
NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed";
|
|
5103
5116
|
NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass";
|
|
@@ -6732,7 +6745,7 @@ var ts;
|
|
|
6732
6745
|
}
|
|
6733
6746
|
/*@internal*/
|
|
6734
6747
|
function createSystemWatchFunctions(_a) {
|
|
6735
|
-
var pollingWatchFileWorker = _a.pollingWatchFileWorker, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatchWorker = _a.fsWatchWorker, fileSystemEntryExists = _a.fileSystemEntryExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory,
|
|
6748
|
+
var pollingWatchFileWorker = _a.pollingWatchFileWorker, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatchWorker = _a.fsWatchWorker, fileSystemEntryExists = _a.fileSystemEntryExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory, inodeWatching = _a.inodeWatching, sysLog = _a.sysLog;
|
|
6736
6749
|
var pollingWatches = new ts.Map();
|
|
6737
6750
|
var fsWatches = new ts.Map();
|
|
6738
6751
|
var fsWatchesRecursive = new ts.Map();
|
|
@@ -6798,8 +6811,8 @@ var ts;
|
|
|
6798
6811
|
return useNonPollingWatchers ?
|
|
6799
6812
|
// Use notifications from FS to watch with falling back to fs.watchFile
|
|
6800
6813
|
generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
|
|
6801
|
-
// Default to
|
|
6802
|
-
{ watchFile:
|
|
6814
|
+
// Default to using fs events
|
|
6815
|
+
{ watchFile: ts.WatchFileKind.UseFsEvents };
|
|
6803
6816
|
}
|
|
6804
6817
|
}
|
|
6805
6818
|
function generateWatchFileOptions(watchFile, fallbackPolling, options) {
|
|
@@ -7071,7 +7084,6 @@ var ts;
|
|
|
7071
7084
|
tscWatchFile: process.env.TSC_WATCHFILE,
|
|
7072
7085
|
useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
|
|
7073
7086
|
tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
|
|
7074
|
-
defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
|
7075
7087
|
inodeWatching: isLinuxOrMacOs,
|
|
7076
7088
|
sysLog: sysLog,
|
|
7077
7089
|
}), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
|
|
@@ -9582,6 +9594,10 @@ var ts;
|
|
|
9582
9594
|
Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitted: diag(6399, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_buildinfo_file_1_indicates_that_some_of_the_changes_were_not_emitte_6399", "Project '{0}' is out of date because buildinfo file '{1}' indicates that some of the changes were not emitted"),
|
|
9583
9595
|
Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_files: diag(6400, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_but_needs_to_update_timestamps_of_output_files_that_are_older_than_input_fil_6400", "Project '{0}' is up to date but needs to update timestamps of output files that are older than input files"),
|
|
9584
9596
|
Project_0_is_out_of_date_because_there_was_error_reading_file_1: diag(6401, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_there_was_error_reading_file_1_6401", "Project '{0}' is out of date because there was error reading file '{1}'"),
|
|
9597
|
+
Resolving_in_0_mode_with_conditions_1: diag(6402, ts.DiagnosticCategory.Message, "Resolving_in_0_mode_with_conditions_1_6402", "Resolving in {0} mode with conditions {1}."),
|
|
9598
|
+
Matched_0_condition_1: diag(6403, ts.DiagnosticCategory.Message, "Matched_0_condition_1_6403", "Matched '{0}' condition '{1}'."),
|
|
9599
|
+
Using_0_subpath_1_with_target_2: diag(6404, ts.DiagnosticCategory.Message, "Using_0_subpath_1_with_target_2_6404", "Using '{0}' subpath '{1}' with target '{2}'."),
|
|
9600
|
+
Saw_non_matching_condition_0: diag(6405, ts.DiagnosticCategory.Message, "Saw_non_matching_condition_0_6405", "Saw non-matching condition '{0}'."),
|
|
9585
9601
|
The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"),
|
|
9586
9602
|
The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."),
|
|
9587
9603
|
The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."),
|
|
@@ -9898,6 +9914,8 @@ var ts;
|
|
|
9898
9914
|
Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
|
|
9899
9915
|
Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
|
|
9900
9916
|
Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
|
|
9917
|
+
Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
|
|
9918
|
+
Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
|
|
9901
9919
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9902
9920
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9903
9921
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -11355,7 +11373,7 @@ var ts;
|
|
|
11355
11373
|
return -1;
|
|
11356
11374
|
}
|
|
11357
11375
|
function peekExtendedUnicodeEscape() {
|
|
11358
|
-
if (
|
|
11376
|
+
if (codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
|
|
11359
11377
|
var start_2 = pos;
|
|
11360
11378
|
pos += 3;
|
|
11361
11379
|
var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
|
|
@@ -21658,6 +21676,32 @@ var ts;
|
|
|
21658
21676
|
return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
|
|
21659
21677
|
}
|
|
21660
21678
|
ts.getParameterTypeNode = getParameterTypeNode;
|
|
21679
|
+
function isTypeDeclaration(node) {
|
|
21680
|
+
switch (node.kind) {
|
|
21681
|
+
case 165 /* SyntaxKind.TypeParameter */:
|
|
21682
|
+
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
21683
|
+
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
21684
|
+
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
21685
|
+
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
21686
|
+
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
21687
|
+
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
21688
|
+
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
21689
|
+
return true;
|
|
21690
|
+
case 270 /* SyntaxKind.ImportClause */:
|
|
21691
|
+
return node.isTypeOnly;
|
|
21692
|
+
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
21693
|
+
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
21694
|
+
return node.parent.parent.isTypeOnly;
|
|
21695
|
+
default:
|
|
21696
|
+
return false;
|
|
21697
|
+
}
|
|
21698
|
+
}
|
|
21699
|
+
ts.isTypeDeclaration = isTypeDeclaration;
|
|
21700
|
+
function canHaveExportModifier(node) {
|
|
21701
|
+
return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
|
|
21702
|
+
|| ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
|
|
21703
|
+
}
|
|
21704
|
+
ts.canHaveExportModifier = canHaveExportModifier;
|
|
21661
21705
|
})(ts || (ts = {}));
|
|
21662
21706
|
/* @internal */
|
|
21663
21707
|
var ts;
|
|
@@ -21666,13 +21710,11 @@ var ts;
|
|
|
21666
21710
|
* Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
|
|
21667
21711
|
*/
|
|
21668
21712
|
function createBaseNodeFactory() {
|
|
21669
|
-
// tslint:disable variable-name
|
|
21670
21713
|
var NodeConstructor;
|
|
21671
21714
|
var TokenConstructor;
|
|
21672
21715
|
var IdentifierConstructor;
|
|
21673
21716
|
var PrivateIdentifierConstructor;
|
|
21674
21717
|
var SourceFileConstructor;
|
|
21675
|
-
// tslint:enable variable-name
|
|
21676
21718
|
return {
|
|
21677
21719
|
createBaseSourceFileNode: createBaseSourceFileNode,
|
|
21678
21720
|
createBaseIdentifierNode: createBaseIdentifierNode,
|
|
@@ -23136,7 +23178,7 @@ var ts;
|
|
|
23136
23178
|
return node;
|
|
23137
23179
|
}
|
|
23138
23180
|
// @api
|
|
23139
|
-
function createIdentifier(text, typeArguments, originalKeywordKind) {
|
|
23181
|
+
function createIdentifier(text, typeArguments, originalKeywordKind, hasExtendedUnicodeEscape) {
|
|
23140
23182
|
var node = createBaseIdentifier(text, originalKeywordKind);
|
|
23141
23183
|
if (typeArguments) {
|
|
23142
23184
|
// NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
|
|
@@ -23145,6 +23187,10 @@ var ts;
|
|
|
23145
23187
|
if (node.originalKeywordKind === 133 /* SyntaxKind.AwaitKeyword */) {
|
|
23146
23188
|
node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */;
|
|
23147
23189
|
}
|
|
23190
|
+
if (hasExtendedUnicodeEscape) {
|
|
23191
|
+
node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
|
|
23192
|
+
node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
|
|
23193
|
+
}
|
|
23148
23194
|
return node;
|
|
23149
23195
|
}
|
|
23150
23196
|
// @api
|
|
@@ -27600,11 +27646,9 @@ var ts;
|
|
|
27600
27646
|
rawTextScanner.setText("`" + rawText + "`");
|
|
27601
27647
|
break;
|
|
27602
27648
|
case 15 /* SyntaxKind.TemplateHead */:
|
|
27603
|
-
// tslint:disable-next-line no-invalid-template-strings
|
|
27604
27649
|
rawTextScanner.setText("`" + rawText + "${");
|
|
27605
27650
|
break;
|
|
27606
27651
|
case 16 /* SyntaxKind.TemplateMiddle */:
|
|
27607
|
-
// tslint:disable-next-line no-invalid-template-strings
|
|
27608
27652
|
rawTextScanner.setText("}" + rawText + "${");
|
|
27609
27653
|
break;
|
|
27610
27654
|
case 17 /* SyntaxKind.TemplateTail */:
|
|
@@ -27963,7 +28007,6 @@ var ts;
|
|
|
27963
28007
|
return node;
|
|
27964
28008
|
}
|
|
27965
28009
|
ts.createInputFiles = createInputFiles;
|
|
27966
|
-
// tslint:disable-next-line variable-name
|
|
27967
28010
|
var SourceMapSource;
|
|
27968
28011
|
/**
|
|
27969
28012
|
* Create an external source map source file reference
|
|
@@ -28755,6 +28798,8 @@ var ts;
|
|
|
28755
28798
|
// - The verb (`next`, `throw`, or `return` method) to delegate to the expression
|
|
28756
28799
|
// of a `yield*`.
|
|
28757
28800
|
// - The result of evaluating the verb delegated to the expression of a `yield*`.
|
|
28801
|
+
// g A temporary variable that holds onto the generator object until the generator
|
|
28802
|
+
// is started, allowing it to also act as the `suspendedStart` state.
|
|
28758
28803
|
//
|
|
28759
28804
|
// functions:
|
|
28760
28805
|
// verb(n) Creates a bound callback to the `step` function for opcode `n`.
|
|
@@ -28793,7 +28838,7 @@ var ts;
|
|
|
28793
28838
|
importName: "__generator",
|
|
28794
28839
|
scoped: false,
|
|
28795
28840
|
priority: 6,
|
|
28796
|
-
text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };"
|
|
28841
|
+
text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };"
|
|
28797
28842
|
};
|
|
28798
28843
|
// ES Module Helpers
|
|
28799
28844
|
ts.createBindingHelper = {
|
|
@@ -32097,13 +32142,11 @@ var ts;
|
|
|
32097
32142
|
var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
|
|
32098
32143
|
var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
|
|
32099
32144
|
// capture constructors in 'initializeState' to avoid null checks
|
|
32100
|
-
// tslint:disable variable-name
|
|
32101
32145
|
var NodeConstructor;
|
|
32102
32146
|
var TokenConstructor;
|
|
32103
32147
|
var IdentifierConstructor;
|
|
32104
32148
|
var PrivateIdentifierConstructor;
|
|
32105
32149
|
var SourceFileConstructor;
|
|
32106
|
-
// tslint:enable variable-name
|
|
32107
32150
|
function countNode(node) {
|
|
32108
32151
|
nodeCount++;
|
|
32109
32152
|
return node;
|
|
@@ -33079,8 +33122,9 @@ var ts;
|
|
|
33079
33122
|
// Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
|
|
33080
33123
|
var originalKeywordKind = token();
|
|
33081
33124
|
var text = internIdentifier(scanner.getTokenValue());
|
|
33125
|
+
var hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
|
|
33082
33126
|
nextTokenWithoutCheck();
|
|
33083
|
-
return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos);
|
|
33127
|
+
return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind, hasExtendedUnicodeEscape), pos);
|
|
33084
33128
|
}
|
|
33085
33129
|
if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
|
|
33086
33130
|
parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
@@ -42219,12 +42263,23 @@ var ts;
|
|
|
42219
42263
|
}
|
|
42220
42264
|
function writeConfigurations() {
|
|
42221
42265
|
// Filter applicable options to place in the file
|
|
42222
|
-
var categorizedOptions = ts.
|
|
42266
|
+
var categorizedOptions = new ts.Map();
|
|
42267
|
+
// Set allowed categories in order
|
|
42268
|
+
categorizedOptions.set(ts.Diagnostics.Projects, []);
|
|
42269
|
+
categorizedOptions.set(ts.Diagnostics.Language_and_Environment, []);
|
|
42270
|
+
categorizedOptions.set(ts.Diagnostics.Modules, []);
|
|
42271
|
+
categorizedOptions.set(ts.Diagnostics.JavaScript_Support, []);
|
|
42272
|
+
categorizedOptions.set(ts.Diagnostics.Emit, []);
|
|
42273
|
+
categorizedOptions.set(ts.Diagnostics.Interop_Constraints, []);
|
|
42274
|
+
categorizedOptions.set(ts.Diagnostics.Type_Checking, []);
|
|
42275
|
+
categorizedOptions.set(ts.Diagnostics.Completeness, []);
|
|
42223
42276
|
for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
|
|
42224
42277
|
var option = optionDeclarations_1[_i];
|
|
42225
|
-
var category = option.category;
|
|
42226
42278
|
if (isAllowedOptionForOutput(option)) {
|
|
42227
|
-
categorizedOptions.
|
|
42279
|
+
var listForCategory = categorizedOptions.get(option.category);
|
|
42280
|
+
if (!listForCategory)
|
|
42281
|
+
categorizedOptions.set(option.category, listForCategory = []);
|
|
42282
|
+
listForCategory.push(option);
|
|
42228
42283
|
}
|
|
42229
42284
|
}
|
|
42230
42285
|
// Serialize all options and their descriptions
|
|
@@ -42235,7 +42290,7 @@ var ts;
|
|
|
42235
42290
|
if (entries.length !== 0) {
|
|
42236
42291
|
entries.push({ value: "" });
|
|
42237
42292
|
}
|
|
42238
|
-
entries.push({ value: "/* ".concat(category, " */") });
|
|
42293
|
+
entries.push({ value: "/* ".concat(ts.getLocaleSpecificMessage(category), " */") });
|
|
42239
42294
|
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
|
|
42240
42295
|
var option = options_1[_i];
|
|
42241
42296
|
var optionName = void 0;
|
|
@@ -44277,6 +44332,9 @@ var ts;
|
|
|
44277
44332
|
requestContainingDirectory: containingDirectory,
|
|
44278
44333
|
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
44279
44334
|
};
|
|
44335
|
+
if (traceEnabled && ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) <= ts.ModuleResolutionKind.NodeNext) {
|
|
44336
|
+
trace(host, ts.Diagnostics.Resolving_in_0_mode_with_conditions_1, features & NodeResolutionFeatures.EsmMode ? "ESM" : "CJS", conditions.map(function (c) { return "'".concat(c, "'"); }).join(", "));
|
|
44337
|
+
}
|
|
44280
44338
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
44281
44339
|
return createResolvedModuleWithFailedLookupLocations((_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.resolved, (_b = result === null || result === void 0 ? void 0 : result.value) === null || _b === void 0 ? void 0 : _b.isExternalLibraryImport, failedLookupLocations, affectingLocations, diagnostics, state.resultFromCache);
|
|
44282
44340
|
function tryResolve(extensions) {
|
|
@@ -44866,7 +44924,7 @@ var ts;
|
|
|
44866
44924
|
}
|
|
44867
44925
|
if (mainExport) {
|
|
44868
44926
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
|
|
44869
|
-
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
|
|
44927
|
+
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false, ".");
|
|
44870
44928
|
}
|
|
44871
44929
|
}
|
|
44872
44930
|
else if (allKeysStartWithDot(scope.contents.packageJsonContent.exports)) {
|
|
@@ -44946,7 +45004,7 @@ var ts;
|
|
|
44946
45004
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
44947
45005
|
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
44948
45006
|
var target = lookupTable[moduleName];
|
|
44949
|
-
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
45007
|
+
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false, moduleName);
|
|
44950
45008
|
}
|
|
44951
45009
|
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
|
|
44952
45010
|
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
@@ -44955,17 +45013,17 @@ var ts;
|
|
|
44955
45013
|
var target = lookupTable[potentialTarget];
|
|
44956
45014
|
var starPos = potentialTarget.indexOf("*");
|
|
44957
45015
|
var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
44958
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
45016
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
|
|
44959
45017
|
}
|
|
44960
45018
|
else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
44961
45019
|
var target = lookupTable[potentialTarget];
|
|
44962
45020
|
var subpath = moduleName.substring(potentialTarget.length - 1);
|
|
44963
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
45021
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
|
|
44964
45022
|
}
|
|
44965
45023
|
else if (ts.startsWith(moduleName, potentialTarget)) {
|
|
44966
45024
|
var target = lookupTable[potentialTarget];
|
|
44967
45025
|
var subpath = moduleName.substring(potentialTarget.length);
|
|
44968
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
|
|
45026
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false, potentialTarget);
|
|
44969
45027
|
}
|
|
44970
45028
|
}
|
|
44971
45029
|
function matchesPatternWithTrailer(target, name) {
|
|
@@ -44982,7 +45040,7 @@ var ts;
|
|
|
44982
45040
|
*/
|
|
44983
45041
|
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
44984
45042
|
return loadModuleFromTargetImportOrExport;
|
|
44985
|
-
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
45043
|
+
function loadModuleFromTargetImportOrExport(target, subpath, pattern, key) {
|
|
44986
45044
|
if (typeof target === "string") {
|
|
44987
45045
|
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
44988
45046
|
if (state.traceEnabled) {
|
|
@@ -44993,6 +45051,8 @@ var ts;
|
|
|
44993
45051
|
if (!ts.startsWith(target, "./")) {
|
|
44994
45052
|
if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
|
|
44995
45053
|
var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
|
|
45054
|
+
traceIfEnabled(state, ts.Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
|
|
45055
|
+
traceIfEnabled(state, ts.Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
|
|
44996
45056
|
var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
|
|
44997
45057
|
return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
|
|
44998
45058
|
}
|
|
@@ -45019,6 +45079,9 @@ var ts;
|
|
|
45019
45079
|
}
|
|
45020
45080
|
return toSearchResult(/*value*/ undefined);
|
|
45021
45081
|
}
|
|
45082
|
+
if (state.traceEnabled) {
|
|
45083
|
+
trace(state.host, ts.Diagnostics.Using_0_subpath_1_with_target_2, isImports ? "imports" : "exports", key, pattern ? target.replace(/\*/g, subpath) : target + subpath);
|
|
45084
|
+
}
|
|
45022
45085
|
var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
|
|
45023
45086
|
var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
|
|
45024
45087
|
if (inputLink)
|
|
@@ -45028,14 +45091,18 @@ var ts;
|
|
|
45028
45091
|
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
45029
45092
|
if (!Array.isArray(target)) {
|
|
45030
45093
|
for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
|
|
45031
|
-
var
|
|
45032
|
-
if (
|
|
45033
|
-
|
|
45034
|
-
var
|
|
45094
|
+
var condition = _a[_i];
|
|
45095
|
+
if (condition === "default" || state.conditions.indexOf(condition) >= 0 || isApplicableVersionedTypesKey(state.conditions, condition)) {
|
|
45096
|
+
traceIfEnabled(state, ts.Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
|
|
45097
|
+
var subTarget = target[condition];
|
|
45098
|
+
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern, key);
|
|
45035
45099
|
if (result) {
|
|
45036
45100
|
return result;
|
|
45037
45101
|
}
|
|
45038
45102
|
}
|
|
45103
|
+
else {
|
|
45104
|
+
traceIfEnabled(state, ts.Diagnostics.Saw_non_matching_condition_0, condition);
|
|
45105
|
+
}
|
|
45039
45106
|
}
|
|
45040
45107
|
return undefined;
|
|
45041
45108
|
}
|
|
@@ -45048,7 +45115,7 @@ var ts;
|
|
|
45048
45115
|
}
|
|
45049
45116
|
for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
|
|
45050
45117
|
var elem = target_2[_b];
|
|
45051
|
-
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
45118
|
+
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern, key);
|
|
45052
45119
|
if (result) {
|
|
45053
45120
|
return result;
|
|
45054
45121
|
}
|
|
@@ -45464,6 +45531,15 @@ var ts;
|
|
|
45464
45531
|
function toSearchResult(value) {
|
|
45465
45532
|
return value !== undefined ? { value: value } : undefined;
|
|
45466
45533
|
}
|
|
45534
|
+
function traceIfEnabled(state, diagnostic) {
|
|
45535
|
+
var args = [];
|
|
45536
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
45537
|
+
args[_i - 2] = arguments[_i];
|
|
45538
|
+
}
|
|
45539
|
+
if (state.traceEnabled) {
|
|
45540
|
+
trace.apply(void 0, __spreadArray([state.host, diagnostic], args, false));
|
|
45541
|
+
}
|
|
45542
|
+
}
|
|
45467
45543
|
})(ts || (ts = {}));
|
|
45468
45544
|
/* @internal */
|
|
45469
45545
|
var ts;
|
|
@@ -49055,8 +49131,6 @@ var ts;
|
|
|
49055
49131
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
49056
49132
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
49057
49133
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
49058
|
-
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
49059
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
49060
49134
|
})(IntersectionState || (IntersectionState = {}));
|
|
49061
49135
|
var RecursionFlags;
|
|
49062
49136
|
(function (RecursionFlags) {
|
|
@@ -49475,6 +49549,12 @@ var ts;
|
|
|
49475
49549
|
getOptionalType: function () { return optionalType; },
|
|
49476
49550
|
getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
|
|
49477
49551
|
getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
|
|
49552
|
+
getAsyncIterableType: function () {
|
|
49553
|
+
var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
|
|
49554
|
+
if (type === emptyGenericType)
|
|
49555
|
+
return undefined;
|
|
49556
|
+
return type;
|
|
49557
|
+
},
|
|
49478
49558
|
isSymbolAccessible: isSymbolAccessible,
|
|
49479
49559
|
isArrayType: isArrayType,
|
|
49480
49560
|
isTupleType: isTupleType,
|
|
@@ -50312,9 +50392,9 @@ var ts;
|
|
|
50312
50392
|
return symbol;
|
|
50313
50393
|
}
|
|
50314
50394
|
if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
50315
|
-
var
|
|
50316
|
-
//
|
|
50317
|
-
if (
|
|
50395
|
+
var targetFlags = getAllSymbolFlags(symbol);
|
|
50396
|
+
// `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
|
|
50397
|
+
if (targetFlags & meaning) {
|
|
50318
50398
|
return symbol;
|
|
50319
50399
|
}
|
|
50320
50400
|
}
|
|
@@ -50947,8 +51027,8 @@ var ts;
|
|
|
50947
51027
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
50948
51028
|
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
50949
51029
|
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
51030
|
+
!checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
|
|
50950
51031
|
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
|
|
50951
|
-
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
50952
51032
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
50953
51033
|
var suggestion = void 0;
|
|
50954
51034
|
var suggestedLib = void 0;
|
|
@@ -51035,7 +51115,7 @@ var ts;
|
|
|
51035
51115
|
}
|
|
51036
51116
|
}
|
|
51037
51117
|
if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
51038
|
-
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
|
|
51118
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
|
|
51039
51119
|
if (typeOnlyDeclaration) {
|
|
51040
51120
|
var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
|
|
51041
51121
|
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
@@ -51198,7 +51278,7 @@ var ts;
|
|
|
51198
51278
|
return false;
|
|
51199
51279
|
}
|
|
51200
51280
|
function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
|
|
51201
|
-
if (meaning &
|
|
51281
|
+
if (meaning & 111551 /* SymbolFlags.Value */) {
|
|
51202
51282
|
if (isPrimitiveTypeName(name)) {
|
|
51203
51283
|
if (isExtendedByInterface(errorLocation)) {
|
|
51204
51284
|
error(errorLocation, ts.Diagnostics.An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes, ts.unescapeLeadingUnderscores(name));
|
|
@@ -51209,7 +51289,8 @@ var ts;
|
|
|
51209
51289
|
return true;
|
|
51210
51290
|
}
|
|
51211
51291
|
var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51212
|
-
|
|
51292
|
+
var allFlags = symbol && getAllSymbolFlags(symbol);
|
|
51293
|
+
if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
|
|
51213
51294
|
var rawName = ts.unescapeLeadingUnderscores(name);
|
|
51214
51295
|
if (isES2015OrLaterConstructorName(name)) {
|
|
51215
51296
|
error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later, rawName);
|
|
@@ -51257,16 +51338,16 @@ var ts;
|
|
|
51257
51338
|
}
|
|
51258
51339
|
return false;
|
|
51259
51340
|
}
|
|
51260
|
-
function
|
|
51261
|
-
if (meaning & (111551 /* SymbolFlags.Value */ & ~
|
|
51262
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule
|
|
51341
|
+
function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
|
|
51342
|
+
if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
|
|
51343
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51263
51344
|
if (symbol) {
|
|
51264
51345
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
|
|
51265
51346
|
return true;
|
|
51266
51347
|
}
|
|
51267
51348
|
}
|
|
51268
|
-
else if (meaning & (788968 /* SymbolFlags.Type */ & ~
|
|
51269
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name,
|
|
51349
|
+
else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
|
|
51350
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51270
51351
|
if (symbol) {
|
|
51271
51352
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
|
|
51272
51353
|
return true;
|
|
@@ -51856,6 +51937,52 @@ var ts;
|
|
|
51856
51937
|
}
|
|
51857
51938
|
return undefined;
|
|
51858
51939
|
}
|
|
51940
|
+
/**
|
|
51941
|
+
* Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
|
|
51942
|
+
* is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
|
|
51943
|
+
* with another exported symbol, e.g.
|
|
51944
|
+
* ```ts
|
|
51945
|
+
* // a.ts
|
|
51946
|
+
* export const a = 0;
|
|
51947
|
+
* // b.ts
|
|
51948
|
+
* export { a } from "./a";
|
|
51949
|
+
* export type a = number;
|
|
51950
|
+
* // c.ts
|
|
51951
|
+
* import { a } from "./b";
|
|
51952
|
+
* ```
|
|
51953
|
+
* Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
|
|
51954
|
+
* from b.ts, even though there is still more alias to resolve. Consequently, if we were
|
|
51955
|
+
* trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
|
|
51956
|
+
* the local symbol and on the symbol returned by `resolveAlias` is not enough.
|
|
51957
|
+
* @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
|
|
51958
|
+
* combined flags of all alias targets otherwise.
|
|
51959
|
+
*/
|
|
51960
|
+
function getAllSymbolFlags(symbol) {
|
|
51961
|
+
var flags = symbol.flags;
|
|
51962
|
+
var seenSymbols;
|
|
51963
|
+
while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51964
|
+
var target = resolveAlias(symbol);
|
|
51965
|
+
if (target === unknownSymbol) {
|
|
51966
|
+
return 67108863 /* SymbolFlags.All */;
|
|
51967
|
+
}
|
|
51968
|
+
// Optimizations - try to avoid creating or adding to
|
|
51969
|
+
// `seenSymbols` if possible
|
|
51970
|
+
if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
|
|
51971
|
+
break;
|
|
51972
|
+
}
|
|
51973
|
+
if (target.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51974
|
+
if (seenSymbols) {
|
|
51975
|
+
seenSymbols.add(target);
|
|
51976
|
+
}
|
|
51977
|
+
else {
|
|
51978
|
+
seenSymbols = new ts.Set([symbol, target]);
|
|
51979
|
+
}
|
|
51980
|
+
}
|
|
51981
|
+
flags |= target.flags;
|
|
51982
|
+
symbol = target;
|
|
51983
|
+
}
|
|
51984
|
+
return flags;
|
|
51985
|
+
}
|
|
51859
51986
|
/**
|
|
51860
51987
|
* Marks a symbol as type-only if its declaration is syntactically type-only.
|
|
51861
51988
|
* If it is not itself marked type-only, but resolves to a type-only alias
|
|
@@ -51901,19 +52028,25 @@ var ts;
|
|
|
51901
52028
|
return !!aliasDeclarationLinks.typeOnlyDeclaration;
|
|
51902
52029
|
}
|
|
51903
52030
|
/** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
|
|
51904
|
-
function getTypeOnlyAliasDeclaration(symbol) {
|
|
52031
|
+
function getTypeOnlyAliasDeclaration(symbol, include) {
|
|
51905
52032
|
if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
|
|
51906
52033
|
return undefined;
|
|
51907
52034
|
}
|
|
51908
52035
|
var links = getSymbolLinks(symbol);
|
|
51909
|
-
|
|
52036
|
+
if (include === undefined) {
|
|
52037
|
+
return links.typeOnlyDeclaration || undefined;
|
|
52038
|
+
}
|
|
52039
|
+
if (links.typeOnlyDeclaration) {
|
|
52040
|
+
return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
|
|
52041
|
+
}
|
|
52042
|
+
return undefined;
|
|
51910
52043
|
}
|
|
51911
52044
|
function markExportAsReferenced(node) {
|
|
51912
52045
|
var symbol = getSymbolOfNode(node);
|
|
51913
52046
|
var target = resolveAlias(symbol);
|
|
51914
52047
|
if (target) {
|
|
51915
52048
|
var markAlias = target === unknownSymbol ||
|
|
51916
|
-
((target
|
|
52049
|
+
((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
|
|
51917
52050
|
if (markAlias) {
|
|
51918
52051
|
markAliasSymbolAsReferenced(symbol);
|
|
51919
52052
|
}
|
|
@@ -51933,8 +52066,7 @@ var ts;
|
|
|
51933
52066
|
// This way a chain of imports can be elided if ultimately the final input is only used in a type
|
|
51934
52067
|
// position.
|
|
51935
52068
|
if (ts.isInternalModuleImportEqualsDeclaration(node)) {
|
|
51936
|
-
|
|
51937
|
-
if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
|
|
52069
|
+
if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
|
|
51938
52070
|
// import foo = <symbol>
|
|
51939
52071
|
checkExpressionCached(node.moduleReference);
|
|
51940
52072
|
}
|
|
@@ -52756,7 +52888,7 @@ var ts;
|
|
|
52756
52888
|
}
|
|
52757
52889
|
function symbolIsValue(symbol, includeTypeOnlyMembers) {
|
|
52758
52890
|
return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
|
|
52759
|
-
symbol.flags & 2097152 /* SymbolFlags.Alias */ &&
|
|
52891
|
+
symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
|
|
52760
52892
|
}
|
|
52761
52893
|
function findConstructorDeclaration(node) {
|
|
52762
52894
|
var members = node.members;
|
|
@@ -53025,8 +53157,10 @@ var ts;
|
|
|
53025
53157
|
return true;
|
|
53026
53158
|
}
|
|
53027
53159
|
// Qualify if the symbol from symbol table has same meaning as expected
|
|
53028
|
-
|
|
53029
|
-
|
|
53160
|
+
var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
|
|
53161
|
+
symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
|
|
53162
|
+
var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
|
|
53163
|
+
if (flags & meaning) {
|
|
53030
53164
|
qualify = true;
|
|
53031
53165
|
return true;
|
|
53032
53166
|
}
|
|
@@ -55338,7 +55472,7 @@ var ts;
|
|
|
55338
55472
|
// export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
|
|
55339
55473
|
var indices = ts.indicesOf(statements);
|
|
55340
55474
|
var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
|
|
55341
|
-
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
|
|
55475
|
+
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
|
|
55342
55476
|
for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
|
|
55343
55477
|
var index_1 = associatedIndices_1[_i];
|
|
55344
55478
|
statements[index_1] = addExportModifier(statements[index_1]);
|
|
@@ -55372,15 +55506,6 @@ var ts;
|
|
|
55372
55506
|
}
|
|
55373
55507
|
return statements;
|
|
55374
55508
|
}
|
|
55375
|
-
function canHaveExportModifier(node) {
|
|
55376
|
-
return ts.isEnumDeclaration(node) ||
|
|
55377
|
-
ts.isVariableStatement(node) ||
|
|
55378
|
-
ts.isFunctionDeclaration(node) ||
|
|
55379
|
-
ts.isClassDeclaration(node) ||
|
|
55380
|
-
(ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
|
|
55381
|
-
ts.isInterfaceDeclaration(node) ||
|
|
55382
|
-
isTypeDeclaration(node);
|
|
55383
|
-
}
|
|
55384
55509
|
function addExportModifier(node) {
|
|
55385
55510
|
var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
|
|
55386
55511
|
return ts.factory.updateModifiers(node, flags);
|
|
@@ -55627,7 +55752,7 @@ var ts;
|
|
|
55627
55752
|
(ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
|
|
55628
55753
|
if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
|
|
55629
55754
|
enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
|
|
55630
|
-
canHaveExportModifier(node)) {
|
|
55755
|
+
ts.canHaveExportModifier(node)) {
|
|
55631
55756
|
// Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
|
|
55632
55757
|
newModifierFlags |= 1 /* ModifierFlags.Export */;
|
|
55633
55758
|
}
|
|
@@ -55683,7 +55808,7 @@ var ts;
|
|
|
55683
55808
|
return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
|
|
55684
55809
|
}
|
|
55685
55810
|
function isTypeOnlyNamespace(symbol) {
|
|
55686
|
-
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m)
|
|
55811
|
+
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
|
|
55687
55812
|
}
|
|
55688
55813
|
function serializeModule(symbol, symbolName, modifierFlags) {
|
|
55689
55814
|
var members = getNamespaceMembersForSerialization(symbol);
|
|
@@ -57903,7 +58028,7 @@ var ts;
|
|
|
57903
58028
|
links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
|
|
57904
58029
|
: isDuplicatedCommonJSExport(symbol.declarations) ? autoType
|
|
57905
58030
|
: declaredType ? declaredType
|
|
57906
|
-
: targetSymbol
|
|
58031
|
+
: getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
|
|
57907
58032
|
: errorType;
|
|
57908
58033
|
}
|
|
57909
58034
|
return links.type;
|
|
@@ -59786,7 +59911,20 @@ var ts;
|
|
|
59786
59911
|
return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
|
|
59787
59912
|
}
|
|
59788
59913
|
function isGenericMappedType(type) {
|
|
59789
|
-
|
|
59914
|
+
if (ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) {
|
|
59915
|
+
var constraint = getConstraintTypeFromMappedType(type);
|
|
59916
|
+
if (isGenericIndexType(constraint)) {
|
|
59917
|
+
return true;
|
|
59918
|
+
}
|
|
59919
|
+
// A mapped type is generic if the 'as' clause references generic types other than the iteration type.
|
|
59920
|
+
// To determine this, we substitute the constraint type (that we now know isn't generic) for the iteration
|
|
59921
|
+
// type and check whether the resulting type is generic.
|
|
59922
|
+
var nameType = getNameTypeFromMappedType(type);
|
|
59923
|
+
if (nameType && isGenericIndexType(instantiateType(nameType, makeUnaryTypeMapper(getTypeParameterFromMappedType(type), constraint)))) {
|
|
59924
|
+
return true;
|
|
59925
|
+
}
|
|
59926
|
+
}
|
|
59927
|
+
return false;
|
|
59790
59928
|
}
|
|
59791
59929
|
function resolveStructuredTypeMembers(type) {
|
|
59792
59930
|
if (!type.members) {
|
|
@@ -60256,7 +60394,7 @@ var ts;
|
|
|
60256
60394
|
var indexTypes;
|
|
60257
60395
|
var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
|
|
60258
60396
|
// Flags we want to propagate to the result if they exist in all source symbols
|
|
60259
|
-
var optionalFlag
|
|
60397
|
+
var optionalFlag;
|
|
60260
60398
|
var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
|
|
60261
60399
|
var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
|
|
60262
60400
|
var mergedInstantiations = false;
|
|
@@ -60267,11 +60405,14 @@ var ts;
|
|
|
60267
60405
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
60268
60406
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
60269
60407
|
if (prop) {
|
|
60270
|
-
if (
|
|
60271
|
-
optionalFlag
|
|
60272
|
-
|
|
60273
|
-
|
|
60274
|
-
|
|
60408
|
+
if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
|
|
60409
|
+
optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
|
|
60410
|
+
if (isUnion) {
|
|
60411
|
+
optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
|
|
60412
|
+
}
|
|
60413
|
+
else {
|
|
60414
|
+
optionalFlag &= prop.flags;
|
|
60415
|
+
}
|
|
60275
60416
|
}
|
|
60276
60417
|
if (!singleProp) {
|
|
60277
60418
|
singleProp = prop;
|
|
@@ -60390,7 +60531,7 @@ var ts;
|
|
|
60390
60531
|
propTypes.push(type);
|
|
60391
60532
|
}
|
|
60392
60533
|
ts.addRange(propTypes, indexTypes);
|
|
60393
|
-
var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
|
|
60534
|
+
var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
|
|
60394
60535
|
result.containingType = containingType;
|
|
60395
60536
|
if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
|
|
60396
60537
|
result.valueDeclaration = firstValueDeclaration;
|
|
@@ -63103,8 +63244,14 @@ var ts;
|
|
|
63103
63244
|
return getStringLiteralType(text);
|
|
63104
63245
|
}
|
|
63105
63246
|
newTexts.push(text);
|
|
63106
|
-
if (ts.every(newTexts, function (t) { return t === ""; })
|
|
63107
|
-
return
|
|
63247
|
+
if (ts.every(newTexts, function (t) { return t === ""; })) {
|
|
63248
|
+
if (ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
|
|
63249
|
+
return stringType;
|
|
63250
|
+
}
|
|
63251
|
+
// Normalize `${Mapping<xxx>}` into Mapping<xxx>
|
|
63252
|
+
if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
|
|
63253
|
+
return newTypes[0];
|
|
63254
|
+
}
|
|
63108
63255
|
}
|
|
63109
63256
|
var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
|
|
63110
63257
|
var type = templateLiteralTypes.get(id);
|
|
@@ -63163,12 +63310,14 @@ var ts;
|
|
|
63163
63310
|
}
|
|
63164
63311
|
function getStringMappingType(symbol, type) {
|
|
63165
63312
|
return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
63166
|
-
|
|
63167
|
-
|
|
63168
|
-
|
|
63169
|
-
type.flags &
|
|
63170
|
-
type.flags &
|
|
63171
|
-
|
|
63313
|
+
type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
63314
|
+
type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
63315
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
63316
|
+
type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
|
|
63317
|
+
type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
|
|
63318
|
+
// This handles Mapping<`${number}`> and Mapping<`${bigint}`>
|
|
63319
|
+
isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) :
|
|
63320
|
+
type;
|
|
63172
63321
|
}
|
|
63173
63322
|
function applyStringMapping(symbol, str) {
|
|
63174
63323
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -63333,7 +63482,18 @@ var ts;
|
|
|
63333
63482
|
return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
|
|
63334
63483
|
}
|
|
63335
63484
|
errorIfWritingToReadonlyIndex(indexInfo);
|
|
63336
|
-
|
|
63485
|
+
// When accessing an enum object with its own type,
|
|
63486
|
+
// e.g. E[E.A] for enum E { A }, undefined shouldn't
|
|
63487
|
+
// be included in the result type
|
|
63488
|
+
if ((accessFlags & 1 /* AccessFlags.IncludeUndefined */) &&
|
|
63489
|
+
!(objectType.symbol &&
|
|
63490
|
+
objectType.symbol.flags & (256 /* SymbolFlags.RegularEnum */ | 128 /* SymbolFlags.ConstEnum */) &&
|
|
63491
|
+
(indexType.symbol &&
|
|
63492
|
+
indexType.flags & 1024 /* TypeFlags.EnumLiteral */ &&
|
|
63493
|
+
getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
|
|
63494
|
+
return getUnionType([indexInfo.type, undefinedType]);
|
|
63495
|
+
}
|
|
63496
|
+
return indexInfo.type;
|
|
63337
63497
|
}
|
|
63338
63498
|
if (indexType.flags & 131072 /* TypeFlags.Never */) {
|
|
63339
63499
|
return neverType;
|
|
@@ -63436,10 +63596,11 @@ var ts;
|
|
|
63436
63596
|
accessNode;
|
|
63437
63597
|
}
|
|
63438
63598
|
function isPatternLiteralPlaceholderType(type) {
|
|
63439
|
-
return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) ||
|
|
63599
|
+
return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || isPatternLiteralType(type);
|
|
63440
63600
|
}
|
|
63441
63601
|
function isPatternLiteralType(type) {
|
|
63442
|
-
return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType)
|
|
63602
|
+
return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType) ||
|
|
63603
|
+
!!(type.flags & 268435456 /* TypeFlags.StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
63443
63604
|
}
|
|
63444
63605
|
function isGenericType(type) {
|
|
63445
63606
|
return !!getGenericObjectFlags(type);
|
|
@@ -63718,18 +63879,23 @@ var ts;
|
|
|
63718
63879
|
var result;
|
|
63719
63880
|
var extraTypes;
|
|
63720
63881
|
var tailCount = 0;
|
|
63721
|
-
|
|
63882
|
+
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63883
|
+
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63884
|
+
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63885
|
+
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63886
|
+
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63887
|
+
while (true) {
|
|
63722
63888
|
if (tailCount === 1000) {
|
|
63723
63889
|
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
63724
63890
|
result = errorType;
|
|
63725
|
-
|
|
63891
|
+
break;
|
|
63726
63892
|
}
|
|
63727
63893
|
var isUnwrapped = isTypicalNondistributiveConditional(root);
|
|
63728
63894
|
var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
|
|
63729
63895
|
var checkTypeInstantiable = isGenericType(checkType);
|
|
63730
63896
|
var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
|
|
63731
63897
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
63732
|
-
return
|
|
63898
|
+
return wildcardType;
|
|
63733
63899
|
}
|
|
63734
63900
|
var combinedMapper = void 0;
|
|
63735
63901
|
if (root.inferTypeParameters) {
|
|
@@ -63762,11 +63928,7 @@ var ts;
|
|
|
63762
63928
|
}
|
|
63763
63929
|
}
|
|
63764
63930
|
}
|
|
63765
|
-
|
|
63766
|
-
// if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
|
|
63767
|
-
// "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
|
|
63768
|
-
// so in those cases we refain from performing inference and retain the uninfered type parameter
|
|
63769
|
-
if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
|
|
63931
|
+
if (!checkTypeInstantiable) {
|
|
63770
63932
|
// We don't want inferences from constraints as they may cause us to eagerly resolve the
|
|
63771
63933
|
// conditional type instead of deferring resolution. Also, we always want strict function
|
|
63772
63934
|
// types rules (i.e. proper contravariance) for inferences.
|
|
@@ -63798,14 +63960,14 @@ var ts;
|
|
|
63798
63960
|
var newRoot = falseType_1.root;
|
|
63799
63961
|
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
63800
63962
|
root = newRoot;
|
|
63801
|
-
|
|
63963
|
+
continue;
|
|
63802
63964
|
}
|
|
63803
63965
|
if (canTailRecurse(falseType_1, mapper)) {
|
|
63804
|
-
|
|
63966
|
+
continue;
|
|
63805
63967
|
}
|
|
63806
63968
|
}
|
|
63807
63969
|
result = instantiateType(falseType_1, mapper);
|
|
63808
|
-
|
|
63970
|
+
break;
|
|
63809
63971
|
}
|
|
63810
63972
|
// Return trueType for a definitely true extends check. We check instantiations of the two
|
|
63811
63973
|
// types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
|
|
@@ -63816,10 +63978,10 @@ var ts;
|
|
|
63816
63978
|
var trueType_1 = getTypeFromTypeNode(root.node.trueType);
|
|
63817
63979
|
var trueMapper = combinedMapper || mapper;
|
|
63818
63980
|
if (canTailRecurse(trueType_1, trueMapper)) {
|
|
63819
|
-
|
|
63981
|
+
continue;
|
|
63820
63982
|
}
|
|
63821
63983
|
result = instantiateType(trueType_1, trueMapper);
|
|
63822
|
-
|
|
63984
|
+
break;
|
|
63823
63985
|
}
|
|
63824
63986
|
}
|
|
63825
63987
|
// Return a deferred type for a check that is neither definitely true nor definitely false
|
|
@@ -63831,19 +63993,7 @@ var ts;
|
|
|
63831
63993
|
result.combinedMapper = combinedMapper;
|
|
63832
63994
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
63833
63995
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
|
|
63834
|
-
|
|
63835
|
-
};
|
|
63836
|
-
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63837
|
-
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63838
|
-
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63839
|
-
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63840
|
-
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63841
|
-
while (true) {
|
|
63842
|
-
var state_6 = _loop_20();
|
|
63843
|
-
if (typeof state_6 === "object")
|
|
63844
|
-
return state_6.value;
|
|
63845
|
-
if (state_6 === "break")
|
|
63846
|
-
break;
|
|
63996
|
+
break;
|
|
63847
63997
|
}
|
|
63848
63998
|
return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
|
|
63849
63999
|
// We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
|
|
@@ -66297,7 +66447,7 @@ var ts;
|
|
|
66297
66447
|
return 0 /* Ternary.False */;
|
|
66298
66448
|
}
|
|
66299
66449
|
}
|
|
66300
|
-
var isPerformingCommonPropertyChecks = (relation !== comparableRelation ||
|
|
66450
|
+
var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
|
|
66301
66451
|
!(intersectionState & 2 /* IntersectionState.Target */) &&
|
|
66302
66452
|
source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
|
|
66303
66453
|
target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
|
|
@@ -66325,27 +66475,6 @@ var ts;
|
|
|
66325
66475
|
var result_7 = skipCaching ?
|
|
66326
66476
|
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
66327
66477
|
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
66328
|
-
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
66329
|
-
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
66330
|
-
// examples that all should be errors, but aren't without this extra property check:
|
|
66331
|
-
//
|
|
66332
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
66333
|
-
//
|
|
66334
|
-
// declare let wrong: { a: { y: string } };
|
|
66335
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
66336
|
-
//
|
|
66337
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
66338
|
-
// x = y; // Mismatched property in source intersection
|
|
66339
|
-
// }
|
|
66340
|
-
//
|
|
66341
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
66342
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
66343
|
-
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
66344
|
-
isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) {
|
|
66345
|
-
inPropertyCheck = true;
|
|
66346
|
-
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
|
|
66347
|
-
inPropertyCheck = false;
|
|
66348
|
-
}
|
|
66349
66478
|
if (result_7) {
|
|
66350
66479
|
return result_7;
|
|
66351
66480
|
}
|
|
@@ -66457,7 +66586,7 @@ var ts;
|
|
|
66457
66586
|
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
|
66458
66587
|
checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
|
|
66459
66588
|
}
|
|
66460
|
-
var
|
|
66589
|
+
var _loop_20 = function (prop) {
|
|
66461
66590
|
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
|
66462
66591
|
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
|
66463
66592
|
if (reportErrors) {
|
|
@@ -66520,9 +66649,9 @@ var ts;
|
|
|
66520
66649
|
};
|
|
66521
66650
|
for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
|
|
66522
66651
|
var prop = _b[_i];
|
|
66523
|
-
var
|
|
66524
|
-
if (typeof
|
|
66525
|
-
return
|
|
66652
|
+
var state_6 = _loop_20(prop);
|
|
66653
|
+
if (typeof state_6 === "object")
|
|
66654
|
+
return state_6.value;
|
|
66526
66655
|
}
|
|
66527
66656
|
return false;
|
|
66528
66657
|
}
|
|
@@ -66743,8 +66872,7 @@ var ts;
|
|
|
66743
66872
|
if (overflow) {
|
|
66744
66873
|
return 0 /* Ternary.False */;
|
|
66745
66874
|
}
|
|
66746
|
-
var
|
|
66747
|
-
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66875
|
+
var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66748
66876
|
var entry = relation.get(id);
|
|
66749
66877
|
if (entry !== undefined) {
|
|
66750
66878
|
if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
|
|
@@ -66774,7 +66902,7 @@ var ts;
|
|
|
66774
66902
|
// A key that starts with "*" is an indication that we have type references that reference constrained
|
|
66775
66903
|
// type parameters. For such keys we also check against the key we would have gotten if all type parameters
|
|
66776
66904
|
// were unconstrained.
|
|
66777
|
-
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target,
|
|
66905
|
+
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
|
|
66778
66906
|
for (var i = 0; i < maybeCount; i++) {
|
|
66779
66907
|
// If source and target are already being compared, consider them related with assumptions
|
|
66780
66908
|
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
|
|
@@ -66861,7 +66989,7 @@ var ts;
|
|
|
66861
66989
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66862
66990
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66863
66991
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66864
|
-
if (
|
|
66992
|
+
if (relation !== identityRelation) {
|
|
66865
66993
|
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66866
66994
|
// the constituents. When an intersection type contains instantiable types with union type
|
|
66867
66995
|
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
@@ -66875,10 +67003,33 @@ var ts;
|
|
|
66875
67003
|
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66876
67004
|
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66877
67005
|
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66878
|
-
|
|
66879
|
-
|
|
66880
|
-
|
|
66881
|
-
|
|
67006
|
+
if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
|
|
67007
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
|
|
67008
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
67009
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
67010
|
+
result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
67011
|
+
}
|
|
67012
|
+
}
|
|
67013
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
67014
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
67015
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
67016
|
+
//
|
|
67017
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
67018
|
+
//
|
|
67019
|
+
// declare let wrong: { a: { y: string } };
|
|
67020
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
67021
|
+
//
|
|
67022
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
67023
|
+
// x = y; // Mismatched property in source intersection
|
|
67024
|
+
// }
|
|
67025
|
+
//
|
|
67026
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
67027
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
67028
|
+
if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
|
|
67029
|
+
isNonGenericObjectType(target) && !isArrayOrTupleType(target) && source.flags & 2097152 /* TypeFlags.Intersection */ && getApparentType(source).flags & 3670016 /* TypeFlags.StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 262144 /* ObjectFlags.NonInferrableType */); }))) {
|
|
67030
|
+
inPropertyCheck = true;
|
|
67031
|
+
result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67032
|
+
inPropertyCheck = false;
|
|
66882
67033
|
}
|
|
66883
67034
|
}
|
|
66884
67035
|
if (result) {
|
|
@@ -66887,9 +67038,6 @@ var ts;
|
|
|
66887
67038
|
return result;
|
|
66888
67039
|
}
|
|
66889
67040
|
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
66890
|
-
if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
|
|
66891
|
-
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
66892
|
-
}
|
|
66893
67041
|
var result;
|
|
66894
67042
|
var originalErrorInfo;
|
|
66895
67043
|
var varianceCheckFailed = false;
|
|
@@ -66990,7 +67138,7 @@ var ts;
|
|
|
66990
67138
|
// with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
|
|
66991
67139
|
var constraint = getConstraintOfTypeParameter(source);
|
|
66992
67140
|
if (constraint && hasNonCircularBaseConstraint(source)) {
|
|
66993
|
-
while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
|
|
67141
|
+
while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
|
|
66994
67142
|
if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
|
|
66995
67143
|
return result;
|
|
66996
67144
|
}
|
|
@@ -67513,11 +67661,11 @@ var ts;
|
|
|
67513
67661
|
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
|
67514
67662
|
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
|
67515
67663
|
var matchingTypes = [];
|
|
67516
|
-
var
|
|
67664
|
+
var _loop_21 = function (combination) {
|
|
67517
67665
|
var hasMatch = false;
|
|
67518
67666
|
outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
|
|
67519
67667
|
var type = _d[_c];
|
|
67520
|
-
var
|
|
67668
|
+
var _loop_22 = function (i) {
|
|
67521
67669
|
var sourceProperty = sourcePropertiesFiltered[i];
|
|
67522
67670
|
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
|
67523
67671
|
if (!targetProperty)
|
|
@@ -67533,8 +67681,8 @@ var ts;
|
|
|
67533
67681
|
}
|
|
67534
67682
|
};
|
|
67535
67683
|
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
|
67536
|
-
var
|
|
67537
|
-
switch (
|
|
67684
|
+
var state_8 = _loop_22(i);
|
|
67685
|
+
switch (state_8) {
|
|
67538
67686
|
case "continue-outer": continue outer;
|
|
67539
67687
|
}
|
|
67540
67688
|
}
|
|
@@ -67547,9 +67695,9 @@ var ts;
|
|
|
67547
67695
|
};
|
|
67548
67696
|
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
|
67549
67697
|
var combination = discriminantCombinations_1[_a];
|
|
67550
|
-
var
|
|
67551
|
-
if (typeof
|
|
67552
|
-
return
|
|
67698
|
+
var state_7 = _loop_21(combination);
|
|
67699
|
+
if (typeof state_7 === "object")
|
|
67700
|
+
return state_7.value;
|
|
67553
67701
|
}
|
|
67554
67702
|
// Compare the remaining non-discriminant properties of each match.
|
|
67555
67703
|
var result = -1 /* Ternary.True */;
|
|
@@ -67646,7 +67794,7 @@ var ts;
|
|
|
67646
67794
|
return 0 /* Ternary.False */;
|
|
67647
67795
|
}
|
|
67648
67796
|
// When checking for comparability, be more lenient with optional properties.
|
|
67649
|
-
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67797
|
+
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67650
67798
|
// TypeScript 1.0 spec (April 2014): 3.8.3
|
|
67651
67799
|
// S is a subtype of a type T, and T is a supertype of S if ...
|
|
67652
67800
|
// S' and T are object types and, for each member M in T..
|
|
@@ -68254,7 +68402,7 @@ var ts;
|
|
|
68254
68402
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
|
68255
68403
|
links.variances = ts.emptyArray;
|
|
68256
68404
|
var variances = [];
|
|
68257
|
-
var
|
|
68405
|
+
var _loop_23 = function (tp) {
|
|
68258
68406
|
var modifiers = getVarianceModifiers(tp);
|
|
68259
68407
|
var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
|
|
68260
68408
|
modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
|
|
@@ -68292,7 +68440,7 @@ var ts;
|
|
|
68292
68440
|
};
|
|
68293
68441
|
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
|
|
68294
68442
|
var tp = typeParameters_2[_i];
|
|
68295
|
-
|
|
68443
|
+
_loop_23(tp);
|
|
68296
68444
|
}
|
|
68297
68445
|
links.variances = variances;
|
|
68298
68446
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
|
|
@@ -68746,8 +68894,7 @@ var ts;
|
|
|
68746
68894
|
return !!(type.flags & 109440 /* TypeFlags.Unit */);
|
|
68747
68895
|
}
|
|
68748
68896
|
function isUnitLikeType(type) {
|
|
68749
|
-
return
|
|
68750
|
-
!!(type.flags & 109440 /* TypeFlags.Unit */);
|
|
68897
|
+
return isUnitType(getBaseConstraintOrType(type));
|
|
68751
68898
|
}
|
|
68752
68899
|
function extractUnitType(type) {
|
|
68753
68900
|
return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type;
|
|
@@ -69626,7 +69773,7 @@ var ts;
|
|
|
69626
69773
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
69627
69774
|
}
|
|
69628
69775
|
function isMemberOfStringMapping(source, target) {
|
|
69629
|
-
if (target.flags & (4 /* TypeFlags.String */ |
|
|
69776
|
+
if (target.flags & (4 /* TypeFlags.String */ | 1 /* TypeFlags.Any */)) {
|
|
69630
69777
|
return true;
|
|
69631
69778
|
}
|
|
69632
69779
|
if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
|
|
@@ -70250,7 +70397,7 @@ var ts;
|
|
|
70250
70397
|
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
70251
70398
|
// succeed. That would be a pointless and confusing outcome.
|
|
70252
70399
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
70253
|
-
var
|
|
70400
|
+
var _loop_24 = function (i) {
|
|
70254
70401
|
var source_1 = matches ? matches[i] : neverType;
|
|
70255
70402
|
var target_3 = types[i];
|
|
70256
70403
|
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
@@ -70300,7 +70447,7 @@ var ts;
|
|
|
70300
70447
|
inferFromTypes(source_1, target_3);
|
|
70301
70448
|
};
|
|
70302
70449
|
for (var i = 0; i < types.length; i++) {
|
|
70303
|
-
|
|
70450
|
+
_loop_24(i);
|
|
70304
70451
|
}
|
|
70305
70452
|
}
|
|
70306
70453
|
}
|
|
@@ -70752,7 +70899,7 @@ var ts;
|
|
|
70752
70899
|
}
|
|
70753
70900
|
if (ts.isEntityNameExpression(node.argumentExpression)) {
|
|
70754
70901
|
var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
|
|
70755
|
-
if (!symbol || !isConstVariable(symbol))
|
|
70902
|
+
if (!symbol || !(isConstVariable(symbol) || (symbol.flags & 8 /* SymbolFlags.EnumMember */)))
|
|
70756
70903
|
return undefined;
|
|
70757
70904
|
var declaration = symbol.valueDeclaration;
|
|
70758
70905
|
if (declaration === undefined)
|
|
@@ -70766,7 +70913,12 @@ var ts;
|
|
|
70766
70913
|
}
|
|
70767
70914
|
if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
|
|
70768
70915
|
var initializer = ts.getEffectiveInitializer(declaration);
|
|
70769
|
-
|
|
70916
|
+
if (initializer) {
|
|
70917
|
+
return tryGetNameFromType(getTypeOfExpression(initializer));
|
|
70918
|
+
}
|
|
70919
|
+
if (ts.isEnumMember(declaration)) {
|
|
70920
|
+
return ts.getTextOfPropertyName(declaration.name);
|
|
70921
|
+
}
|
|
70770
70922
|
}
|
|
70771
70923
|
}
|
|
70772
70924
|
return undefined;
|
|
@@ -70824,7 +70976,7 @@ var ts;
|
|
|
70824
70976
|
function mapTypesByKeyProperty(types, name) {
|
|
70825
70977
|
var map = new ts.Map();
|
|
70826
70978
|
var count = 0;
|
|
70827
|
-
var
|
|
70979
|
+
var _loop_25 = function (type) {
|
|
70828
70980
|
if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
|
|
70829
70981
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
70830
70982
|
if (discriminant) {
|
|
@@ -70850,9 +71002,9 @@ var ts;
|
|
|
70850
71002
|
};
|
|
70851
71003
|
for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
|
|
70852
71004
|
var type = types_15[_i];
|
|
70853
|
-
var
|
|
70854
|
-
if (typeof
|
|
70855
|
-
return
|
|
71005
|
+
var state_9 = _loop_25(type);
|
|
71006
|
+
if (typeof state_9 === "object")
|
|
71007
|
+
return state_9.value;
|
|
70856
71008
|
}
|
|
70857
71009
|
return count >= 10 && count * 2 >= types.length ? map : undefined;
|
|
70858
71010
|
}
|
|
@@ -71449,6 +71601,7 @@ var ts;
|
|
|
71449
71601
|
ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
|
|
71450
71602
|
}
|
|
71451
71603
|
function getExplicitTypeOfSymbol(symbol, diagnostic) {
|
|
71604
|
+
symbol = resolveSymbol(symbol);
|
|
71452
71605
|
if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) {
|
|
71453
71606
|
return getTypeOfSymbol(symbol);
|
|
71454
71607
|
}
|
|
@@ -71487,7 +71640,7 @@ var ts;
|
|
|
71487
71640
|
switch (node.kind) {
|
|
71488
71641
|
case 79 /* SyntaxKind.Identifier */:
|
|
71489
71642
|
var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
|
|
71490
|
-
return getExplicitTypeOfSymbol(symbol
|
|
71643
|
+
return getExplicitTypeOfSymbol(symbol, diagnostic);
|
|
71491
71644
|
case 108 /* SyntaxKind.ThisKeyword */:
|
|
71492
71645
|
return getExplicitThisType(node);
|
|
71493
71646
|
case 106 /* SyntaxKind.SuperKeyword */:
|
|
@@ -71974,7 +72127,7 @@ var ts;
|
|
|
71974
72127
|
type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
|
|
71975
72128
|
}
|
|
71976
72129
|
else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
|
|
71977
|
-
type =
|
|
72130
|
+
type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
|
|
71978
72131
|
}
|
|
71979
72132
|
else {
|
|
71980
72133
|
if (strictNullChecks) {
|
|
@@ -72255,7 +72408,7 @@ var ts;
|
|
|
72255
72408
|
!!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
|
|
72256
72409
|
!!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
|
|
72257
72410
|
}
|
|
72258
|
-
function
|
|
72411
|
+
function narrowTypeByInKeyword(type, nameType, assumeTrue) {
|
|
72259
72412
|
var name = getPropertyNameFromType(nameType);
|
|
72260
72413
|
var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
|
|
72261
72414
|
if (isKnownProperty) {
|
|
@@ -72336,7 +72489,7 @@ var ts;
|
|
|
72336
72489
|
return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
|
|
72337
72490
|
}
|
|
72338
72491
|
if (isMatchingReference(reference, target)) {
|
|
72339
|
-
return
|
|
72492
|
+
return narrowTypeByInKeyword(type, leftType, assumeTrue);
|
|
72340
72493
|
}
|
|
72341
72494
|
}
|
|
72342
72495
|
break;
|
|
@@ -72525,7 +72678,7 @@ var ts;
|
|
|
72525
72678
|
neverType;
|
|
72526
72679
|
});
|
|
72527
72680
|
}
|
|
72528
|
-
function
|
|
72681
|
+
function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
|
|
72529
72682
|
var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
|
|
72530
72683
|
if (!witnesses) {
|
|
72531
72684
|
return type;
|
|
@@ -72913,15 +73066,15 @@ var ts;
|
|
|
72913
73066
|
});
|
|
72914
73067
|
}
|
|
72915
73068
|
function markAliasReferenced(symbol, location) {
|
|
72916
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
73069
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
72917
73070
|
var target = resolveAlias(symbol);
|
|
72918
|
-
if (target
|
|
73071
|
+
if (getAllSymbolFlags(target) & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */)) {
|
|
72919
73072
|
// An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
|
|
72920
73073
|
// (because the const enum value will not be inlined), or if (2) the alias is an export
|
|
72921
73074
|
// of a const enum declaration that will be preserved.
|
|
72922
73075
|
if (compilerOptions.isolatedModules ||
|
|
72923
73076
|
ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) ||
|
|
72924
|
-
!isConstEnumOrConstEnumOnlyModule(target)) {
|
|
73077
|
+
!isConstEnumOrConstEnumOnlyModule(getExportSymbolOfValueSymbolIfExported(target))) {
|
|
72925
73078
|
markAliasSymbolAsReferenced(symbol);
|
|
72926
73079
|
}
|
|
72927
73080
|
else {
|
|
@@ -73149,7 +73302,7 @@ var ts;
|
|
|
73149
73302
|
// We only look for uninitialized variables in strict null checking mode, and only when we can analyze
|
|
73150
73303
|
// the entire control flow graph from the variable's declaration (i.e. when the flow container and
|
|
73151
73304
|
// declaration container are the same).
|
|
73152
|
-
var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports ||
|
|
73305
|
+
var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) ||
|
|
73153
73306
|
type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 ||
|
|
73154
73307
|
isInTypeQuery(node) || node.parent.kind === 278 /* SyntaxKind.ExportSpecifier */) ||
|
|
73155
73308
|
node.parent.kind === 232 /* SyntaxKind.NonNullExpression */ ||
|
|
@@ -73178,6 +73331,12 @@ var ts;
|
|
|
73178
73331
|
}
|
|
73179
73332
|
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
|
|
73180
73333
|
}
|
|
73334
|
+
function isSameScopedBindingElement(node, declaration) {
|
|
73335
|
+
if (ts.isBindingElement(declaration)) {
|
|
73336
|
+
var bindingElement = ts.findAncestor(node, ts.isBindingElement);
|
|
73337
|
+
return bindingElement && ts.getRootDeclaration(bindingElement) === ts.getRootDeclaration(declaration);
|
|
73338
|
+
}
|
|
73339
|
+
}
|
|
73181
73340
|
function shouldMarkIdentifierAliasReferenced(node) {
|
|
73182
73341
|
var _a;
|
|
73183
73342
|
var parent = node.parent;
|
|
@@ -73519,12 +73678,17 @@ var ts;
|
|
|
73519
73678
|
var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true);
|
|
73520
73679
|
var container = immediateContainer;
|
|
73521
73680
|
var needToCaptureLexicalThis = false;
|
|
73681
|
+
var inAsyncFunction = false;
|
|
73522
73682
|
// adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
|
|
73523
73683
|
if (!isCallExpression) {
|
|
73524
73684
|
while (container && container.kind === 216 /* SyntaxKind.ArrowFunction */) {
|
|
73685
|
+
if (ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
|
|
73686
|
+
inAsyncFunction = true;
|
|
73525
73687
|
container = ts.getSuperContainer(container, /*stopOnFunctions*/ true);
|
|
73526
73688
|
needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */;
|
|
73527
73689
|
}
|
|
73690
|
+
if (container && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
|
|
73691
|
+
inAsyncFunction = true;
|
|
73528
73692
|
}
|
|
73529
73693
|
var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
|
|
73530
73694
|
var nodeCheckFlag = 0;
|
|
@@ -73630,12 +73794,12 @@ var ts;
|
|
|
73630
73794
|
// as a call expression cannot be used as the target of a destructuring assignment while a property access can.
|
|
73631
73795
|
//
|
|
73632
73796
|
// For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations.
|
|
73633
|
-
if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ &&
|
|
73797
|
+
if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && inAsyncFunction) {
|
|
73634
73798
|
if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
|
|
73635
|
-
getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.
|
|
73799
|
+
getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */;
|
|
73636
73800
|
}
|
|
73637
73801
|
else {
|
|
73638
|
-
getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.
|
|
73802
|
+
getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */;
|
|
73639
73803
|
}
|
|
73640
73804
|
}
|
|
73641
73805
|
if (needToCaptureLexicalThis) {
|
|
@@ -74331,9 +74495,10 @@ var ts;
|
|
|
74331
74495
|
function instantiateContextualType(contextualType, node, contextFlags) {
|
|
74332
74496
|
if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) {
|
|
74333
74497
|
var inferenceContext = getInferenceContext(node);
|
|
74334
|
-
// If no inferences have been made,
|
|
74335
|
-
//
|
|
74336
|
-
|
|
74498
|
+
// If no inferences have been made, and none of the type parameters for which we are inferring
|
|
74499
|
+
// specify default types, nothing is gained from instantiating as type parameters would just be
|
|
74500
|
+
// replaced with their constraints similar to the apparent type.
|
|
74501
|
+
if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
|
|
74337
74502
|
// For contextual signatures we incorporate all inferences made so far, e.g. from return
|
|
74338
74503
|
// types as well as arguments to the left in a function call.
|
|
74339
74504
|
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
@@ -77307,7 +77472,7 @@ var ts;
|
|
|
77307
77472
|
if (spreadIndex >= 0) {
|
|
77308
77473
|
// Create synthetic arguments from spreads of tuple types.
|
|
77309
77474
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
77310
|
-
var
|
|
77475
|
+
var _loop_26 = function (i) {
|
|
77311
77476
|
var arg = args[i];
|
|
77312
77477
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
77313
77478
|
var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -77324,7 +77489,7 @@ var ts;
|
|
|
77324
77489
|
}
|
|
77325
77490
|
};
|
|
77326
77491
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
77327
|
-
|
|
77492
|
+
_loop_26(i);
|
|
77328
77493
|
}
|
|
77329
77494
|
return effectiveArgs_1;
|
|
77330
77495
|
}
|
|
@@ -77653,7 +77818,7 @@ var ts;
|
|
|
77653
77818
|
var min_3 = Number.MAX_VALUE;
|
|
77654
77819
|
var minIndex = 0;
|
|
77655
77820
|
var i_1 = 0;
|
|
77656
|
-
var
|
|
77821
|
+
var _loop_27 = function (c) {
|
|
77657
77822
|
var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); };
|
|
77658
77823
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
|
|
77659
77824
|
if (diags_2) {
|
|
@@ -77671,7 +77836,7 @@ var ts;
|
|
|
77671
77836
|
};
|
|
77672
77837
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
77673
77838
|
var c = candidatesForArgumentError_1[_a];
|
|
77674
|
-
|
|
77839
|
+
_loop_27(c);
|
|
77675
77840
|
}
|
|
77676
77841
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
77677
77842
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -77829,7 +77994,7 @@ var ts;
|
|
|
77829
77994
|
}
|
|
77830
77995
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
77831
77996
|
var parameters = [];
|
|
77832
|
-
var
|
|
77997
|
+
var _loop_28 = function (i) {
|
|
77833
77998
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
77834
77999
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
77835
78000
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -77837,7 +78002,7 @@ var ts;
|
|
|
77837
78002
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
77838
78003
|
};
|
|
77839
78004
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
77840
|
-
|
|
78005
|
+
_loop_28(i);
|
|
77841
78006
|
}
|
|
77842
78007
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
77843
78008
|
var flags = 0 /* SignatureFlags.None */;
|
|
@@ -78807,7 +78972,7 @@ var ts;
|
|
|
78807
78972
|
if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
78808
78973
|
symbol = resolveAlias(symbol);
|
|
78809
78974
|
}
|
|
78810
|
-
return !!(symbol && (symbol
|
|
78975
|
+
return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
|
|
78811
78976
|
}
|
|
78812
78977
|
return false;
|
|
78813
78978
|
}
|
|
@@ -79469,7 +79634,17 @@ var ts;
|
|
|
79469
79634
|
}
|
|
79470
79635
|
function isExhaustiveSwitchStatement(node) {
|
|
79471
79636
|
var links = getNodeLinks(node);
|
|
79472
|
-
|
|
79637
|
+
if (links.isExhaustive === undefined) {
|
|
79638
|
+
links.isExhaustive = 0; // Indicate resolution is in process
|
|
79639
|
+
var exhaustive = computeExhaustiveSwitchStatement(node);
|
|
79640
|
+
if (links.isExhaustive === 0) {
|
|
79641
|
+
links.isExhaustive = exhaustive;
|
|
79642
|
+
}
|
|
79643
|
+
}
|
|
79644
|
+
else if (links.isExhaustive === 0) {
|
|
79645
|
+
links.isExhaustive = false; // Resolve circularity to false
|
|
79646
|
+
}
|
|
79647
|
+
return links.isExhaustive;
|
|
79473
79648
|
}
|
|
79474
79649
|
function computeExhaustiveSwitchStatement(node) {
|
|
79475
79650
|
if (node.expression.kind === 218 /* SyntaxKind.TypeOfExpression */) {
|
|
@@ -79477,7 +79652,7 @@ var ts;
|
|
|
79477
79652
|
if (!witnesses) {
|
|
79478
79653
|
return false;
|
|
79479
79654
|
}
|
|
79480
|
-
var operandConstraint = getBaseConstraintOrType(
|
|
79655
|
+
var operandConstraint = getBaseConstraintOrType(checkExpressionCached(node.expression.expression));
|
|
79481
79656
|
// Get the not-equal flags for all handled cases.
|
|
79482
79657
|
var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
|
|
79483
79658
|
if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) {
|
|
@@ -79487,7 +79662,7 @@ var ts;
|
|
|
79487
79662
|
// A missing not-equal flag indicates that the type wasn't handled by some case.
|
|
79488
79663
|
return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
|
|
79489
79664
|
}
|
|
79490
|
-
var type =
|
|
79665
|
+
var type = checkExpressionCached(node.expression);
|
|
79491
79666
|
if (!isLiteralType(type)) {
|
|
79492
79667
|
return false;
|
|
79493
79668
|
}
|
|
@@ -81181,6 +81356,9 @@ var ts;
|
|
|
81181
81356
|
function hasInferenceCandidates(info) {
|
|
81182
81357
|
return !!(info.candidates || info.contraCandidates);
|
|
81183
81358
|
}
|
|
81359
|
+
function hasInferenceCandidatesOrDefault(info) {
|
|
81360
|
+
return !!(info.candidates || info.contraCandidates || hasTypeParameterDefault(info.typeParameter));
|
|
81361
|
+
}
|
|
81184
81362
|
function hasOverlappingInferences(a, b) {
|
|
81185
81363
|
for (var i = 0; i < a.length; i++) {
|
|
81186
81364
|
if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
|
|
@@ -81882,7 +82060,7 @@ var ts;
|
|
|
81882
82060
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
81883
82061
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
81884
82062
|
var indexSignatureMap_1 = new ts.Map();
|
|
81885
|
-
var
|
|
82063
|
+
var _loop_29 = function (declaration) {
|
|
81886
82064
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
81887
82065
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
81888
82066
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -81897,7 +82075,7 @@ var ts;
|
|
|
81897
82075
|
};
|
|
81898
82076
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
81899
82077
|
var declaration = _a[_i];
|
|
81900
|
-
|
|
82078
|
+
_loop_29(declaration);
|
|
81901
82079
|
}
|
|
81902
82080
|
indexSignatureMap_1.forEach(function (entry) {
|
|
81903
82081
|
if (entry.declarations.length > 1) {
|
|
@@ -82174,7 +82352,7 @@ var ts;
|
|
|
82174
82352
|
}
|
|
82175
82353
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
82176
82354
|
if (symbol) {
|
|
82177
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82355
|
+
if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82178
82356
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
82179
82357
|
}
|
|
82180
82358
|
if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
|
|
@@ -82777,7 +82955,7 @@ var ts;
|
|
|
82777
82955
|
return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
|
|
82778
82956
|
}
|
|
82779
82957
|
// primitives with a `{ then() }` won't be unwrapped/adopted.
|
|
82780
|
-
if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
|
|
82958
|
+
if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
|
|
82781
82959
|
return undefined;
|
|
82782
82960
|
}
|
|
82783
82961
|
var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217
|
|
@@ -82844,7 +83022,7 @@ var ts;
|
|
|
82844
83022
|
* Determines whether a type is an object with a callable `then` member.
|
|
82845
83023
|
*/
|
|
82846
83024
|
function isThenableType(type) {
|
|
82847
|
-
if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
|
|
83025
|
+
if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
|
|
82848
83026
|
// primitive types cannot be considered "thenable" since they are not objects.
|
|
82849
83027
|
return false;
|
|
82850
83028
|
}
|
|
@@ -82878,7 +83056,7 @@ var ts;
|
|
|
82878
83056
|
// We only need `Awaited<T>` if `T` is a type variable that has no base constraint, or the base constraint of `T` is `any`, `unknown`, `{}`, `object`,
|
|
82879
83057
|
// or is promise-like.
|
|
82880
83058
|
if (baseConstraint ?
|
|
82881
|
-
baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) ||
|
|
83059
|
+
baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
|
|
82882
83060
|
maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
|
|
82883
83061
|
return true;
|
|
82884
83062
|
}
|
|
@@ -83552,7 +83730,7 @@ var ts;
|
|
|
83552
83730
|
}
|
|
83553
83731
|
function errorUnusedLocal(declaration, name, addDiagnostic) {
|
|
83554
83732
|
var node = ts.getNameOfDeclaration(declaration) || declaration;
|
|
83555
|
-
var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83733
|
+
var message = ts.isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83556
83734
|
addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
|
|
83557
83735
|
}
|
|
83558
83736
|
function isIdentifierThatStartsWithUnderscore(node) {
|
|
@@ -84982,7 +85160,16 @@ var ts;
|
|
|
84982
85160
|
var message = allowAsyncIterables
|
|
84983
85161
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
84984
85162
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
84985
|
-
|
|
85163
|
+
var suggestAwait =
|
|
85164
|
+
// for (const x of Promise<...>) or [...Promise<...>]
|
|
85165
|
+
!!getAwaitedTypeOfPromise(type)
|
|
85166
|
+
// for (const x of AsyncIterable<...>)
|
|
85167
|
+
|| (!allowAsyncIterables &&
|
|
85168
|
+
ts.isForOfStatement(errorNode.parent) &&
|
|
85169
|
+
errorNode.parent.expression === errorNode &&
|
|
85170
|
+
getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
|
|
85171
|
+
isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
|
|
85172
|
+
return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
|
|
84986
85173
|
}
|
|
84987
85174
|
/**
|
|
84988
85175
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -85497,7 +85684,7 @@ var ts;
|
|
|
85497
85684
|
var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
|
|
85498
85685
|
name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
|
|
85499
85686
|
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
85500
|
-
var
|
|
85687
|
+
var _loop_30 = function (info) {
|
|
85501
85688
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
85502
85689
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
85503
85690
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -85514,7 +85701,7 @@ var ts;
|
|
|
85514
85701
|
};
|
|
85515
85702
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
85516
85703
|
var info = indexInfos_9[_i];
|
|
85517
|
-
|
|
85704
|
+
_loop_30(info);
|
|
85518
85705
|
}
|
|
85519
85706
|
}
|
|
85520
85707
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -85522,7 +85709,7 @@ var ts;
|
|
|
85522
85709
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
85523
85710
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
|
|
85524
85711
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
85525
|
-
var
|
|
85712
|
+
var _loop_31 = function (info) {
|
|
85526
85713
|
if (info === checkInfo)
|
|
85527
85714
|
return "continue";
|
|
85528
85715
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -85537,7 +85724,7 @@ var ts;
|
|
|
85537
85724
|
};
|
|
85538
85725
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
85539
85726
|
var info = indexInfos_10[_i];
|
|
85540
|
-
|
|
85727
|
+
_loop_31(info);
|
|
85541
85728
|
}
|
|
85542
85729
|
}
|
|
85543
85730
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -85592,7 +85779,7 @@ var ts;
|
|
|
85592
85779
|
}
|
|
85593
85780
|
else {
|
|
85594
85781
|
ts.forEach(jsdocParameters, function (_a, index) {
|
|
85595
|
-
var name = _a.name;
|
|
85782
|
+
var name = _a.name, isNameFirst = _a.isNameFirst;
|
|
85596
85783
|
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
85597
85784
|
return;
|
|
85598
85785
|
}
|
|
@@ -85602,7 +85789,9 @@ var ts;
|
|
|
85602
85789
|
}
|
|
85603
85790
|
}
|
|
85604
85791
|
else {
|
|
85605
|
-
|
|
85792
|
+
if (!isNameFirst) {
|
|
85793
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
85794
|
+
}
|
|
85606
85795
|
}
|
|
85607
85796
|
});
|
|
85608
85797
|
}
|
|
@@ -85857,7 +86046,7 @@ var ts;
|
|
|
85857
86046
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
85858
86047
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
85859
86048
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
85860
|
-
var
|
|
86049
|
+
var _loop_32 = function (member) {
|
|
85861
86050
|
if (ts.hasAmbientModifier(member)) {
|
|
85862
86051
|
return "continue";
|
|
85863
86052
|
}
|
|
@@ -85874,7 +86063,7 @@ var ts;
|
|
|
85874
86063
|
};
|
|
85875
86064
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
85876
86065
|
var member = _a[_i];
|
|
85877
|
-
|
|
86066
|
+
_loop_32(member);
|
|
85878
86067
|
}
|
|
85879
86068
|
}
|
|
85880
86069
|
/**
|
|
@@ -85962,7 +86151,7 @@ var ts;
|
|
|
85962
86151
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
85963
86152
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
85964
86153
|
var issuedMemberError = false;
|
|
85965
|
-
var
|
|
86154
|
+
var _loop_33 = function (member) {
|
|
85966
86155
|
if (ts.isStatic(member)) {
|
|
85967
86156
|
return "continue";
|
|
85968
86157
|
}
|
|
@@ -85981,7 +86170,7 @@ var ts;
|
|
|
85981
86170
|
};
|
|
85982
86171
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
85983
86172
|
var member = _a[_i];
|
|
85984
|
-
|
|
86173
|
+
_loop_33(member);
|
|
85985
86174
|
}
|
|
85986
86175
|
if (!issuedMemberError) {
|
|
85987
86176
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -86052,7 +86241,7 @@ var ts;
|
|
|
86052
86241
|
var _a, _b, _c, _d;
|
|
86053
86242
|
// NOTE: assignability is checked in checkClassDeclaration
|
|
86054
86243
|
var baseProperties = getPropertiesOfType(baseType);
|
|
86055
|
-
var
|
|
86244
|
+
var _loop_34 = function (baseProperty) {
|
|
86056
86245
|
var base = getTargetSymbol(baseProperty);
|
|
86057
86246
|
if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
|
|
86058
86247
|
return "continue";
|
|
@@ -86162,8 +86351,8 @@ var ts;
|
|
|
86162
86351
|
};
|
|
86163
86352
|
basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
|
|
86164
86353
|
var baseProperty = baseProperties_1[_i];
|
|
86165
|
-
var
|
|
86166
|
-
switch (
|
|
86354
|
+
var state_10 = _loop_34(baseProperty);
|
|
86355
|
+
switch (state_10) {
|
|
86167
86356
|
case "continue-basePropertyCheck": continue basePropertyCheck;
|
|
86168
86357
|
}
|
|
86169
86358
|
}
|
|
@@ -86682,12 +86871,11 @@ var ts;
|
|
|
86682
86871
|
}
|
|
86683
86872
|
}
|
|
86684
86873
|
function checkModuleAugmentationElement(node, isGlobalAugmentation) {
|
|
86685
|
-
var _a;
|
|
86686
86874
|
switch (node.kind) {
|
|
86687
86875
|
case 240 /* SyntaxKind.VariableStatement */:
|
|
86688
86876
|
// error each individual name in variable statement instead of marking the entire variable statement
|
|
86689
|
-
for (var _i = 0,
|
|
86690
|
-
var decl =
|
|
86877
|
+
for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
|
|
86878
|
+
var decl = _a[_i];
|
|
86691
86879
|
checkModuleAugmentationElement(decl, isGlobalAugmentation);
|
|
86692
86880
|
}
|
|
86693
86881
|
break;
|
|
@@ -86703,8 +86891,8 @@ var ts;
|
|
|
86703
86891
|
case 257 /* SyntaxKind.VariableDeclaration */:
|
|
86704
86892
|
var name = node.name;
|
|
86705
86893
|
if (ts.isBindingPattern(name)) {
|
|
86706
|
-
for (var
|
|
86707
|
-
var el =
|
|
86894
|
+
for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
|
|
86895
|
+
var el = _c[_b];
|
|
86708
86896
|
// mark individual names in binding pattern
|
|
86709
86897
|
checkModuleAugmentationElement(el, isGlobalAugmentation);
|
|
86710
86898
|
}
|
|
@@ -86720,18 +86908,6 @@ var ts;
|
|
|
86720
86908
|
if (isGlobalAugmentation) {
|
|
86721
86909
|
return;
|
|
86722
86910
|
}
|
|
86723
|
-
var symbol = getSymbolOfNode(node);
|
|
86724
|
-
if (symbol) {
|
|
86725
|
-
// module augmentations cannot introduce new names on the top level scope of the module
|
|
86726
|
-
// this is done it two steps
|
|
86727
|
-
// 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error
|
|
86728
|
-
// 2. main check - report error if value declaration of the parent symbol is module augmentation)
|
|
86729
|
-
var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */);
|
|
86730
|
-
if (!reportError) {
|
|
86731
|
-
// symbol should not originate in augmentation
|
|
86732
|
-
reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
|
|
86733
|
-
}
|
|
86734
|
-
}
|
|
86735
86911
|
break;
|
|
86736
86912
|
}
|
|
86737
86913
|
}
|
|
@@ -86833,10 +87009,11 @@ var ts;
|
|
|
86833
87009
|
}
|
|
86834
87010
|
return;
|
|
86835
87011
|
}
|
|
87012
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
86836
87013
|
var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
|
|
86837
87014
|
(symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
|
|
86838
87015
|
(symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
|
|
86839
|
-
if (
|
|
87016
|
+
if (targetFlags & excludedMeanings) {
|
|
86840
87017
|
var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
|
|
86841
87018
|
ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
|
|
86842
87019
|
ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
|
@@ -86846,7 +87023,7 @@ var ts;
|
|
|
86846
87023
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
86847
87024
|
&& !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
|
|
86848
87025
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
86849
|
-
var isType = !(
|
|
87026
|
+
var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
|
|
86850
87027
|
if (isType || typeOnlyAlias) {
|
|
86851
87028
|
switch (node.kind) {
|
|
86852
87029
|
case 270 /* SyntaxKind.ImportClause */:
|
|
@@ -87006,14 +87183,15 @@ var ts;
|
|
|
87006
87183
|
if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
|
|
87007
87184
|
var target = resolveAlias(getSymbolOfNode(node));
|
|
87008
87185
|
if (target !== unknownSymbol) {
|
|
87009
|
-
|
|
87186
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
87187
|
+
if (targetFlags & 111551 /* SymbolFlags.Value */) {
|
|
87010
87188
|
// Target is a value symbol, check that it is not hidden by a local declaration with the same name
|
|
87011
87189
|
var moduleName = ts.getFirstIdentifier(node.moduleReference);
|
|
87012
87190
|
if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
|
|
87013
87191
|
error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
|
|
87014
87192
|
}
|
|
87015
87193
|
}
|
|
87016
|
-
if (
|
|
87194
|
+
if (targetFlags & 788968 /* SymbolFlags.Type */) {
|
|
87017
87195
|
checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
|
|
87018
87196
|
}
|
|
87019
87197
|
}
|
|
@@ -87152,7 +87330,7 @@ var ts;
|
|
|
87152
87330
|
markExportAsReferenced(node);
|
|
87153
87331
|
}
|
|
87154
87332
|
var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
|
|
87155
|
-
if (!target || target
|
|
87333
|
+
if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87156
87334
|
checkExpressionCached(node.propertyName || node.name);
|
|
87157
87335
|
}
|
|
87158
87336
|
}
|
|
@@ -87199,7 +87377,7 @@ var ts;
|
|
|
87199
87377
|
markAliasReferenced(sym, id);
|
|
87200
87378
|
// If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
|
|
87201
87379
|
var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
|
|
87202
|
-
if (target
|
|
87380
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87203
87381
|
// However if it is a value, we need to check it's being used correctly
|
|
87204
87382
|
checkExpressionCached(node.expression);
|
|
87205
87383
|
}
|
|
@@ -87871,29 +88049,9 @@ var ts;
|
|
|
87871
88049
|
}
|
|
87872
88050
|
function isTypeDeclarationName(name) {
|
|
87873
88051
|
return name.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
87874
|
-
isTypeDeclaration(name.parent) &&
|
|
88052
|
+
ts.isTypeDeclaration(name.parent) &&
|
|
87875
88053
|
ts.getNameOfDeclaration(name.parent) === name;
|
|
87876
88054
|
}
|
|
87877
|
-
function isTypeDeclaration(node) {
|
|
87878
|
-
switch (node.kind) {
|
|
87879
|
-
case 165 /* SyntaxKind.TypeParameter */:
|
|
87880
|
-
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
87881
|
-
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
87882
|
-
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
87883
|
-
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
87884
|
-
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
87885
|
-
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
87886
|
-
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
87887
|
-
return true;
|
|
87888
|
-
case 270 /* SyntaxKind.ImportClause */:
|
|
87889
|
-
return node.isTypeOnly;
|
|
87890
|
-
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
87891
|
-
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
87892
|
-
return node.parent.parent.isTypeOnly;
|
|
87893
|
-
default:
|
|
87894
|
-
return false;
|
|
87895
|
-
}
|
|
87896
|
-
}
|
|
87897
88055
|
// True if the given identifier is part of a type reference
|
|
87898
88056
|
function isTypeReferenceIdentifier(node) {
|
|
87899
88057
|
while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
|
|
@@ -88326,7 +88484,7 @@ var ts;
|
|
|
88326
88484
|
var baseType = ts.firstOrUndefined(getBaseTypes(classType));
|
|
88327
88485
|
return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
|
|
88328
88486
|
}
|
|
88329
|
-
if (isTypeDeclaration(node)) {
|
|
88487
|
+
if (ts.isTypeDeclaration(node)) {
|
|
88330
88488
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
88331
88489
|
var symbol = getSymbolOfNode(node);
|
|
88332
88490
|
return getDeclaredTypeOfSymbol(symbol);
|
|
@@ -88521,7 +88679,7 @@ var ts;
|
|
|
88521
88679
|
return symbolLinks.exportsSomeValue;
|
|
88522
88680
|
function isValue(s) {
|
|
88523
88681
|
s = resolveSymbol(s);
|
|
88524
|
-
return s && !!(s
|
|
88682
|
+
return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
|
|
88525
88683
|
}
|
|
88526
88684
|
}
|
|
88527
88685
|
function isNameOfModuleOrEnumDeclaration(node) {
|
|
@@ -88574,7 +88732,7 @@ var ts;
|
|
|
88574
88732
|
var symbol = getReferencedValueOrAliasSymbol(node);
|
|
88575
88733
|
// We should only get the declaration of an alias if there isn't a local value
|
|
88576
88734
|
// declaration for the symbol
|
|
88577
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
88735
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
88578
88736
|
return getDeclarationOfAliasSymbol(symbol);
|
|
88579
88737
|
}
|
|
88580
88738
|
}
|
|
@@ -88662,7 +88820,7 @@ var ts;
|
|
|
88662
88820
|
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88663
88821
|
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88664
88822
|
var symbol = getSymbolOfNode(node);
|
|
88665
|
-
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
|
|
88823
|
+
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
|
|
88666
88824
|
case 275 /* SyntaxKind.ExportDeclaration */:
|
|
88667
88825
|
var exportClause = node.exportClause;
|
|
88668
88826
|
return !!exportClause && (ts.isNamespaceExport(exportClause) ||
|
|
@@ -88684,6 +88842,7 @@ var ts;
|
|
|
88684
88842
|
return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
|
|
88685
88843
|
}
|
|
88686
88844
|
function isAliasResolvedToValue(symbol) {
|
|
88845
|
+
var _a;
|
|
88687
88846
|
if (!symbol) {
|
|
88688
88847
|
return false;
|
|
88689
88848
|
}
|
|
@@ -88693,7 +88852,7 @@ var ts;
|
|
|
88693
88852
|
}
|
|
88694
88853
|
// const enums and modules that contain only const enums are not considered values from the emit perspective
|
|
88695
88854
|
// unless 'preserveConstEnums' option is set to true
|
|
88696
|
-
return !!(target
|
|
88855
|
+
return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
|
|
88697
88856
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
|
|
88698
88857
|
}
|
|
88699
88858
|
function isConstEnumOrConstEnumOnlyModule(s) {
|
|
@@ -88708,7 +88867,7 @@ var ts;
|
|
|
88708
88867
|
}
|
|
88709
88868
|
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
88710
88869
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
|
|
88711
|
-
target
|
|
88870
|
+
getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
|
|
88712
88871
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
88713
88872
|
// An `export import ... =` of a value symbol is always considered referenced
|
|
88714
88873
|
return true;
|
|
@@ -98362,8 +98521,11 @@ var ts;
|
|
|
98362
98521
|
}
|
|
98363
98522
|
return ts.visitEachChild(node, visitor, context);
|
|
98364
98523
|
case 174 /* SyntaxKind.GetAccessor */:
|
|
98524
|
+
return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitGetAccessorDeclaration, node);
|
|
98365
98525
|
case 175 /* SyntaxKind.SetAccessor */:
|
|
98526
|
+
return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitSetAccessorDeclaration, node);
|
|
98366
98527
|
case 173 /* SyntaxKind.Constructor */:
|
|
98528
|
+
return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitConstructorDeclaration, node);
|
|
98367
98529
|
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
98368
98530
|
case 228 /* SyntaxKind.ClassExpression */:
|
|
98369
98531
|
return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node);
|
|
@@ -98464,6 +98626,9 @@ var ts;
|
|
|
98464
98626
|
return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
|
|
98465
98627
|
/*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
|
|
98466
98628
|
}
|
|
98629
|
+
function visitConstructorDeclaration(node) {
|
|
98630
|
+
return factory.updateConstructorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
|
|
98631
|
+
}
|
|
98467
98632
|
/**
|
|
98468
98633
|
* Visits a MethodDeclaration node.
|
|
98469
98634
|
*
|
|
@@ -98478,7 +98643,14 @@ var ts;
|
|
|
98478
98643
|
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
|
|
98479
98644
|
/*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
|
|
98480
98645
|
? transformAsyncFunctionBody(node)
|
|
98481
|
-
:
|
|
98646
|
+
: transformMethodBody(node));
|
|
98647
|
+
}
|
|
98648
|
+
function visitGetAccessorDeclaration(node) {
|
|
98649
|
+
return factory.updateGetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context),
|
|
98650
|
+
/*type*/ undefined, transformMethodBody(node));
|
|
98651
|
+
}
|
|
98652
|
+
function visitSetAccessorDeclaration(node) {
|
|
98653
|
+
return factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
|
|
98482
98654
|
}
|
|
98483
98655
|
/**
|
|
98484
98656
|
* Visits a FunctionDeclaration node.
|
|
@@ -98592,6 +98764,42 @@ var ts;
|
|
|
98592
98764
|
}
|
|
98593
98765
|
return false;
|
|
98594
98766
|
}
|
|
98767
|
+
function transformMethodBody(node) {
|
|
98768
|
+
ts.Debug.assertIsDefined(node.body);
|
|
98769
|
+
var savedCapturedSuperProperties = capturedSuperProperties;
|
|
98770
|
+
var savedHasSuperElementAccess = hasSuperElementAccess;
|
|
98771
|
+
capturedSuperProperties = new ts.Set();
|
|
98772
|
+
hasSuperElementAccess = false;
|
|
98773
|
+
var updated = ts.visitFunctionBody(node.body, visitor, context);
|
|
98774
|
+
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
|
98775
|
+
// This step isn't needed if we eventually transform this to ES5.
|
|
98776
|
+
var originalMethod = ts.getOriginalNode(node, ts.isFunctionLikeDeclaration);
|
|
98777
|
+
var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ &&
|
|
98778
|
+
resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) &&
|
|
98779
|
+
(ts.getFunctionFlags(originalMethod) & 3 /* FunctionFlags.AsyncGenerator */) !== 3 /* FunctionFlags.AsyncGenerator */;
|
|
98780
|
+
if (emitSuperHelpers) {
|
|
98781
|
+
enableSubstitutionForAsyncMethodsWithSuper();
|
|
98782
|
+
if (capturedSuperProperties.size) {
|
|
98783
|
+
var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
|
|
98784
|
+
substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
|
|
98785
|
+
var statements = updated.statements.slice();
|
|
98786
|
+
ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
|
|
98787
|
+
updated = factory.updateBlock(updated, statements);
|
|
98788
|
+
}
|
|
98789
|
+
if (hasSuperElementAccess) {
|
|
98790
|
+
// Emit helpers for super element access expressions (`super[x]`).
|
|
98791
|
+
if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
|
|
98792
|
+
ts.addEmitHelper(updated, ts.advancedAsyncSuperHelper);
|
|
98793
|
+
}
|
|
98794
|
+
else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
|
|
98795
|
+
ts.addEmitHelper(updated, ts.asyncSuperHelper);
|
|
98796
|
+
}
|
|
98797
|
+
}
|
|
98798
|
+
}
|
|
98799
|
+
capturedSuperProperties = savedCapturedSuperProperties;
|
|
98800
|
+
hasSuperElementAccess = savedHasSuperElementAccess;
|
|
98801
|
+
return updated;
|
|
98802
|
+
}
|
|
98595
98803
|
function transformAsyncFunctionBody(node) {
|
|
98596
98804
|
resumeLexicalEnvironment();
|
|
98597
98805
|
var original = ts.getOriginalNode(node, ts.isFunctionLike);
|
|
@@ -98624,7 +98832,7 @@ var ts;
|
|
|
98624
98832
|
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
|
|
98625
98833
|
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
|
98626
98834
|
// This step isn't needed if we eventually transform this to ES5.
|
|
98627
|
-
var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.
|
|
98835
|
+
var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
|
|
98628
98836
|
if (emitSuperHelpers) {
|
|
98629
98837
|
enableSubstitutionForAsyncMethodsWithSuper();
|
|
98630
98838
|
if (capturedSuperProperties.size) {
|
|
@@ -98637,10 +98845,10 @@ var ts;
|
|
|
98637
98845
|
ts.setTextRange(block, node.body);
|
|
98638
98846
|
if (emitSuperHelpers && hasSuperElementAccess) {
|
|
98639
98847
|
// Emit helpers for super element access expressions (`super[x]`).
|
|
98640
|
-
if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.
|
|
98848
|
+
if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
|
|
98641
98849
|
ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
|
|
98642
98850
|
}
|
|
98643
|
-
else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.
|
|
98851
|
+
else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
|
|
98644
98852
|
ts.addEmitHelper(block, ts.asyncSuperHelper);
|
|
98645
98853
|
}
|
|
98646
98854
|
}
|
|
@@ -98712,7 +98920,7 @@ var ts;
|
|
|
98712
98920
|
// If we need to support substitutions for `super` in an async method,
|
|
98713
98921
|
// we should track it here.
|
|
98714
98922
|
if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
|
|
98715
|
-
var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.
|
|
98923
|
+
var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
|
|
98716
98924
|
if (superContainerFlags !== enclosingSuperContainerFlags) {
|
|
98717
98925
|
var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
|
|
98718
98926
|
enclosingSuperContainerFlags = superContainerFlags;
|
|
@@ -98789,7 +98997,7 @@ var ts;
|
|
|
98789
98997
|
|| kind === 175 /* SyntaxKind.SetAccessor */;
|
|
98790
98998
|
}
|
|
98791
98999
|
function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
|
|
98792
|
-
if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.
|
|
99000
|
+
if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
|
|
98793
99001
|
return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
|
|
98794
99002
|
/*typeArguments*/ undefined, [argumentExpression]), "value"), location);
|
|
98795
99003
|
}
|
|
@@ -98804,7 +99012,7 @@ var ts;
|
|
|
98804
99012
|
function createSuperAccessVariableStatement(factory, resolver, node, names) {
|
|
98805
99013
|
// Create a variable declaration with a getter/setter (if binding) definition for each name:
|
|
98806
99014
|
// const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
|
|
98807
|
-
var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.
|
|
99015
|
+
var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) !== 0;
|
|
98808
99016
|
var accessors = [];
|
|
98809
99017
|
names.forEach(function (_, key) {
|
|
98810
99018
|
var name = ts.unescapeLeadingUnderscores(key);
|
|
@@ -99297,11 +99505,22 @@ var ts;
|
|
|
99297
99505
|
}
|
|
99298
99506
|
return node;
|
|
99299
99507
|
}
|
|
99300
|
-
function convertForOfStatementHead(node, boundValue) {
|
|
99301
|
-
var
|
|
99508
|
+
function convertForOfStatementHead(node, boundValue, nonUserCode) {
|
|
99509
|
+
var value = factory.createTempVariable(hoistVariableDeclaration);
|
|
99510
|
+
var iteratorValueExpression = factory.createAssignment(value, boundValue);
|
|
99511
|
+
var iteratorValueStatement = factory.createExpressionStatement(iteratorValueExpression);
|
|
99512
|
+
ts.setSourceMapRange(iteratorValueStatement, node.expression);
|
|
99513
|
+
var exitNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createFalse());
|
|
99514
|
+
var exitNonUserCodeStatement = factory.createExpressionStatement(exitNonUserCodeExpression);
|
|
99515
|
+
ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
|
|
99516
|
+
var enterNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createTrue());
|
|
99517
|
+
var enterNonUserCodeStatement = factory.createExpressionStatement(enterNonUserCodeExpression);
|
|
99518
|
+
ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
|
|
99519
|
+
var statements = [];
|
|
99520
|
+
var binding = ts.createForOfBindingStatement(factory, node.initializer, value);
|
|
99521
|
+
statements.push(ts.visitNode(binding, visitor, ts.isStatement));
|
|
99302
99522
|
var bodyLocation;
|
|
99303
99523
|
var statementsLocation;
|
|
99304
|
-
var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
|
|
99305
99524
|
var statement = ts.visitIterationBody(node.statement, visitor, context);
|
|
99306
99525
|
if (ts.isBlock(statement)) {
|
|
99307
99526
|
ts.addRange(statements, statement.statements);
|
|
@@ -99311,8 +99530,16 @@ var ts;
|
|
|
99311
99530
|
else {
|
|
99312
99531
|
statements.push(statement);
|
|
99313
99532
|
}
|
|
99314
|
-
|
|
99533
|
+
var body = ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
|
|
99315
99534
|
/*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */);
|
|
99535
|
+
return factory.createBlock([
|
|
99536
|
+
iteratorValueStatement,
|
|
99537
|
+
exitNonUserCodeStatement,
|
|
99538
|
+
factory.createTryStatement(body,
|
|
99539
|
+
/*catchClause*/ undefined, factory.createBlock([
|
|
99540
|
+
enterNonUserCodeStatement
|
|
99541
|
+
]))
|
|
99542
|
+
]);
|
|
99316
99543
|
}
|
|
99317
99544
|
function createDownlevelAwait(expression) {
|
|
99318
99545
|
return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
|
|
@@ -99323,6 +99550,8 @@ var ts;
|
|
|
99323
99550
|
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
|
|
99324
99551
|
var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined);
|
|
99325
99552
|
var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(/*recordTempVariable*/ undefined);
|
|
99553
|
+
var nonUserCode = factory.createTempVariable(/*recordTempVariable*/ undefined);
|
|
99554
|
+
var done = factory.createTempVariable(hoistVariableDeclaration);
|
|
99326
99555
|
var errorRecord = factory.createUniqueName("e");
|
|
99327
99556
|
var catchVariable = factory.getGeneratedNameForNode(errorRecord);
|
|
99328
99557
|
var returnMethod = factory.createTempVariable(/*recordTempVariable*/ undefined);
|
|
@@ -99339,12 +99568,17 @@ var ts;
|
|
|
99339
99568
|
callValues;
|
|
99340
99569
|
var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(
|
|
99341
99570
|
/*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
|
|
99571
|
+
factory.createVariableDeclaration(nonUserCode, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createTrue()),
|
|
99342
99572
|
ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
|
|
99343
99573
|
factory.createVariableDeclaration(result)
|
|
99344
99574
|
]), node.expression), 2097152 /* EmitFlags.NoHoisting */),
|
|
99345
|
-
/*condition*/ factory.
|
|
99575
|
+
/*condition*/ factory.inlineExpressions([
|
|
99576
|
+
factory.createAssignment(result, createDownlevelAwait(callNext)),
|
|
99577
|
+
factory.createAssignment(done, getDone),
|
|
99578
|
+
factory.createLogicalNot(done)
|
|
99579
|
+
]),
|
|
99346
99580
|
/*incrementor*/ undefined,
|
|
99347
|
-
/*statement*/ convertForOfStatementHead(node, getValue)),
|
|
99581
|
+
/*statement*/ convertForOfStatementHead(node, getValue, nonUserCode)),
|
|
99348
99582
|
/*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */);
|
|
99349
99583
|
ts.setOriginalNode(forStatement, node);
|
|
99350
99584
|
return factory.createTryStatement(factory.createBlock([
|
|
@@ -99356,7 +99590,7 @@ var ts;
|
|
|
99356
99590
|
]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([
|
|
99357
99591
|
factory.createTryStatement(
|
|
99358
99592
|
/*tryBlock*/ factory.createBlock([
|
|
99359
|
-
ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(
|
|
99593
|
+
ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(factory.createLogicalNot(nonUserCode), factory.createLogicalNot(done)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1 /* EmitFlags.SingleLine */)
|
|
99360
99594
|
]),
|
|
99361
99595
|
/*catchClause*/ undefined,
|
|
99362
99596
|
/*finallyBlock*/ ts.setEmitFlags(factory.createBlock([
|
|
@@ -99512,7 +99746,7 @@ var ts;
|
|
|
99512
99746
|
/*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */)));
|
|
99513
99747
|
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
|
99514
99748
|
// This step isn't needed if we eventually transform this to ES5.
|
|
99515
|
-
var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.
|
|
99749
|
+
var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
|
|
99516
99750
|
if (emitSuperHelpers) {
|
|
99517
99751
|
enableSubstitutionForAsyncMethodsWithSuper();
|
|
99518
99752
|
var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
|
|
@@ -99523,10 +99757,10 @@ var ts;
|
|
|
99523
99757
|
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
|
|
99524
99758
|
var block = factory.updateBlock(node.body, statements);
|
|
99525
99759
|
if (emitSuperHelpers && hasSuperElementAccess) {
|
|
99526
|
-
if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.
|
|
99760
|
+
if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
|
|
99527
99761
|
ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
|
|
99528
99762
|
}
|
|
99529
|
-
else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.
|
|
99763
|
+
else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
|
|
99530
99764
|
ts.addEmitHelper(block, ts.asyncSuperHelper);
|
|
99531
99765
|
}
|
|
99532
99766
|
}
|
|
@@ -99655,7 +99889,7 @@ var ts;
|
|
|
99655
99889
|
// If we need to support substitutions for `super` in an async method,
|
|
99656
99890
|
// we should track it here.
|
|
99657
99891
|
if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
|
|
99658
|
-
var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.
|
|
99892
|
+
var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
|
|
99659
99893
|
if (superContainerFlags !== enclosingSuperContainerFlags) {
|
|
99660
99894
|
var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
|
|
99661
99895
|
enclosingSuperContainerFlags = superContainerFlags;
|
|
@@ -99732,7 +99966,7 @@ var ts;
|
|
|
99732
99966
|
|| kind === 175 /* SyntaxKind.SetAccessor */;
|
|
99733
99967
|
}
|
|
99734
99968
|
function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
|
|
99735
|
-
if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.
|
|
99969
|
+
if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
|
|
99736
99970
|
return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"),
|
|
99737
99971
|
/*typeArguments*/ undefined, [argumentExpression]), "value"), location);
|
|
99738
99972
|
}
|
|
@@ -101201,11 +101435,13 @@ var ts;
|
|
|
101201
101435
|
return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
|
|
101202
101436
|
}
|
|
101203
101437
|
function visitIdentifier(node) {
|
|
101204
|
-
if (
|
|
101205
|
-
|
|
101438
|
+
if (convertedLoopState) {
|
|
101439
|
+
if (resolver.isArgumentsLocalBinding(node)) {
|
|
101440
|
+
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
|
|
101441
|
+
}
|
|
101206
101442
|
}
|
|
101207
|
-
if (
|
|
101208
|
-
return
|
|
101443
|
+
if (node.hasExtendedUnicodeEscape) {
|
|
101444
|
+
return ts.setOriginalNode(ts.setTextRange(factory.createIdentifier(ts.unescapeLeadingUnderscores(node.escapedText)), node), node);
|
|
101209
101445
|
}
|
|
101210
101446
|
return node;
|
|
101211
101447
|
}
|
|
@@ -105352,7 +105588,6 @@ var ts;
|
|
|
105352
105588
|
return node;
|
|
105353
105589
|
}
|
|
105354
105590
|
function transformAndEmitForInStatement(node) {
|
|
105355
|
-
// TODO(rbuckton): Source map locations
|
|
105356
105591
|
if (containsYield(node)) {
|
|
105357
105592
|
// [source]
|
|
105358
105593
|
// for (var p in o) {
|
|
@@ -105360,34 +105595,41 @@ var ts;
|
|
|
105360
105595
|
// }
|
|
105361
105596
|
//
|
|
105362
105597
|
// [intermediate]
|
|
105363
|
-
// .local _a,
|
|
105364
|
-
//
|
|
105365
|
-
//
|
|
105598
|
+
// .local _b, _a, _c, _i
|
|
105599
|
+
// _b = [];
|
|
105600
|
+
// _a = o;
|
|
105601
|
+
// for (_c in _a) _b.push(_c);
|
|
105366
105602
|
// _i = 0;
|
|
105367
105603
|
// .loop incrementLabel, endLoopLabel
|
|
105368
105604
|
// .mark conditionLabel
|
|
105369
|
-
// .brfalse endLoopLabel, (_i <
|
|
105370
|
-
//
|
|
105605
|
+
// .brfalse endLoopLabel, (_i < _b.length)
|
|
105606
|
+
// _c = _b[_i];
|
|
105607
|
+
// .brfalse incrementLabel, (_c in _a)
|
|
105608
|
+
// p = _c;
|
|
105371
105609
|
// /*body*/
|
|
105372
105610
|
// .mark incrementLabel
|
|
105373
|
-
//
|
|
105611
|
+
// _c++;
|
|
105374
105612
|
// .br conditionLabel
|
|
105375
105613
|
// .endloop
|
|
105376
105614
|
// .mark endLoopLabel
|
|
105377
|
-
var
|
|
105378
|
-
var
|
|
105615
|
+
var obj = declareLocal(); // _a
|
|
105616
|
+
var keysArray = declareLocal(); // _b
|
|
105617
|
+
var key = declareLocal(); // _c
|
|
105379
105618
|
var keysIndex = factory.createLoopVariable(); // _i
|
|
105380
105619
|
var initializer = node.initializer;
|
|
105381
105620
|
hoistVariableDeclaration(keysIndex);
|
|
105621
|
+
emitAssignment(obj, ts.visitNode(node.expression, visitor, ts.isExpression));
|
|
105382
105622
|
emitAssignment(keysArray, factory.createArrayLiteralExpression());
|
|
105383
|
-
emitStatement(factory.createForInStatement(key,
|
|
105623
|
+
emitStatement(factory.createForInStatement(key, obj, factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
|
|
105384
105624
|
/*typeArguments*/ undefined, [key]))));
|
|
105385
105625
|
emitAssignment(keysIndex, factory.createNumericLiteral(0));
|
|
105386
105626
|
var conditionLabel = defineLabel();
|
|
105387
105627
|
var incrementLabel = defineLabel();
|
|
105388
|
-
var
|
|
105628
|
+
var endLoopLabel = beginLoopBlock(incrementLabel);
|
|
105389
105629
|
markLabel(conditionLabel);
|
|
105390
|
-
emitBreakWhenFalse(
|
|
105630
|
+
emitBreakWhenFalse(endLoopLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
|
|
105631
|
+
emitAssignment(key, factory.createElementAccessExpression(keysArray, keysIndex));
|
|
105632
|
+
emitBreakWhenFalse(incrementLabel, factory.createBinaryExpression(key, 101 /* SyntaxKind.InKeyword */, obj));
|
|
105391
105633
|
var variable = void 0;
|
|
105392
105634
|
if (ts.isVariableDeclarationList(initializer)) {
|
|
105393
105635
|
for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
|
|
@@ -105400,7 +105642,7 @@ var ts;
|
|
|
105400
105642
|
variable = ts.visitNode(initializer, visitor, ts.isExpression);
|
|
105401
105643
|
ts.Debug.assert(ts.isLeftHandSideExpression(variable));
|
|
105402
105644
|
}
|
|
105403
|
-
emitAssignment(variable,
|
|
105645
|
+
emitAssignment(variable, key);
|
|
105404
105646
|
transformAndEmitEmbeddedStatement(node.statement);
|
|
105405
105647
|
markLabel(incrementLabel);
|
|
105406
105648
|
emitStatement(factory.createExpressionStatement(factory.createPostfixIncrement(keysIndex)));
|
|
@@ -107241,7 +107483,7 @@ var ts;
|
|
|
107241
107483
|
return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
|
|
107242
107484
|
case ts.ModuleKind.CommonJS:
|
|
107243
107485
|
default:
|
|
107244
|
-
return createImportCallExpressionCommonJS(argument
|
|
107486
|
+
return createImportCallExpressionCommonJS(argument);
|
|
107245
107487
|
}
|
|
107246
107488
|
}
|
|
107247
107489
|
function createImportCallExpressionUMD(arg, containsLexicalThis) {
|
|
@@ -107264,7 +107506,7 @@ var ts;
|
|
|
107264
107506
|
return factory.createConditionalExpression(
|
|
107265
107507
|
/*condition*/ factory.createIdentifier("__syncRequire"),
|
|
107266
107508
|
/*questionToken*/ undefined,
|
|
107267
|
-
/*whenTrue*/ createImportCallExpressionCommonJS(arg
|
|
107509
|
+
/*whenTrue*/ createImportCallExpressionCommonJS(arg),
|
|
107268
107510
|
/*colonToken*/ undefined,
|
|
107269
107511
|
/*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
|
|
107270
107512
|
}
|
|
@@ -107273,7 +107515,7 @@ var ts;
|
|
|
107273
107515
|
return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
|
|
107274
107516
|
/*condition*/ factory.createIdentifier("__syncRequire"),
|
|
107275
107517
|
/*questionToken*/ undefined,
|
|
107276
|
-
/*whenTrue*/ createImportCallExpressionCommonJS(temp,
|
|
107518
|
+
/*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
|
|
107277
107519
|
/*colonToken*/ undefined,
|
|
107278
107520
|
/*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
|
|
107279
107521
|
}
|
|
@@ -107323,14 +107565,20 @@ var ts;
|
|
|
107323
107565
|
}
|
|
107324
107566
|
return promise;
|
|
107325
107567
|
}
|
|
107326
|
-
function createImportCallExpressionCommonJS(arg,
|
|
107327
|
-
// import(
|
|
107568
|
+
function createImportCallExpressionCommonJS(arg, isInlineable) {
|
|
107569
|
+
// import(x)
|
|
107328
107570
|
// emit as
|
|
107329
|
-
//
|
|
107571
|
+
// var _a;
|
|
107572
|
+
// (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
|
|
107330
107573
|
// We have to wrap require in then callback so that require is done in asynchronously
|
|
107331
107574
|
// if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
|
|
107332
|
-
|
|
107333
|
-
var
|
|
107575
|
+
// If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
|
|
107576
|
+
var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
|
|
107577
|
+
var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
|
|
107578
|
+
/*typeArguments*/ undefined,
|
|
107579
|
+
/*argumentsArray*/ []);
|
|
107580
|
+
var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
|
|
107581
|
+
/*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
|
|
107334
107582
|
if (ts.getESModuleInterop(compilerOptions)) {
|
|
107335
107583
|
requireCall = emitHelpers().createImportStarHelper(requireCall);
|
|
107336
107584
|
}
|
|
@@ -107351,14 +107599,9 @@ var ts;
|
|
|
107351
107599
|
/*typeParameters*/ undefined,
|
|
107352
107600
|
/*parameters*/ [],
|
|
107353
107601
|
/*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
|
|
107354
|
-
// if there is a lexical 'this' in the import call arguments, ensure we indicate
|
|
107355
|
-
// that this new function expression indicates it captures 'this' so that the
|
|
107356
|
-
// es2015 transformer will properly substitute 'this' with '_this'.
|
|
107357
|
-
if (containsLexicalThis) {
|
|
107358
|
-
ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
|
|
107359
|
-
}
|
|
107360
107602
|
}
|
|
107361
|
-
|
|
107603
|
+
var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
|
|
107604
|
+
return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
|
|
107362
107605
|
}
|
|
107363
107606
|
function getHelperExpressionForExport(node, innerExpr) {
|
|
107364
107607
|
if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
|
|
@@ -118351,14 +118594,16 @@ var ts;
|
|
|
118351
118594
|
}
|
|
118352
118595
|
return setReadFileCache(key, fileName);
|
|
118353
118596
|
};
|
|
118354
|
-
var getSourceFileWithCache = getSourceFile ? function (fileName,
|
|
118597
|
+
var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
|
|
118355
118598
|
var key = toPath(fileName);
|
|
118356
|
-
var
|
|
118599
|
+
var impliedNodeFormat = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions.impliedNodeFormat : undefined;
|
|
118600
|
+
var forImpliedNodeFormat = sourceFileCache.get(impliedNodeFormat);
|
|
118601
|
+
var value = forImpliedNodeFormat === null || forImpliedNodeFormat === void 0 ? void 0 : forImpliedNodeFormat.get(key);
|
|
118357
118602
|
if (value)
|
|
118358
118603
|
return value;
|
|
118359
|
-
var sourceFile = getSourceFile(fileName,
|
|
118604
|
+
var sourceFile = getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
118360
118605
|
if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) {
|
|
118361
|
-
sourceFileCache.set(key, sourceFile);
|
|
118606
|
+
sourceFileCache.set(impliedNodeFormat, (forImpliedNodeFormat || new ts.Map()).set(key, sourceFile));
|
|
118362
118607
|
}
|
|
118363
118608
|
return sourceFile;
|
|
118364
118609
|
} : undefined;
|
|
@@ -118383,13 +118628,15 @@ var ts;
|
|
|
118383
118628
|
var value = readFileCache.get(key);
|
|
118384
118629
|
if (value !== undefined && value !== data) {
|
|
118385
118630
|
readFileCache.delete(key);
|
|
118386
|
-
sourceFileCache.delete(key);
|
|
118631
|
+
sourceFileCache.forEach(function (map) { return map.delete(key); });
|
|
118387
118632
|
}
|
|
118388
118633
|
else if (getSourceFileWithCache) {
|
|
118389
|
-
|
|
118390
|
-
|
|
118391
|
-
|
|
118392
|
-
|
|
118634
|
+
sourceFileCache.forEach(function (map) {
|
|
118635
|
+
var sourceFile = map.get(key);
|
|
118636
|
+
if (sourceFile && sourceFile.text !== data) {
|
|
118637
|
+
map.delete(key);
|
|
118638
|
+
}
|
|
118639
|
+
});
|
|
118393
118640
|
}
|
|
118394
118641
|
originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
|
|
118395
118642
|
};
|
|
@@ -122531,10 +122778,16 @@ var ts;
|
|
|
122531
122778
|
var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
|
|
122532
122779
|
var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
|
|
122533
122780
|
!ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
|
|
122781
|
+
// We can only reuse emit signatures (i.e. .d.ts signatures) if the .d.ts file is unchanged,
|
|
122782
|
+
// which will eg be depedent on change in options like declarationDir and outDir options are unchanged.
|
|
122783
|
+
// We need to look in oldState.compilerOptions, rather than oldCompilerOptions (i.e.we need to disregard useOldState) because
|
|
122784
|
+
// oldCompilerOptions can be undefined if there was change in say module from None to some other option
|
|
122785
|
+
// which would make useOldState as false since we can now use reference maps that are needed to track what to emit, what to check etc
|
|
122786
|
+
// but that option change does not affect d.ts file name so emitSignatures should still be reused.
|
|
122534
122787
|
var canCopyEmitSignatures = compilerOptions.composite &&
|
|
122535
122788
|
(oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
|
|
122536
122789
|
!outFilePath &&
|
|
122537
|
-
!ts.compilerOptionsAffectDeclarationPath(compilerOptions,
|
|
122790
|
+
!ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
|
|
122538
122791
|
if (useOldState) {
|
|
122539
122792
|
// Copy old state's changed files set
|
|
122540
122793
|
(_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
|
|
@@ -123749,7 +124002,7 @@ var ts;
|
|
|
123749
124002
|
var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */;
|
|
123750
124003
|
if (isNonDirectorySeparatorRoot &&
|
|
123751
124004
|
dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
|
|
123752
|
-
pathPartForUserCheck.search(/[a-zA-
|
|
124005
|
+
pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) { // Dos style nextPart
|
|
123753
124006
|
nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
|
|
123754
124007
|
if (nextDirectorySeparator === -1) {
|
|
123755
124008
|
// ignore "//vda1cs4850/c$/folderAtRoot"
|
|
@@ -125003,7 +125256,7 @@ var ts;
|
|
|
125003
125256
|
});
|
|
125004
125257
|
// Sort by paths closest to importing file Name directory
|
|
125005
125258
|
var sortedPaths = [];
|
|
125006
|
-
var
|
|
125259
|
+
var _loop_35 = function (directory) {
|
|
125007
125260
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
125008
125261
|
var pathsInDirectory;
|
|
125009
125262
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -125027,9 +125280,9 @@ var ts;
|
|
|
125027
125280
|
};
|
|
125028
125281
|
var out_directory_1;
|
|
125029
125282
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
125030
|
-
var
|
|
125283
|
+
var state_11 = _loop_35(directory);
|
|
125031
125284
|
directory = out_directory_1;
|
|
125032
|
-
if (
|
|
125285
|
+
if (state_11 === "break")
|
|
125033
125286
|
break;
|
|
125034
125287
|
}
|
|
125035
125288
|
if (allFileNames.size) {
|
|
@@ -125098,7 +125351,7 @@ var ts;
|
|
|
125098
125351
|
}
|
|
125099
125352
|
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
125100
125353
|
for (var key in paths) {
|
|
125101
|
-
var
|
|
125354
|
+
var _loop_36 = function (patternText_1) {
|
|
125102
125355
|
var pattern = ts.normalizePath(patternText_1);
|
|
125103
125356
|
var indexOfStar = pattern.indexOf("*");
|
|
125104
125357
|
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
@@ -125165,9 +125418,9 @@ var ts;
|
|
|
125165
125418
|
};
|
|
125166
125419
|
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
125167
125420
|
var patternText_1 = _a[_i];
|
|
125168
|
-
var
|
|
125169
|
-
if (typeof
|
|
125170
|
-
return
|
|
125421
|
+
var state_12 = _loop_36(patternText_1);
|
|
125422
|
+
if (typeof state_12 === "object")
|
|
125423
|
+
return state_12.value;
|
|
125171
125424
|
}
|
|
125172
125425
|
}
|
|
125173
125426
|
function validateEnding(_a) {
|
|
@@ -125255,15 +125508,21 @@ var ts;
|
|
|
125255
125508
|
return undefined;
|
|
125256
125509
|
}
|
|
125257
125510
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
|
|
125258
|
-
var
|
|
125259
|
-
if (
|
|
125511
|
+
var normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
125512
|
+
if (normalizedTargetPaths === undefined) {
|
|
125513
|
+
return undefined;
|
|
125514
|
+
}
|
|
125515
|
+
var normalizedSourcePaths = getPathsRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
|
|
125516
|
+
var relativePaths = ts.flatMap(normalizedSourcePaths, function (sourcePath) {
|
|
125517
|
+
return ts.map(normalizedTargetPaths, function (targetPath) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourcePath, targetPath, getCanonicalFileName)); });
|
|
125518
|
+
});
|
|
125519
|
+
var shortest = ts.min(relativePaths, ts.compareNumberOfDirectorySeparators);
|
|
125520
|
+
if (!shortest) {
|
|
125260
125521
|
return undefined;
|
|
125261
125522
|
}
|
|
125262
|
-
var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
|
|
125263
|
-
var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
|
|
125264
125523
|
return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
|
|
125265
|
-
? removeExtensionAndIndexPostFix(
|
|
125266
|
-
: ts.removeFileExtension(
|
|
125524
|
+
? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions)
|
|
125525
|
+
: ts.removeFileExtension(shortest);
|
|
125267
125526
|
}
|
|
125268
125527
|
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
125269
125528
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
@@ -125400,8 +125659,8 @@ var ts;
|
|
|
125400
125659
|
}
|
|
125401
125660
|
}
|
|
125402
125661
|
}
|
|
125403
|
-
function
|
|
125404
|
-
return ts.
|
|
125662
|
+
function getPathsRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
125663
|
+
return ts.mapDefined(rootDirs, function (rootDir) {
|
|
125405
125664
|
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
125406
125665
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
125407
125666
|
});
|
|
@@ -127969,8 +128228,15 @@ var ts;
|
|
|
127969
128228
|
}
|
|
127970
128229
|
if (buildInfo.program) {
|
|
127971
128230
|
// If there are pending changes that are not emitted, project is out of date
|
|
128231
|
+
// When there are syntax errors, changeFileSet will have list of files changed (irrespective of noEmit)
|
|
128232
|
+
// But in case of semantic error we need special treatment.
|
|
128233
|
+
// Checking presence of affectedFilesPendingEmit list is fast and good way to tell if there were semantic errors and file emit was blocked
|
|
128234
|
+
// But if noEmit is true, affectedFilesPendingEmit will have file list even if there are no semantic errors to preserve list of files to be emitted when running with noEmit false
|
|
128235
|
+
// So with noEmit set to true, check on semantic diagnostics needs to be explicit as oppose to when it is false when only files pending emit is sufficient
|
|
127972
128236
|
if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
127973
|
-
(!project.options.noEmit
|
|
128237
|
+
(!project.options.noEmit ?
|
|
128238
|
+
(_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length :
|
|
128239
|
+
ts.some(buildInfo.program.semanticDiagnosticsPerFile, ts.isArray))) {
|
|
127974
128240
|
return {
|
|
127975
128241
|
type: ts.UpToDateStatusType.OutOfDateBuildInfo,
|
|
127976
128242
|
buildInfoFile: buildInfoPath
|
|
@@ -129151,6 +129417,12 @@ var ts;
|
|
|
129151
129417
|
SemanticClassificationFormat["Original"] = "original";
|
|
129152
129418
|
SemanticClassificationFormat["TwentyTwenty"] = "2020";
|
|
129153
129419
|
})(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
|
|
129420
|
+
var OrganizeImportsMode;
|
|
129421
|
+
(function (OrganizeImportsMode) {
|
|
129422
|
+
OrganizeImportsMode["All"] = "All";
|
|
129423
|
+
OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
|
|
129424
|
+
OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
|
|
129425
|
+
})(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
|
|
129154
129426
|
var CompletionTriggerKind;
|
|
129155
129427
|
(function (CompletionTriggerKind) {
|
|
129156
129428
|
/** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
|
|
@@ -130196,6 +130468,8 @@ var ts;
|
|
|
130196
130468
|
return lastTypeNode;
|
|
130197
130469
|
}
|
|
130198
130470
|
function getContextualTypeFromParentOrAncestorTypeNode(node, checker) {
|
|
130471
|
+
if (node.flags & (8388608 /* NodeFlags.JSDoc */ & ~262144 /* NodeFlags.JavaScriptFile */))
|
|
130472
|
+
return undefined;
|
|
130199
130473
|
var contextualType = getContextualTypeFromParent(node, checker);
|
|
130200
130474
|
if (contextualType)
|
|
130201
130475
|
return contextualType;
|
|
@@ -132682,6 +132956,10 @@ var ts;
|
|
|
132682
132956
|
return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
|
|
132683
132957
|
}
|
|
132684
132958
|
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
|
|
132959
|
+
function isSourceFileFromLibrary(program, node) {
|
|
132960
|
+
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
132961
|
+
}
|
|
132962
|
+
ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
|
|
132685
132963
|
// #endregion
|
|
132686
132964
|
})(ts || (ts = {}));
|
|
132687
132965
|
/*@internal*/
|
|
@@ -135708,7 +135986,7 @@ var ts;
|
|
|
135708
135986
|
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
135709
135987
|
preferences.includeCompletionsWithInsertText &&
|
|
135710
135988
|
completionKind === 3 /* CompletionKind.MemberLike */ &&
|
|
135711
|
-
isClassLikeMemberCompletion(symbol, location)) {
|
|
135989
|
+
isClassLikeMemberCompletion(symbol, location, sourceFile)) {
|
|
135712
135990
|
var importAdder = void 0;
|
|
135713
135991
|
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
|
|
135714
135992
|
sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
@@ -135780,7 +136058,7 @@ var ts;
|
|
|
135780
136058
|
data: data,
|
|
135781
136059
|
};
|
|
135782
136060
|
}
|
|
135783
|
-
function isClassLikeMemberCompletion(symbol, location) {
|
|
136061
|
+
function isClassLikeMemberCompletion(symbol, location, sourceFile) {
|
|
135784
136062
|
// TODO: support JS files.
|
|
135785
136063
|
if (ts.isInJSFile(location)) {
|
|
135786
136064
|
return false;
|
|
@@ -135814,6 +136092,7 @@ var ts;
|
|
|
135814
136092
|
location.parent.parent &&
|
|
135815
136093
|
ts.isClassElement(location.parent) &&
|
|
135816
136094
|
location === location.parent.name &&
|
|
136095
|
+
location.parent.getLastToken(sourceFile) === location.parent.name &&
|
|
135817
136096
|
ts.isClassLike(location.parent.parent)) ||
|
|
135818
136097
|
(location.parent &&
|
|
135819
136098
|
ts.isSyntaxList(location) &&
|
|
@@ -142975,6 +143254,12 @@ var ts;
|
|
|
142975
143254
|
var label = ts.getTargetLabel(node.parent, node.text);
|
|
142976
143255
|
return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217
|
|
142977
143256
|
}
|
|
143257
|
+
if (node.kind === 105 /* SyntaxKind.ReturnKeyword */) {
|
|
143258
|
+
var functionDeclaration = ts.findAncestor(node.parent, function (n) {
|
|
143259
|
+
return ts.isClassStaticBlockDeclaration(n) ? "quit" : ts.isFunctionLikeDeclaration(n);
|
|
143260
|
+
});
|
|
143261
|
+
return functionDeclaration ? [createDefinitionFromSignatureDeclaration(typeChecker, functionDeclaration)] : undefined;
|
|
143262
|
+
}
|
|
142978
143263
|
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
|
|
142979
143264
|
var classDecl = node.parent.parent;
|
|
142980
143265
|
var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
|
|
@@ -143110,13 +143395,16 @@ var ts;
|
|
|
143110
143395
|
if (!baseDeclaration)
|
|
143111
143396
|
return;
|
|
143112
143397
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(baseDeclaration);
|
|
143113
|
-
|
|
143114
|
-
|
|
143398
|
+
if (!baseTypeNode)
|
|
143399
|
+
return;
|
|
143400
|
+
var expression = ts.skipParentheses(baseTypeNode.expression);
|
|
143401
|
+
var base = ts.isClassExpression(expression) ? expression.symbol : typeChecker.getSymbolAtLocation(expression);
|
|
143402
|
+
if (!base)
|
|
143115
143403
|
return;
|
|
143116
143404
|
var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(classElement.name));
|
|
143117
143405
|
var symbol = ts.hasStaticModifier(classElement)
|
|
143118
|
-
? typeChecker.getPropertyOfType(typeChecker.
|
|
143119
|
-
: typeChecker.getPropertyOfType(
|
|
143406
|
+
? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbol(base), name)
|
|
143407
|
+
: typeChecker.getPropertyOfType(typeChecker.getDeclaredTypeOfSymbol(base), name);
|
|
143120
143408
|
if (!symbol)
|
|
143121
143409
|
return;
|
|
143122
143410
|
return getDefinitionFromSymbol(typeChecker, symbol, node);
|
|
@@ -143823,19 +144111,24 @@ var ts;
|
|
|
143823
144111
|
return getCommentOwnerInfoWorker(commentOwner.initializer, options);
|
|
143824
144112
|
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
143825
144113
|
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
143826
|
-
case 168 /* SyntaxKind.PropertySignature */:
|
|
143827
144114
|
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
143828
144115
|
case 302 /* SyntaxKind.EnumMember */:
|
|
143829
144116
|
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
143830
144117
|
return { commentOwner: commentOwner };
|
|
144118
|
+
case 168 /* SyntaxKind.PropertySignature */: {
|
|
144119
|
+
var host_1 = commentOwner;
|
|
144120
|
+
return host_1.type && ts.isFunctionTypeNode(host_1.type)
|
|
144121
|
+
? { commentOwner: commentOwner, parameters: host_1.type.parameters, hasReturn: hasReturn(host_1.type, options) }
|
|
144122
|
+
: { commentOwner: commentOwner };
|
|
144123
|
+
}
|
|
143831
144124
|
case 240 /* SyntaxKind.VariableStatement */: {
|
|
143832
144125
|
var varStatement = commentOwner;
|
|
143833
144126
|
var varDeclarations = varStatement.declarationList.declarations;
|
|
143834
|
-
var
|
|
144127
|
+
var host_2 = varDeclarations.length === 1 && varDeclarations[0].initializer
|
|
143835
144128
|
? getRightHandSideOfAssignment(varDeclarations[0].initializer)
|
|
143836
144129
|
: undefined;
|
|
143837
|
-
return
|
|
143838
|
-
? { commentOwner: commentOwner, parameters:
|
|
144130
|
+
return host_2
|
|
144131
|
+
? { commentOwner: commentOwner, parameters: host_2.parameters, hasReturn: hasReturn(host_2, options) }
|
|
143839
144132
|
: { commentOwner: commentOwner };
|
|
143840
144133
|
}
|
|
143841
144134
|
case 308 /* SyntaxKind.SourceFile */:
|
|
@@ -143865,7 +144158,7 @@ var ts;
|
|
|
143865
144158
|
}
|
|
143866
144159
|
function hasReturn(node, options) {
|
|
143867
144160
|
return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) &&
|
|
143868
|
-
(ts.isArrowFunction(node) && ts.isExpression(node.body)
|
|
144161
|
+
(ts.isFunctionTypeNode(node) || ts.isArrowFunction(node) && ts.isExpression(node.body)
|
|
143869
144162
|
|| ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }));
|
|
143870
144163
|
}
|
|
143871
144164
|
function getRightHandSideOfAssignment(rightHandSide) {
|
|
@@ -144906,23 +145199,39 @@ var ts;
|
|
|
144906
145199
|
* 2) Coalescing imports from the same module
|
|
144907
145200
|
* 3) Sorting imports
|
|
144908
145201
|
*/
|
|
144909
|
-
function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
145202
|
+
function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
|
|
144910
145203
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
144911
|
-
var
|
|
145204
|
+
var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
145205
|
+
var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
|
|
145206
|
+
var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
145207
|
+
var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
|
|
145208
|
+
var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
|
|
145209
|
+
var processImportsOfSameModuleSpecifier = function (importGroup) {
|
|
145210
|
+
var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
|
|
145211
|
+
return shouldSort
|
|
145212
|
+
? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
|
|
145213
|
+
: processedDeclarations;
|
|
145214
|
+
};
|
|
144912
145215
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
144913
145216
|
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
144914
|
-
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144915
|
-
//
|
|
144916
|
-
|
|
144917
|
-
|
|
145217
|
+
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
145218
|
+
// Exports are always used
|
|
145219
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
145220
|
+
// All of the old ExportDeclarations in the file, in syntactic order.
|
|
145221
|
+
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
|
|
145222
|
+
organizeImportsWorker(topLevelExportDecls, coalesceExports);
|
|
145223
|
+
}
|
|
144918
145224
|
for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
|
|
144919
145225
|
var ambientModule = _a[_i];
|
|
144920
145226
|
if (!ambientModule.body)
|
|
144921
145227
|
continue;
|
|
144922
145228
|
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
144923
|
-
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144924
|
-
|
|
144925
|
-
|
|
145229
|
+
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
145230
|
+
// Exports are always used
|
|
145231
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
145232
|
+
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
|
|
145233
|
+
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
|
|
145234
|
+
}
|
|
144926
145235
|
}
|
|
144927
145236
|
return changeTracker.getChanges();
|
|
144928
145237
|
function organizeImportsWorker(oldImportDecls, coalesce) {
|
|
@@ -144935,8 +145244,12 @@ var ts;
|
|
|
144935
145244
|
// Consider: we could do a more careful check that this trivia is actually a header,
|
|
144936
145245
|
// but the consequences of being wrong are very minor.
|
|
144937
145246
|
ts.suppressLeadingTrivia(oldImportDecls[0]);
|
|
144938
|
-
var oldImportGroups =
|
|
144939
|
-
|
|
145247
|
+
var oldImportGroups = shouldCombine
|
|
145248
|
+
? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
|
|
145249
|
+
: [oldImportDecls];
|
|
145250
|
+
var sortedImportGroups = shouldSort
|
|
145251
|
+
? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
|
|
145252
|
+
: oldImportGroups;
|
|
144940
145253
|
var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
|
|
144941
145254
|
return getExternalModuleName(importGroup[0].moduleSpecifier)
|
|
144942
145255
|
? coalesce(importGroup)
|
|
@@ -145000,11 +145313,7 @@ var ts;
|
|
|
145000
145313
|
}
|
|
145001
145314
|
return false;
|
|
145002
145315
|
}
|
|
145003
|
-
function removeUnusedImports(oldImports, sourceFile, program
|
|
145004
|
-
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
145005
|
-
if (skipDestructiveCodeActions) {
|
|
145006
|
-
return oldImports;
|
|
145007
|
-
}
|
|
145316
|
+
function removeUnusedImports(oldImports, sourceFile, program) {
|
|
145008
145317
|
var typeChecker = program.getTypeChecker();
|
|
145009
145318
|
var compilerOptions = program.getCompilerOptions();
|
|
145010
145319
|
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
|
@@ -145860,7 +146169,7 @@ var ts;
|
|
|
145860
146169
|
return bestMatch;
|
|
145861
146170
|
}
|
|
145862
146171
|
function betterMatch(a, b) {
|
|
145863
|
-
return ts.min(a, b, compareMatches);
|
|
146172
|
+
return ts.min([a, b], compareMatches);
|
|
145864
146173
|
}
|
|
145865
146174
|
function compareMatches(a, b) {
|
|
145866
146175
|
return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */
|
|
@@ -146469,8 +146778,8 @@ var ts;
|
|
|
146469
146778
|
}
|
|
146470
146779
|
if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
|
|
146471
146780
|
var stack = [ts.scanner.getToken()];
|
|
146472
|
-
var token = ts.scanner.scan();
|
|
146473
146781
|
loop: while (ts.length(stack)) {
|
|
146782
|
+
var token = ts.scanner.scan();
|
|
146474
146783
|
switch (token) {
|
|
146475
146784
|
case 1 /* SyntaxKind.EndOfFileToken */:
|
|
146476
146785
|
break loop;
|
|
@@ -146498,7 +146807,6 @@ var ts;
|
|
|
146498
146807
|
}
|
|
146499
146808
|
break;
|
|
146500
146809
|
}
|
|
146501
|
-
token = ts.scanner.scan();
|
|
146502
146810
|
}
|
|
146503
146811
|
nextToken();
|
|
146504
146812
|
}
|
|
@@ -148977,7 +149285,7 @@ var ts;
|
|
|
148977
149285
|
tags = signature.getJsDocTags();
|
|
148978
149286
|
if (allSignatures.length > 1 && documentation.length === 0 && tags.length === 0) {
|
|
148979
149287
|
documentation = allSignatures[0].getDocumentationComment(typeChecker);
|
|
148980
|
-
tags = allSignatures[0].getJsDocTags();
|
|
149288
|
+
tags = allSignatures[0].getJsDocTags().filter(function (tag) { return tag.name !== "deprecated"; }); // should only include @deprecated JSDoc tag on the first overload (#49368)
|
|
148981
149289
|
}
|
|
148982
149290
|
}
|
|
148983
149291
|
function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
|
|
@@ -149320,7 +149628,7 @@ var ts;
|
|
|
149320
149628
|
return false;
|
|
149321
149629
|
}
|
|
149322
149630
|
function shouldRescanJsxText(node) {
|
|
149323
|
-
return ts.isJsxText(node)
|
|
149631
|
+
return ts.isJsxText(node) || ts.isJsxElement(node) && (lastTokenInfo === null || lastTokenInfo === void 0 ? void 0 : lastTokenInfo.token.kind) === 11 /* SyntaxKind.JsxText */;
|
|
149324
149632
|
}
|
|
149325
149633
|
function shouldRescanSlashToken(container) {
|
|
149326
149634
|
return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */;
|
|
@@ -150089,10 +150397,10 @@ var ts;
|
|
|
150089
150397
|
!nodeIsInDecoratorContext(context.nextTokenParent);
|
|
150090
150398
|
}
|
|
150091
150399
|
function nodeIsInDecoratorContext(node) {
|
|
150092
|
-
while (ts.
|
|
150400
|
+
while (node && ts.isExpression(node)) {
|
|
150093
150401
|
node = node.parent;
|
|
150094
150402
|
}
|
|
150095
|
-
return node.kind === 167 /* SyntaxKind.Decorator */;
|
|
150403
|
+
return node && node.kind === 167 /* SyntaxKind.Decorator */;
|
|
150096
150404
|
}
|
|
150097
150405
|
function isStartOfVariableDeclarationList(context) {
|
|
150098
150406
|
return context.currentTokenParent.kind === 258 /* SyntaxKind.VariableDeclarationList */ &&
|
|
@@ -153010,6 +153318,26 @@ var ts;
|
|
|
153010
153318
|
function startPositionToDeleteNodeInList(sourceFile, node) {
|
|
153011
153319
|
return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
|
|
153012
153320
|
}
|
|
153321
|
+
function endPositionToDeleteNodeInList(sourceFile, node, prevNode, nextNode) {
|
|
153322
|
+
var end = startPositionToDeleteNodeInList(sourceFile, nextNode);
|
|
153323
|
+
if (prevNode === undefined || ts.positionsAreOnSameLine(getAdjustedEndPosition(sourceFile, node, {}), end, sourceFile)) {
|
|
153324
|
+
return end;
|
|
153325
|
+
}
|
|
153326
|
+
var token = ts.findPrecedingToken(nextNode.getStart(sourceFile), sourceFile);
|
|
153327
|
+
if (isSeparator(node, token)) {
|
|
153328
|
+
var prevToken = ts.findPrecedingToken(node.getStart(sourceFile), sourceFile);
|
|
153329
|
+
if (isSeparator(prevNode, prevToken)) {
|
|
153330
|
+
var pos = ts.skipTrivia(sourceFile.text, token.getEnd(), /*stopAfterLineBreak*/ true, /*stopAtComments*/ true);
|
|
153331
|
+
if (ts.positionsAreOnSameLine(prevToken.getStart(sourceFile), token.getStart(sourceFile), sourceFile)) {
|
|
153332
|
+
return ts.isLineBreak(sourceFile.text.charCodeAt(pos - 1)) ? pos - 1 : pos;
|
|
153333
|
+
}
|
|
153334
|
+
if (ts.isLineBreak(sourceFile.text.charCodeAt(pos))) {
|
|
153335
|
+
return pos;
|
|
153336
|
+
}
|
|
153337
|
+
}
|
|
153338
|
+
}
|
|
153339
|
+
return end;
|
|
153340
|
+
}
|
|
153013
153341
|
function getClassOrObjectBraceEnds(cls, sourceFile) {
|
|
153014
153342
|
var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
|
|
153015
153343
|
var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
|
|
@@ -153567,7 +153895,7 @@ var ts;
|
|
|
153567
153895
|
deletedNodesInLists.add(node);
|
|
153568
153896
|
changes.deleteRange(sourceFile, {
|
|
153569
153897
|
pos: startPositionToDeleteNodeInList(sourceFile, node),
|
|
153570
|
-
end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) :
|
|
153898
|
+
end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : endPositionToDeleteNodeInList(sourceFile, node, containingList[index - 1], containingList[index + 1]),
|
|
153571
153899
|
});
|
|
153572
153900
|
}
|
|
153573
153901
|
})(textChanges = ts.textChanges || (ts.textChanges = {}));
|
|
@@ -154037,6 +154365,15 @@ var ts;
|
|
|
154037
154365
|
});
|
|
154038
154366
|
}
|
|
154039
154367
|
function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
|
|
154368
|
+
if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
|
|
154369
|
+
var exprType = checker.getTypeAtLocation(insertionSite);
|
|
154370
|
+
var asyncIter = checker.getAsyncIterableType();
|
|
154371
|
+
if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
|
|
154372
|
+
var forOf = insertionSite.parent;
|
|
154373
|
+
changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
|
|
154374
|
+
return;
|
|
154375
|
+
}
|
|
154376
|
+
}
|
|
154040
154377
|
if (ts.isBinaryExpression(insertionSite)) {
|
|
154041
154378
|
for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
|
|
154042
154379
|
var side = _a[_i];
|
|
@@ -157762,6 +158099,143 @@ var ts;
|
|
|
157762
158099
|
})(ts || (ts = {}));
|
|
157763
158100
|
/* @internal */
|
|
157764
158101
|
var ts;
|
|
158102
|
+
(function (ts) {
|
|
158103
|
+
var codefix;
|
|
158104
|
+
(function (codefix) {
|
|
158105
|
+
var fixId = "fixImportNonExportedMember";
|
|
158106
|
+
var errorCodes = [
|
|
158107
|
+
ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
|
|
158108
|
+
];
|
|
158109
|
+
codefix.registerCodeFix({
|
|
158110
|
+
errorCodes: errorCodes,
|
|
158111
|
+
fixIds: [fixId],
|
|
158112
|
+
getCodeActions: function (context) {
|
|
158113
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
158114
|
+
var info = getInfo(sourceFile, span.start, program);
|
|
158115
|
+
if (info === undefined)
|
|
158116
|
+
return undefined;
|
|
158117
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
|
|
158118
|
+
return [codefix.createCodeFixAction(fixId, changes, [ts.Diagnostics.Export_0_from_module_1, info.exportName.node.text, info.moduleSpecifier], fixId, ts.Diagnostics.Export_all_referenced_locals)];
|
|
158119
|
+
},
|
|
158120
|
+
getAllCodeActions: function (context) {
|
|
158121
|
+
var program = context.program;
|
|
158122
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
158123
|
+
var exports = new ts.Map();
|
|
158124
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
158125
|
+
var info = getInfo(diag.file, diag.start, program);
|
|
158126
|
+
if (info === undefined)
|
|
158127
|
+
return undefined;
|
|
158128
|
+
var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
|
|
158129
|
+
if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
|
|
158130
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
158131
|
+
}
|
|
158132
|
+
else {
|
|
158133
|
+
var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
|
|
158134
|
+
if (exportName.isTypeOnly) {
|
|
158135
|
+
moduleExports.typeOnlyExports.push(exportName);
|
|
158136
|
+
}
|
|
158137
|
+
else {
|
|
158138
|
+
moduleExports.exports.push(exportName);
|
|
158139
|
+
}
|
|
158140
|
+
exports.set(moduleSourceFile, moduleExports);
|
|
158141
|
+
}
|
|
158142
|
+
});
|
|
158143
|
+
exports.forEach(function (moduleExports, moduleSourceFile) {
|
|
158144
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
|
|
158145
|
+
if (exportDeclaration && exportDeclaration.isTypeOnly) {
|
|
158146
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
|
|
158147
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
|
|
158148
|
+
}
|
|
158149
|
+
else {
|
|
158150
|
+
doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
|
|
158151
|
+
}
|
|
158152
|
+
});
|
|
158153
|
+
}));
|
|
158154
|
+
}
|
|
158155
|
+
});
|
|
158156
|
+
function getInfo(sourceFile, pos, program) {
|
|
158157
|
+
var _a;
|
|
158158
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
158159
|
+
if (ts.isIdentifier(token)) {
|
|
158160
|
+
var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
|
|
158161
|
+
if (importDeclaration === undefined)
|
|
158162
|
+
return undefined;
|
|
158163
|
+
var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
|
|
158164
|
+
if (moduleSpecifier === undefined)
|
|
158165
|
+
return undefined;
|
|
158166
|
+
var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
|
|
158167
|
+
if (resolvedModule === undefined)
|
|
158168
|
+
return undefined;
|
|
158169
|
+
var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
158170
|
+
if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
|
|
158171
|
+
return undefined;
|
|
158172
|
+
var moduleSymbol = moduleSourceFile.symbol;
|
|
158173
|
+
var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
|
|
158174
|
+
if (locals === undefined)
|
|
158175
|
+
return undefined;
|
|
158176
|
+
var localSymbol = locals.get(token.escapedText);
|
|
158177
|
+
if (localSymbol === undefined)
|
|
158178
|
+
return undefined;
|
|
158179
|
+
var node = getNodeOfSymbol(localSymbol);
|
|
158180
|
+
if (node === undefined)
|
|
158181
|
+
return undefined;
|
|
158182
|
+
var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
|
|
158183
|
+
return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
|
|
158184
|
+
}
|
|
158185
|
+
return undefined;
|
|
158186
|
+
}
|
|
158187
|
+
function doChange(changes, program, _a) {
|
|
158188
|
+
var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
|
|
158189
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
158190
|
+
if (exportDeclaration) {
|
|
158191
|
+
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
158192
|
+
}
|
|
158193
|
+
else if (ts.canHaveExportModifier(node)) {
|
|
158194
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
158195
|
+
}
|
|
158196
|
+
else {
|
|
158197
|
+
createExport(changes, program, moduleSourceFile, [exportName]);
|
|
158198
|
+
}
|
|
158199
|
+
}
|
|
158200
|
+
function doChanges(changes, program, sourceFile, moduleExports, node) {
|
|
158201
|
+
if (ts.length(moduleExports)) {
|
|
158202
|
+
if (node) {
|
|
158203
|
+
updateExport(changes, program, sourceFile, node, moduleExports);
|
|
158204
|
+
}
|
|
158205
|
+
else {
|
|
158206
|
+
createExport(changes, program, sourceFile, moduleExports);
|
|
158207
|
+
}
|
|
158208
|
+
}
|
|
158209
|
+
}
|
|
158210
|
+
function tryGetExportDeclaration(sourceFile, isTypeOnly) {
|
|
158211
|
+
var predicate = function (node) {
|
|
158212
|
+
return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
|
|
158213
|
+
};
|
|
158214
|
+
return ts.findLast(sourceFile.statements, predicate);
|
|
158215
|
+
}
|
|
158216
|
+
function updateExport(changes, program, sourceFile, node, names) {
|
|
158217
|
+
var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
|
|
158218
|
+
var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
|
|
158219
|
+
changes.replaceNode(sourceFile, node, ts.factory.updateExportDeclaration(node, node.modifiers, node.isTypeOnly, ts.factory.createNamedExports(ts.factory.createNodeArray(__spreadArray(__spreadArray([], namedExports, true), createExportSpecifiers(names, allowTypeModifier), true), /*hasTrailingComma*/ namedExports.hasTrailingComma)), node.moduleSpecifier, node.assertClause));
|
|
158220
|
+
}
|
|
158221
|
+
function createExport(changes, program, sourceFile, names) {
|
|
158222
|
+
changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
|
|
158223
|
+
}
|
|
158224
|
+
function createExportSpecifiers(names, allowTypeModifier) {
|
|
158225
|
+
return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
|
|
158226
|
+
}
|
|
158227
|
+
function getNodeOfSymbol(symbol) {
|
|
158228
|
+
if (symbol.valueDeclaration === undefined) {
|
|
158229
|
+
return ts.firstOrUndefined(symbol.declarations);
|
|
158230
|
+
}
|
|
158231
|
+
var declaration = symbol.valueDeclaration;
|
|
158232
|
+
var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
|
|
158233
|
+
return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
|
|
158234
|
+
}
|
|
158235
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
158236
|
+
})(ts || (ts = {}));
|
|
158237
|
+
/* @internal */
|
|
158238
|
+
var ts;
|
|
157765
158239
|
(function (ts) {
|
|
157766
158240
|
var codefix;
|
|
157767
158241
|
(function (codefix) {
|
|
@@ -158292,7 +158766,7 @@ var ts;
|
|
|
158292
158766
|
var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
|
|
158293
158767
|
if (argIndex < 0)
|
|
158294
158768
|
return undefined;
|
|
158295
|
-
var signature =
|
|
158769
|
+
var signature = checker.getResolvedSignature(parent.parent);
|
|
158296
158770
|
if (!(signature && signature.declaration && signature.parameters[argIndex]))
|
|
158297
158771
|
return undefined;
|
|
158298
158772
|
var param = signature.parameters[argIndex].valueDeclaration;
|
|
@@ -158339,13 +158813,13 @@ var ts;
|
|
|
158339
158813
|
if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
|
|
158340
158814
|
var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
|
|
158341
158815
|
var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
|
|
158342
|
-
if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158816
|
+
if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158343
158817
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
|
|
158344
158818
|
}
|
|
158345
158819
|
var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
|
|
158346
158820
|
if (sourceFile.commonJsModuleIndicator)
|
|
158347
158821
|
return undefined;
|
|
158348
|
-
if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158822
|
+
if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158349
158823
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
|
|
158350
158824
|
}
|
|
158351
158825
|
}
|
|
@@ -158355,7 +158829,7 @@ var ts;
|
|
|
158355
158829
|
return undefined;
|
|
158356
158830
|
// Prefer to change the class instead of the interface if they are merged
|
|
158357
158831
|
var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
|
|
158358
|
-
if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158832
|
+
if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158359
158833
|
var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
158360
158834
|
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
|
|
158361
158835
|
return undefined;
|
|
@@ -158367,14 +158841,11 @@ var ts;
|
|
|
158367
158841
|
return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
|
|
158368
158842
|
}
|
|
158369
158843
|
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
|
|
158370
|
-
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158844
|
+
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158371
158845
|
return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
|
|
158372
158846
|
}
|
|
158373
158847
|
return undefined;
|
|
158374
158848
|
}
|
|
158375
|
-
function isSourceFileFromLibrary(program, node) {
|
|
158376
|
-
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
158377
|
-
}
|
|
158378
158849
|
function getActionsForMissingMemberDeclaration(context, info) {
|
|
158379
158850
|
return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
|
|
158380
158851
|
createActionsForAddMissingMemberInTypeScriptFile(context, info);
|
|
@@ -163800,8 +164271,8 @@ var ts;
|
|
|
163800
164271
|
var i = 0;
|
|
163801
164272
|
for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
|
|
163802
164273
|
var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
|
|
163803
|
-
var description = functionExtraction.description;
|
|
163804
164274
|
if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
164275
|
+
var description = functionExtraction.description;
|
|
163805
164276
|
if (functionExtraction.errors.length === 0) {
|
|
163806
164277
|
// Don't issue refactorings with duplicated names.
|
|
163807
164278
|
// Scopes come back in "innermost first" order, so extractions will
|
|
@@ -163825,15 +164296,15 @@ var ts;
|
|
|
163825
164296
|
}
|
|
163826
164297
|
}
|
|
163827
164298
|
if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
164299
|
+
var description = constantExtraction.description;
|
|
163828
164300
|
if (constantExtraction.errors.length === 0) {
|
|
163829
164301
|
// Don't issue refactorings with duplicated names.
|
|
163830
164302
|
// Scopes come back in "innermost first" order, so extractions will
|
|
163831
164303
|
// preferentially go into nearer scopes
|
|
163832
|
-
|
|
163833
|
-
|
|
163834
|
-
usedConstantNames.set(description_1, true);
|
|
164304
|
+
if (!usedConstantNames.has(description)) {
|
|
164305
|
+
usedConstantNames.set(description, true);
|
|
163835
164306
|
constantActions.push({
|
|
163836
|
-
description:
|
|
164307
|
+
description: description,
|
|
163837
164308
|
name: "constant_scope_".concat(i),
|
|
163838
164309
|
kind: extractConstantAction.kind
|
|
163839
164310
|
});
|
|
@@ -163978,7 +164449,6 @@ var ts;
|
|
|
163978
164449
|
var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
|
|
163979
164450
|
// Do the same for the ending position
|
|
163980
164451
|
var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
|
|
163981
|
-
var declarations = [];
|
|
163982
164452
|
// We'll modify these flags as we walk the tree to collect data
|
|
163983
164453
|
// about what things need to be done as part of the extraction.
|
|
163984
164454
|
var rangeFacts = RangeFacts.None;
|
|
@@ -164021,7 +164491,7 @@ var ts;
|
|
|
164021
164491
|
// the expression.
|
|
164022
164492
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
164023
164493
|
}
|
|
164024
|
-
return { targetRange: { range: statements, facts: rangeFacts,
|
|
164494
|
+
return { targetRange: { range: statements, facts: rangeFacts, thisNode: thisNode } };
|
|
164025
164495
|
}
|
|
164026
164496
|
if (ts.isReturnStatement(start) && !start.expression) {
|
|
164027
164497
|
// Makes no sense to extract an expression-less return statement.
|
|
@@ -164033,7 +164503,7 @@ var ts;
|
|
|
164033
164503
|
if (errors) {
|
|
164034
164504
|
return { errors: errors };
|
|
164035
164505
|
}
|
|
164036
|
-
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts,
|
|
164506
|
+
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, thisNode: thisNode } }; // TODO: GH#18217
|
|
164037
164507
|
/**
|
|
164038
164508
|
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
|
|
164039
164509
|
* @param node The unrefined extraction node.
|
|
@@ -164045,10 +164515,10 @@ var ts;
|
|
|
164045
164515
|
}
|
|
164046
164516
|
}
|
|
164047
164517
|
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
|
|
164048
|
-
var
|
|
164518
|
+
var declarations = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
|
164049
164519
|
var numInitializers = 0;
|
|
164050
164520
|
var lastInitializer = void 0;
|
|
164051
|
-
for (var _i = 0, declarations_5 =
|
|
164521
|
+
for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
|
|
164052
164522
|
var declaration = declarations_5[_i];
|
|
164053
164523
|
if (declaration.initializer) {
|
|
164054
164524
|
numInitializers++;
|
|
@@ -164148,7 +164618,6 @@ var ts;
|
|
|
164148
164618
|
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
|
|
164149
164619
|
return true;
|
|
164150
164620
|
}
|
|
164151
|
-
declarations.push(node.symbol);
|
|
164152
164621
|
}
|
|
164153
164622
|
// Some things can't be extracted in certain situations
|
|
164154
164623
|
switch (node.kind) {
|
|
@@ -165873,7 +166342,7 @@ var ts;
|
|
|
165873
166342
|
function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) {
|
|
165874
166343
|
var checker = program.getTypeChecker();
|
|
165875
166344
|
var prologueDirectives = ts.takeWhile(oldFile.statements, ts.isPrologueDirective);
|
|
165876
|
-
if (
|
|
166345
|
+
if (oldFile.externalModuleIndicator === undefined && oldFile.commonJsModuleIndicator === undefined && usage.oldImportsNeededByNewFile.size() === 0) {
|
|
165877
166346
|
deleteMovedStatements(oldFile, toMove.ranges, changes);
|
|
165878
166347
|
return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
|
|
165879
166348
|
}
|
|
@@ -166114,7 +166583,12 @@ var ts;
|
|
|
166114
166583
|
switch (name.kind) {
|
|
166115
166584
|
case 79 /* SyntaxKind.Identifier */:
|
|
166116
166585
|
if (isUnused(name)) {
|
|
166117
|
-
|
|
166586
|
+
if (varDecl.initializer && ts.isRequireCall(varDecl.initializer, /*requireStringLiteralLikeArgument*/ true)) {
|
|
166587
|
+
changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && ts.length(varDecl.parent.declarations) === 1 ? varDecl.parent.parent : varDecl);
|
|
166588
|
+
}
|
|
166589
|
+
else {
|
|
166590
|
+
changes.delete(sourceFile, name);
|
|
166591
|
+
}
|
|
166118
166592
|
}
|
|
166119
166593
|
break;
|
|
166120
166594
|
case 204 /* SyntaxKind.ArrayBindingPattern */:
|
|
@@ -166346,6 +166820,9 @@ var ts;
|
|
|
166346
166820
|
ts.copyEntries(this.map, clone.map);
|
|
166347
166821
|
return clone;
|
|
166348
166822
|
};
|
|
166823
|
+
SymbolSet.prototype.size = function () {
|
|
166824
|
+
return this.map.size;
|
|
166825
|
+
};
|
|
166349
166826
|
return SymbolSet;
|
|
166350
166827
|
}());
|
|
166351
166828
|
function isTopLevelDeclaration(node) {
|
|
@@ -166434,7 +166911,8 @@ var ts;
|
|
|
166434
166911
|
if (useEs6Exports) {
|
|
166435
166912
|
return !ts.isExpressionStatement(decl) && ts.hasSyntacticModifier(decl, 1 /* ModifierFlags.Export */) || !!(name && ((_a = sourceFile.symbol.exports) === null || _a === void 0 ? void 0 : _a.has(name.escapedText)));
|
|
166436
166913
|
}
|
|
166437
|
-
return
|
|
166914
|
+
return !!sourceFile.symbol && !!sourceFile.symbol.exports &&
|
|
166915
|
+
getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
|
|
166438
166916
|
}
|
|
166439
166917
|
function addExport(decl, useEs6Exports) {
|
|
166440
166918
|
return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl);
|
|
@@ -168194,8 +168672,8 @@ var ts;
|
|
|
168194
168672
|
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
168195
168673
|
}
|
|
168196
168674
|
};
|
|
168197
|
-
for (var _i = 0,
|
|
168198
|
-
var declaration =
|
|
168675
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
168676
|
+
var declaration = declarations_6[_i];
|
|
168199
168677
|
_loop_20(declaration);
|
|
168200
168678
|
}
|
|
168201
168679
|
}
|
|
@@ -168221,8 +168699,8 @@ var ts;
|
|
|
168221
168699
|
if (inheritedDocs)
|
|
168222
168700
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
168223
168701
|
};
|
|
168224
|
-
for (var _i = 0,
|
|
168225
|
-
var declaration =
|
|
168702
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
168703
|
+
var declaration = declarations_7[_i];
|
|
168226
168704
|
_loop_21(declaration);
|
|
168227
168705
|
}
|
|
168228
168706
|
}
|
|
@@ -169392,12 +169870,14 @@ var ts;
|
|
|
169392
169870
|
return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
|
|
169393
169871
|
}
|
|
169394
169872
|
function organizeImports(args, formatOptions, preferences) {
|
|
169873
|
+
var _a;
|
|
169395
169874
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
169396
169875
|
synchronizeHostData();
|
|
169397
169876
|
ts.Debug.assert(args.type === "file");
|
|
169398
169877
|
var sourceFile = getValidSourceFile(args.fileName);
|
|
169399
169878
|
var formatContext = ts.formatting.getFormatContext(formatOptions, host);
|
|
169400
|
-
|
|
169879
|
+
var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
|
|
169880
|
+
return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
|
|
169401
169881
|
}
|
|
169402
169882
|
function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
|
|
169403
169883
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|