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/tsserver.js
CHANGED
|
@@ -45,7 +45,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
46
46
|
function step(op) {
|
|
47
47
|
if (f) throw new TypeError("Generator is already executing.");
|
|
48
|
-
while (_) try {
|
|
48
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
49
49
|
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;
|
|
50
50
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
51
51
|
switch (op[0]) {
|
|
@@ -109,7 +109,7 @@ var ts;
|
|
|
109
109
|
// The following is baselined as a literal template type without intervention
|
|
110
110
|
/** The version of the TypeScript compiler release */
|
|
111
111
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
112
|
-
ts.version = "".concat(ts.versionMajorMinor, ".
|
|
112
|
+
ts.version = "".concat(ts.versionMajorMinor, ".2-rc");
|
|
113
113
|
/* @internal */
|
|
114
114
|
var Comparison;
|
|
115
115
|
(function (Comparison) {
|
|
@@ -1901,8 +1901,8 @@ var ts;
|
|
|
1901
1901
|
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);
|
|
1902
1902
|
}
|
|
1903
1903
|
ts.compareTextSpans = compareTextSpans;
|
|
1904
|
-
function min(
|
|
1905
|
-
return compare(
|
|
1904
|
+
function min(items, compare) {
|
|
1905
|
+
return reduceLeft(items, function (x, y) { return compare(x, y) === -1 /* Comparison.LessThan */ ? x : y; });
|
|
1906
1906
|
}
|
|
1907
1907
|
ts.min = min;
|
|
1908
1908
|
/**
|
|
@@ -3215,11 +3215,13 @@ var ts;
|
|
|
3215
3215
|
// > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers
|
|
3216
3216
|
// > MUST NOT include leading zeroes.
|
|
3217
3217
|
var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
|
|
3218
|
+
var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
|
|
3218
3219
|
// https://semver.org/#spec-item-10
|
|
3219
3220
|
// > Build metadata MAY be denoted by appending a plus sign and a series of dot separated
|
|
3220
3221
|
// > identifiers immediately following the patch or pre-release version. Identifiers MUST
|
|
3221
3222
|
// > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
|
|
3222
3223
|
var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
|
|
3224
|
+
var buildPartRegExp = /^[a-z0-9-]+$/i;
|
|
3223
3225
|
// https://semver.org/#spec-item-9
|
|
3224
3226
|
// > Numeric identifiers MUST NOT include leading zeroes.
|
|
3225
3227
|
var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
|
|
@@ -3239,13 +3241,15 @@ var ts;
|
|
|
3239
3241
|
ts.Debug.assert(major >= 0, "Invalid argument: major");
|
|
3240
3242
|
ts.Debug.assert(minor >= 0, "Invalid argument: minor");
|
|
3241
3243
|
ts.Debug.assert(patch >= 0, "Invalid argument: patch");
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
+
var prereleaseArray = prerelease ? ts.isArray(prerelease) ? prerelease : prerelease.split(".") : ts.emptyArray;
|
|
3245
|
+
var buildArray = build ? ts.isArray(build) ? build : build.split(".") : ts.emptyArray;
|
|
3246
|
+
ts.Debug.assert(ts.every(prereleaseArray, function (s) { return prereleasePartRegExp.test(s); }), "Invalid argument: prerelease");
|
|
3247
|
+
ts.Debug.assert(ts.every(buildArray, function (s) { return buildPartRegExp.test(s); }), "Invalid argument: build");
|
|
3244
3248
|
this.major = major;
|
|
3245
3249
|
this.minor = minor;
|
|
3246
3250
|
this.patch = patch;
|
|
3247
|
-
this.prerelease =
|
|
3248
|
-
this.build =
|
|
3251
|
+
this.prerelease = prereleaseArray;
|
|
3252
|
+
this.build = buildArray;
|
|
3249
3253
|
}
|
|
3250
3254
|
Version.tryParse = function (text) {
|
|
3251
3255
|
var result = tryParseComponents(text);
|
|
@@ -3284,6 +3288,10 @@ var ts;
|
|
|
3284
3288
|
default: return ts.Debug.assertNever(field);
|
|
3285
3289
|
}
|
|
3286
3290
|
};
|
|
3291
|
+
Version.prototype.with = function (fields) {
|
|
3292
|
+
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;
|
|
3293
|
+
return new Version(major, minor, patch, prerelease, build);
|
|
3294
|
+
};
|
|
3287
3295
|
Version.prototype.toString = function () {
|
|
3288
3296
|
var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
|
|
3289
3297
|
if (ts.some(this.prerelease))
|
|
@@ -3292,7 +3300,7 @@ var ts;
|
|
|
3292
3300
|
result += "+".concat(this.build.join("."));
|
|
3293
3301
|
return result;
|
|
3294
3302
|
};
|
|
3295
|
-
Version.zero = new Version(0, 0, 0);
|
|
3303
|
+
Version.zero = new Version(0, 0, 0, ["0"]);
|
|
3296
3304
|
return Version;
|
|
3297
3305
|
}());
|
|
3298
3306
|
ts.Version = Version;
|
|
@@ -3375,6 +3383,10 @@ var ts;
|
|
|
3375
3383
|
}
|
|
3376
3384
|
return undefined;
|
|
3377
3385
|
};
|
|
3386
|
+
/**
|
|
3387
|
+
* Tests whether a version matches the range. This is equivalent to `satisfies(version, range, { includePrerelease: true })`.
|
|
3388
|
+
* in `node-semver`.
|
|
3389
|
+
*/
|
|
3378
3390
|
VersionRange.prototype.test = function (version) {
|
|
3379
3391
|
if (typeof version === "string")
|
|
3380
3392
|
version = new Version(version);
|
|
@@ -3485,19 +3497,20 @@ var ts;
|
|
|
3485
3497
|
break;
|
|
3486
3498
|
case "<":
|
|
3487
3499
|
case ">=":
|
|
3488
|
-
comparators.push(createComparator(operator, version))
|
|
3500
|
+
comparators.push(isWildcard(minor) || isWildcard(patch) ? createComparator(operator, version.with({ prerelease: "0" })) :
|
|
3501
|
+
createComparator(operator, version));
|
|
3489
3502
|
break;
|
|
3490
3503
|
case "<=":
|
|
3491
3504
|
case ">":
|
|
3492
|
-
comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
|
|
3493
|
-
isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
|
|
3505
|
+
comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major").with({ prerelease: "0" })) :
|
|
3506
|
+
isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor").with({ prerelease: "0" })) :
|
|
3494
3507
|
createComparator(operator, version));
|
|
3495
3508
|
break;
|
|
3496
3509
|
case "=":
|
|
3497
3510
|
case undefined:
|
|
3498
3511
|
if (isWildcard(minor) || isWildcard(patch)) {
|
|
3499
|
-
comparators.push(createComparator(">=", version));
|
|
3500
|
-
comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
|
|
3512
|
+
comparators.push(createComparator(">=", version.with({ prerelease: "0" })));
|
|
3513
|
+
comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor").with({ prerelease: "0" })));
|
|
3501
3514
|
}
|
|
3502
3515
|
else {
|
|
3503
3516
|
comparators.push(createComparator("=", version));
|
|
@@ -5106,8 +5119,8 @@ var ts;
|
|
|
5106
5119
|
NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 256] = "SuperInstance";
|
|
5107
5120
|
NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 512] = "SuperStatic";
|
|
5108
5121
|
NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 1024] = "ContextChecked";
|
|
5109
|
-
NodeCheckFlags[NodeCheckFlags["
|
|
5110
|
-
NodeCheckFlags[NodeCheckFlags["
|
|
5122
|
+
NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAccessInAsync"] = 2048] = "MethodWithSuperPropertyAccessInAsync";
|
|
5123
|
+
NodeCheckFlags[NodeCheckFlags["MethodWithSuperPropertyAssignmentInAsync"] = 4096] = "MethodWithSuperPropertyAssignmentInAsync";
|
|
5111
5124
|
NodeCheckFlags[NodeCheckFlags["CaptureArguments"] = 8192] = "CaptureArguments";
|
|
5112
5125
|
NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 16384] = "EnumValuesComputed";
|
|
5113
5126
|
NodeCheckFlags[NodeCheckFlags["LexicalModuleMergesWithClass"] = 32768] = "LexicalModuleMergesWithClass";
|
|
@@ -6742,7 +6755,7 @@ var ts;
|
|
|
6742
6755
|
}
|
|
6743
6756
|
/*@internal*/
|
|
6744
6757
|
function createSystemWatchFunctions(_a) {
|
|
6745
|
-
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,
|
|
6758
|
+
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;
|
|
6746
6759
|
var pollingWatches = new ts.Map();
|
|
6747
6760
|
var fsWatches = new ts.Map();
|
|
6748
6761
|
var fsWatchesRecursive = new ts.Map();
|
|
@@ -6808,8 +6821,8 @@ var ts;
|
|
|
6808
6821
|
return useNonPollingWatchers ?
|
|
6809
6822
|
// Use notifications from FS to watch with falling back to fs.watchFile
|
|
6810
6823
|
generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
|
|
6811
|
-
// Default to
|
|
6812
|
-
{ watchFile:
|
|
6824
|
+
// Default to using fs events
|
|
6825
|
+
{ watchFile: ts.WatchFileKind.UseFsEvents };
|
|
6813
6826
|
}
|
|
6814
6827
|
}
|
|
6815
6828
|
function generateWatchFileOptions(watchFile, fallbackPolling, options) {
|
|
@@ -7081,7 +7094,6 @@ var ts;
|
|
|
7081
7094
|
tscWatchFile: process.env.TSC_WATCHFILE,
|
|
7082
7095
|
useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
|
|
7083
7096
|
tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
|
|
7084
|
-
defaultWatchFileKind: function () { var _a, _b; return (_b = (_a = sys).defaultWatchFileKind) === null || _b === void 0 ? void 0 : _b.call(_a); },
|
|
7085
7097
|
inodeWatching: isLinuxOrMacOs,
|
|
7086
7098
|
sysLog: sysLog,
|
|
7087
7099
|
}), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory;
|
|
@@ -9592,6 +9604,10 @@ var ts;
|
|
|
9592
9604
|
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"),
|
|
9593
9605
|
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"),
|
|
9594
9606
|
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}'"),
|
|
9607
|
+
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}."),
|
|
9608
|
+
Matched_0_condition_1: diag(6403, ts.DiagnosticCategory.Message, "Matched_0_condition_1_6403", "Matched '{0}' condition '{1}'."),
|
|
9609
|
+
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}'."),
|
|
9610
|
+
Saw_non_matching_condition_0: diag(6405, ts.DiagnosticCategory.Message, "Saw_non_matching_condition_0_6405", "Saw non-matching condition '{0}'."),
|
|
9595
9611
|
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}'"),
|
|
9596
9612
|
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."),
|
|
9597
9613
|
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."),
|
|
@@ -9908,6 +9924,8 @@ var ts;
|
|
|
9908
9924
|
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}\""),
|
|
9909
9925
|
Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
|
|
9910
9926
|
Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
|
|
9927
|
+
Export_0_from_module_1: diag(90059, ts.DiagnosticCategory.Message, "Export_0_from_module_1_90059", "Export '{0}' from module '{1}'"),
|
|
9928
|
+
Export_all_referenced_locals: diag(90060, ts.DiagnosticCategory.Message, "Export_all_referenced_locals_90060", "Export all referenced locals"),
|
|
9911
9929
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9912
9930
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9913
9931
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -11365,7 +11383,7 @@ var ts;
|
|
|
11365
11383
|
return -1;
|
|
11366
11384
|
}
|
|
11367
11385
|
function peekExtendedUnicodeEscape() {
|
|
11368
|
-
if (
|
|
11386
|
+
if (codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
|
|
11369
11387
|
var start_2 = pos;
|
|
11370
11388
|
pos += 3;
|
|
11371
11389
|
var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
|
|
@@ -21668,6 +21686,32 @@ var ts;
|
|
|
21668
21686
|
return parameter.kind === 343 /* SyntaxKind.JSDocParameterTag */ ? (_a = parameter.typeExpression) === null || _a === void 0 ? void 0 : _a.type : parameter.type;
|
|
21669
21687
|
}
|
|
21670
21688
|
ts.getParameterTypeNode = getParameterTypeNode;
|
|
21689
|
+
function isTypeDeclaration(node) {
|
|
21690
|
+
switch (node.kind) {
|
|
21691
|
+
case 165 /* SyntaxKind.TypeParameter */:
|
|
21692
|
+
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
21693
|
+
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
21694
|
+
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
21695
|
+
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
21696
|
+
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
21697
|
+
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
21698
|
+
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
21699
|
+
return true;
|
|
21700
|
+
case 270 /* SyntaxKind.ImportClause */:
|
|
21701
|
+
return node.isTypeOnly;
|
|
21702
|
+
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
21703
|
+
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
21704
|
+
return node.parent.parent.isTypeOnly;
|
|
21705
|
+
default:
|
|
21706
|
+
return false;
|
|
21707
|
+
}
|
|
21708
|
+
}
|
|
21709
|
+
ts.isTypeDeclaration = isTypeDeclaration;
|
|
21710
|
+
function canHaveExportModifier(node) {
|
|
21711
|
+
return ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node)
|
|
21712
|
+
|| ts.isInterfaceDeclaration(node) || isTypeDeclaration(node) || (ts.isModuleDeclaration(node) && !isExternalModuleAugmentation(node) && !isGlobalScopeAugmentation(node));
|
|
21713
|
+
}
|
|
21714
|
+
ts.canHaveExportModifier = canHaveExportModifier;
|
|
21671
21715
|
})(ts || (ts = {}));
|
|
21672
21716
|
/* @internal */
|
|
21673
21717
|
var ts;
|
|
@@ -21676,13 +21720,11 @@ var ts;
|
|
|
21676
21720
|
* Creates a `BaseNodeFactory` which can be used to create `Node` instances from the constructors provided by the object allocator.
|
|
21677
21721
|
*/
|
|
21678
21722
|
function createBaseNodeFactory() {
|
|
21679
|
-
// tslint:disable variable-name
|
|
21680
21723
|
var NodeConstructor;
|
|
21681
21724
|
var TokenConstructor;
|
|
21682
21725
|
var IdentifierConstructor;
|
|
21683
21726
|
var PrivateIdentifierConstructor;
|
|
21684
21727
|
var SourceFileConstructor;
|
|
21685
|
-
// tslint:enable variable-name
|
|
21686
21728
|
return {
|
|
21687
21729
|
createBaseSourceFileNode: createBaseSourceFileNode,
|
|
21688
21730
|
createBaseIdentifierNode: createBaseIdentifierNode,
|
|
@@ -23146,7 +23188,7 @@ var ts;
|
|
|
23146
23188
|
return node;
|
|
23147
23189
|
}
|
|
23148
23190
|
// @api
|
|
23149
|
-
function createIdentifier(text, typeArguments, originalKeywordKind) {
|
|
23191
|
+
function createIdentifier(text, typeArguments, originalKeywordKind, hasExtendedUnicodeEscape) {
|
|
23150
23192
|
var node = createBaseIdentifier(text, originalKeywordKind);
|
|
23151
23193
|
if (typeArguments) {
|
|
23152
23194
|
// NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
|
|
@@ -23155,6 +23197,10 @@ var ts;
|
|
|
23155
23197
|
if (node.originalKeywordKind === 133 /* SyntaxKind.AwaitKeyword */) {
|
|
23156
23198
|
node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */;
|
|
23157
23199
|
}
|
|
23200
|
+
if (hasExtendedUnicodeEscape) {
|
|
23201
|
+
node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
|
|
23202
|
+
node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
|
|
23203
|
+
}
|
|
23158
23204
|
return node;
|
|
23159
23205
|
}
|
|
23160
23206
|
// @api
|
|
@@ -27610,11 +27656,9 @@ var ts;
|
|
|
27610
27656
|
rawTextScanner.setText("`" + rawText + "`");
|
|
27611
27657
|
break;
|
|
27612
27658
|
case 15 /* SyntaxKind.TemplateHead */:
|
|
27613
|
-
// tslint:disable-next-line no-invalid-template-strings
|
|
27614
27659
|
rawTextScanner.setText("`" + rawText + "${");
|
|
27615
27660
|
break;
|
|
27616
27661
|
case 16 /* SyntaxKind.TemplateMiddle */:
|
|
27617
|
-
// tslint:disable-next-line no-invalid-template-strings
|
|
27618
27662
|
rawTextScanner.setText("}" + rawText + "${");
|
|
27619
27663
|
break;
|
|
27620
27664
|
case 17 /* SyntaxKind.TemplateTail */:
|
|
@@ -27973,7 +28017,6 @@ var ts;
|
|
|
27973
28017
|
return node;
|
|
27974
28018
|
}
|
|
27975
28019
|
ts.createInputFiles = createInputFiles;
|
|
27976
|
-
// tslint:disable-next-line variable-name
|
|
27977
28020
|
var SourceMapSource;
|
|
27978
28021
|
/**
|
|
27979
28022
|
* Create an external source map source file reference
|
|
@@ -28765,6 +28808,8 @@ var ts;
|
|
|
28765
28808
|
// - The verb (`next`, `throw`, or `return` method) to delegate to the expression
|
|
28766
28809
|
// of a `yield*`.
|
|
28767
28810
|
// - The result of evaluating the verb delegated to the expression of a `yield*`.
|
|
28811
|
+
// g A temporary variable that holds onto the generator object until the generator
|
|
28812
|
+
// is started, allowing it to also act as the `suspendedStart` state.
|
|
28768
28813
|
//
|
|
28769
28814
|
// functions:
|
|
28770
28815
|
// verb(n) Creates a bound callback to the `step` function for opcode `n`.
|
|
@@ -28803,7 +28848,7 @@ var ts;
|
|
|
28803
28848
|
importName: "__generator",
|
|
28804
28849
|
scoped: false,
|
|
28805
28850
|
priority: 6,
|
|
28806
|
-
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 };"
|
|
28851
|
+
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 };"
|
|
28807
28852
|
};
|
|
28808
28853
|
// ES Module Helpers
|
|
28809
28854
|
ts.createBindingHelper = {
|
|
@@ -32107,13 +32152,11 @@ var ts;
|
|
|
32107
32152
|
var scanner = ts.createScanner(99 /* ScriptTarget.Latest */, /*skipTrivia*/ true);
|
|
32108
32153
|
var disallowInAndDecoratorContext = 4096 /* NodeFlags.DisallowInContext */ | 16384 /* NodeFlags.DecoratorContext */;
|
|
32109
32154
|
// capture constructors in 'initializeState' to avoid null checks
|
|
32110
|
-
// tslint:disable variable-name
|
|
32111
32155
|
var NodeConstructor;
|
|
32112
32156
|
var TokenConstructor;
|
|
32113
32157
|
var IdentifierConstructor;
|
|
32114
32158
|
var PrivateIdentifierConstructor;
|
|
32115
32159
|
var SourceFileConstructor;
|
|
32116
|
-
// tslint:enable variable-name
|
|
32117
32160
|
function countNode(node) {
|
|
32118
32161
|
nodeCount++;
|
|
32119
32162
|
return node;
|
|
@@ -33089,8 +33132,9 @@ var ts;
|
|
|
33089
33132
|
// Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
|
|
33090
33133
|
var originalKeywordKind = token();
|
|
33091
33134
|
var text = internIdentifier(scanner.getTokenValue());
|
|
33135
|
+
var hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
|
|
33092
33136
|
nextTokenWithoutCheck();
|
|
33093
|
-
return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos);
|
|
33137
|
+
return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind, hasExtendedUnicodeEscape), pos);
|
|
33094
33138
|
}
|
|
33095
33139
|
if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
|
|
33096
33140
|
parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
@@ -42229,12 +42273,23 @@ var ts;
|
|
|
42229
42273
|
}
|
|
42230
42274
|
function writeConfigurations() {
|
|
42231
42275
|
// Filter applicable options to place in the file
|
|
42232
|
-
var categorizedOptions = ts.
|
|
42276
|
+
var categorizedOptions = new ts.Map();
|
|
42277
|
+
// Set allowed categories in order
|
|
42278
|
+
categorizedOptions.set(ts.Diagnostics.Projects, []);
|
|
42279
|
+
categorizedOptions.set(ts.Diagnostics.Language_and_Environment, []);
|
|
42280
|
+
categorizedOptions.set(ts.Diagnostics.Modules, []);
|
|
42281
|
+
categorizedOptions.set(ts.Diagnostics.JavaScript_Support, []);
|
|
42282
|
+
categorizedOptions.set(ts.Diagnostics.Emit, []);
|
|
42283
|
+
categorizedOptions.set(ts.Diagnostics.Interop_Constraints, []);
|
|
42284
|
+
categorizedOptions.set(ts.Diagnostics.Type_Checking, []);
|
|
42285
|
+
categorizedOptions.set(ts.Diagnostics.Completeness, []);
|
|
42233
42286
|
for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
|
|
42234
42287
|
var option = optionDeclarations_1[_i];
|
|
42235
|
-
var category = option.category;
|
|
42236
42288
|
if (isAllowedOptionForOutput(option)) {
|
|
42237
|
-
categorizedOptions.
|
|
42289
|
+
var listForCategory = categorizedOptions.get(option.category);
|
|
42290
|
+
if (!listForCategory)
|
|
42291
|
+
categorizedOptions.set(option.category, listForCategory = []);
|
|
42292
|
+
listForCategory.push(option);
|
|
42238
42293
|
}
|
|
42239
42294
|
}
|
|
42240
42295
|
// Serialize all options and their descriptions
|
|
@@ -42245,7 +42300,7 @@ var ts;
|
|
|
42245
42300
|
if (entries.length !== 0) {
|
|
42246
42301
|
entries.push({ value: "" });
|
|
42247
42302
|
}
|
|
42248
|
-
entries.push({ value: "/* ".concat(category, " */") });
|
|
42303
|
+
entries.push({ value: "/* ".concat(ts.getLocaleSpecificMessage(category), " */") });
|
|
42249
42304
|
for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
|
|
42250
42305
|
var option = options_1[_i];
|
|
42251
42306
|
var optionName = void 0;
|
|
@@ -44287,6 +44342,9 @@ var ts;
|
|
|
44287
44342
|
requestContainingDirectory: containingDirectory,
|
|
44288
44343
|
reportDiagnostic: function (diag) { return void diagnostics.push(diag); },
|
|
44289
44344
|
};
|
|
44345
|
+
if (traceEnabled && ts.getEmitModuleResolutionKind(compilerOptions) >= ts.ModuleResolutionKind.Node16 && ts.getEmitModuleResolutionKind(compilerOptions) <= ts.ModuleResolutionKind.NodeNext) {
|
|
44346
|
+
trace(host, ts.Diagnostics.Resolving_in_0_mode_with_conditions_1, features & NodeResolutionFeatures.EsmMode ? "ESM" : "CJS", conditions.map(function (c) { return "'".concat(c, "'"); }).join(", "));
|
|
44347
|
+
}
|
|
44290
44348
|
var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
|
|
44291
44349
|
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);
|
|
44292
44350
|
function tryResolve(extensions) {
|
|
@@ -44876,7 +44934,7 @@ var ts;
|
|
|
44876
44934
|
}
|
|
44877
44935
|
if (mainExport) {
|
|
44878
44936
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, subpath, scope, /*isImports*/ false);
|
|
44879
|
-
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false);
|
|
44937
|
+
return loadModuleFromTargetImportOrExport(mainExport, "", /*pattern*/ false, ".");
|
|
44880
44938
|
}
|
|
44881
44939
|
}
|
|
44882
44940
|
else if (allKeysStartWithDot(scope.contents.packageJsonContent.exports)) {
|
|
@@ -44956,7 +45014,7 @@ var ts;
|
|
|
44956
45014
|
var loadModuleFromTargetImportOrExport = getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports);
|
|
44957
45015
|
if (!ts.endsWith(moduleName, ts.directorySeparator) && moduleName.indexOf("*") === -1 && ts.hasProperty(lookupTable, moduleName)) {
|
|
44958
45016
|
var target = lookupTable[moduleName];
|
|
44959
|
-
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false);
|
|
45017
|
+
return loadModuleFromTargetImportOrExport(target, /*subpath*/ "", /*pattern*/ false, moduleName);
|
|
44960
45018
|
}
|
|
44961
45019
|
var expandingKeys = ts.sort(ts.filter(ts.getOwnKeys(lookupTable), function (k) { return k.indexOf("*") !== -1 || ts.endsWith(k, "/"); }), comparePatternKeys);
|
|
44962
45020
|
for (var _i = 0, expandingKeys_1 = expandingKeys; _i < expandingKeys_1.length; _i++) {
|
|
@@ -44965,17 +45023,17 @@ var ts;
|
|
|
44965
45023
|
var target = lookupTable[potentialTarget];
|
|
44966
45024
|
var starPos = potentialTarget.indexOf("*");
|
|
44967
45025
|
var subpath = moduleName.substring(potentialTarget.substring(0, starPos).length, moduleName.length - (potentialTarget.length - 1 - starPos));
|
|
44968
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
45026
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
|
|
44969
45027
|
}
|
|
44970
45028
|
else if (ts.endsWith(potentialTarget, "*") && ts.startsWith(moduleName, potentialTarget.substring(0, potentialTarget.length - 1))) {
|
|
44971
45029
|
var target = lookupTable[potentialTarget];
|
|
44972
45030
|
var subpath = moduleName.substring(potentialTarget.length - 1);
|
|
44973
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true);
|
|
45031
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ true, potentialTarget);
|
|
44974
45032
|
}
|
|
44975
45033
|
else if (ts.startsWith(moduleName, potentialTarget)) {
|
|
44976
45034
|
var target = lookupTable[potentialTarget];
|
|
44977
45035
|
var subpath = moduleName.substring(potentialTarget.length);
|
|
44978
|
-
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false);
|
|
45036
|
+
return loadModuleFromTargetImportOrExport(target, subpath, /*pattern*/ false, potentialTarget);
|
|
44979
45037
|
}
|
|
44980
45038
|
}
|
|
44981
45039
|
function matchesPatternWithTrailer(target, name) {
|
|
@@ -44992,7 +45050,7 @@ var ts;
|
|
|
44992
45050
|
*/
|
|
44993
45051
|
function getLoadModuleFromTargetImportOrExport(extensions, state, cache, redirectedReference, moduleName, scope, isImports) {
|
|
44994
45052
|
return loadModuleFromTargetImportOrExport;
|
|
44995
|
-
function loadModuleFromTargetImportOrExport(target, subpath, pattern) {
|
|
45053
|
+
function loadModuleFromTargetImportOrExport(target, subpath, pattern, key) {
|
|
44996
45054
|
if (typeof target === "string") {
|
|
44997
45055
|
if (!pattern && subpath.length > 0 && !ts.endsWith(target, "/")) {
|
|
44998
45056
|
if (state.traceEnabled) {
|
|
@@ -45003,6 +45061,8 @@ var ts;
|
|
|
45003
45061
|
if (!ts.startsWith(target, "./")) {
|
|
45004
45062
|
if (isImports && !ts.startsWith(target, "../") && !ts.startsWith(target, "/") && !ts.isRootedDiskPath(target)) {
|
|
45005
45063
|
var combinedLookup = pattern ? target.replace(/\*/g, subpath) : target + subpath;
|
|
45064
|
+
traceIfEnabled(state, ts.Diagnostics.Using_0_subpath_1_with_target_2, "imports", key, combinedLookup);
|
|
45065
|
+
traceIfEnabled(state, ts.Diagnostics.Resolving_module_0_from_1, combinedLookup, scope.packageDirectory + "/");
|
|
45006
45066
|
var result = nodeModuleNameResolverWorker(state.features, combinedLookup, scope.packageDirectory + "/", state.compilerOptions, state.host, cache, [extensions], redirectedReference);
|
|
45007
45067
|
return toSearchResult(result.resolvedModule ? { path: result.resolvedModule.resolvedFileName, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId, originalPath: result.resolvedModule.originalPath } : undefined);
|
|
45008
45068
|
}
|
|
@@ -45029,6 +45089,9 @@ var ts;
|
|
|
45029
45089
|
}
|
|
45030
45090
|
return toSearchResult(/*value*/ undefined);
|
|
45031
45091
|
}
|
|
45092
|
+
if (state.traceEnabled) {
|
|
45093
|
+
trace(state.host, ts.Diagnostics.Using_0_subpath_1_with_target_2, isImports ? "imports" : "exports", key, pattern ? target.replace(/\*/g, subpath) : target + subpath);
|
|
45094
|
+
}
|
|
45032
45095
|
var finalPath = toAbsolutePath(pattern ? resolvedTarget.replace(/\*/g, subpath) : resolvedTarget + subpath);
|
|
45033
45096
|
var inputLink = tryLoadInputFileForPath(finalPath, subpath, ts.combinePaths(scope.packageDirectory, "package.json"), isImports);
|
|
45034
45097
|
if (inputLink)
|
|
@@ -45038,14 +45101,18 @@ var ts;
|
|
|
45038
45101
|
else if (typeof target === "object" && target !== null) { // eslint-disable-line no-null/no-null
|
|
45039
45102
|
if (!Array.isArray(target)) {
|
|
45040
45103
|
for (var _i = 0, _a = ts.getOwnKeys(target); _i < _a.length; _i++) {
|
|
45041
|
-
var
|
|
45042
|
-
if (
|
|
45043
|
-
|
|
45044
|
-
var
|
|
45104
|
+
var condition = _a[_i];
|
|
45105
|
+
if (condition === "default" || state.conditions.indexOf(condition) >= 0 || isApplicableVersionedTypesKey(state.conditions, condition)) {
|
|
45106
|
+
traceIfEnabled(state, ts.Diagnostics.Matched_0_condition_1, isImports ? "imports" : "exports", condition);
|
|
45107
|
+
var subTarget = target[condition];
|
|
45108
|
+
var result = loadModuleFromTargetImportOrExport(subTarget, subpath, pattern, key);
|
|
45045
45109
|
if (result) {
|
|
45046
45110
|
return result;
|
|
45047
45111
|
}
|
|
45048
45112
|
}
|
|
45113
|
+
else {
|
|
45114
|
+
traceIfEnabled(state, ts.Diagnostics.Saw_non_matching_condition_0, condition);
|
|
45115
|
+
}
|
|
45049
45116
|
}
|
|
45050
45117
|
return undefined;
|
|
45051
45118
|
}
|
|
@@ -45058,7 +45125,7 @@ var ts;
|
|
|
45058
45125
|
}
|
|
45059
45126
|
for (var _b = 0, target_2 = target; _b < target_2.length; _b++) {
|
|
45060
45127
|
var elem = target_2[_b];
|
|
45061
|
-
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern);
|
|
45128
|
+
var result = loadModuleFromTargetImportOrExport(elem, subpath, pattern, key);
|
|
45062
45129
|
if (result) {
|
|
45063
45130
|
return result;
|
|
45064
45131
|
}
|
|
@@ -45474,6 +45541,15 @@ var ts;
|
|
|
45474
45541
|
function toSearchResult(value) {
|
|
45475
45542
|
return value !== undefined ? { value: value } : undefined;
|
|
45476
45543
|
}
|
|
45544
|
+
function traceIfEnabled(state, diagnostic) {
|
|
45545
|
+
var args = [];
|
|
45546
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
45547
|
+
args[_i - 2] = arguments[_i];
|
|
45548
|
+
}
|
|
45549
|
+
if (state.traceEnabled) {
|
|
45550
|
+
trace.apply(void 0, __spreadArray([state.host, diagnostic], args, false));
|
|
45551
|
+
}
|
|
45552
|
+
}
|
|
45477
45553
|
})(ts || (ts = {}));
|
|
45478
45554
|
/* @internal */
|
|
45479
45555
|
var ts;
|
|
@@ -49065,8 +49141,6 @@ var ts;
|
|
|
49065
49141
|
IntersectionState[IntersectionState["None"] = 0] = "None";
|
|
49066
49142
|
IntersectionState[IntersectionState["Source"] = 1] = "Source";
|
|
49067
49143
|
IntersectionState[IntersectionState["Target"] = 2] = "Target";
|
|
49068
|
-
IntersectionState[IntersectionState["PropertyCheck"] = 4] = "PropertyCheck";
|
|
49069
|
-
IntersectionState[IntersectionState["InPropertyCheck"] = 8] = "InPropertyCheck";
|
|
49070
49144
|
})(IntersectionState || (IntersectionState = {}));
|
|
49071
49145
|
var RecursionFlags;
|
|
49072
49146
|
(function (RecursionFlags) {
|
|
@@ -49485,6 +49559,12 @@ var ts;
|
|
|
49485
49559
|
getOptionalType: function () { return optionalType; },
|
|
49486
49560
|
getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
|
|
49487
49561
|
getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
|
|
49562
|
+
getAsyncIterableType: function () {
|
|
49563
|
+
var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
|
|
49564
|
+
if (type === emptyGenericType)
|
|
49565
|
+
return undefined;
|
|
49566
|
+
return type;
|
|
49567
|
+
},
|
|
49488
49568
|
isSymbolAccessible: isSymbolAccessible,
|
|
49489
49569
|
isArrayType: isArrayType,
|
|
49490
49570
|
isTupleType: isTupleType,
|
|
@@ -50322,9 +50402,9 @@ var ts;
|
|
|
50322
50402
|
return symbol;
|
|
50323
50403
|
}
|
|
50324
50404
|
if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
50325
|
-
var
|
|
50326
|
-
//
|
|
50327
|
-
if (
|
|
50405
|
+
var targetFlags = getAllSymbolFlags(symbol);
|
|
50406
|
+
// `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
|
|
50407
|
+
if (targetFlags & meaning) {
|
|
50328
50408
|
return symbol;
|
|
50329
50409
|
}
|
|
50330
50410
|
}
|
|
@@ -50957,8 +51037,8 @@ var ts;
|
|
|
50957
51037
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
50958
51038
|
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
50959
51039
|
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
51040
|
+
!checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
|
|
50960
51041
|
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
|
|
50961
|
-
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
50962
51042
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
50963
51043
|
var suggestion = void 0;
|
|
50964
51044
|
var suggestedLib = void 0;
|
|
@@ -51045,7 +51125,7 @@ var ts;
|
|
|
51045
51125
|
}
|
|
51046
51126
|
}
|
|
51047
51127
|
if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
51048
|
-
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
|
|
51128
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
|
|
51049
51129
|
if (typeOnlyDeclaration) {
|
|
51050
51130
|
var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
|
|
51051
51131
|
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
@@ -51208,7 +51288,7 @@ var ts;
|
|
|
51208
51288
|
return false;
|
|
51209
51289
|
}
|
|
51210
51290
|
function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
|
|
51211
|
-
if (meaning &
|
|
51291
|
+
if (meaning & 111551 /* SymbolFlags.Value */) {
|
|
51212
51292
|
if (isPrimitiveTypeName(name)) {
|
|
51213
51293
|
if (isExtendedByInterface(errorLocation)) {
|
|
51214
51294
|
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));
|
|
@@ -51219,7 +51299,8 @@ var ts;
|
|
|
51219
51299
|
return true;
|
|
51220
51300
|
}
|
|
51221
51301
|
var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51222
|
-
|
|
51302
|
+
var allFlags = symbol && getAllSymbolFlags(symbol);
|
|
51303
|
+
if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
|
|
51223
51304
|
var rawName = ts.unescapeLeadingUnderscores(name);
|
|
51224
51305
|
if (isES2015OrLaterConstructorName(name)) {
|
|
51225
51306
|
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);
|
|
@@ -51267,16 +51348,16 @@ var ts;
|
|
|
51267
51348
|
}
|
|
51268
51349
|
return false;
|
|
51269
51350
|
}
|
|
51270
|
-
function
|
|
51271
|
-
if (meaning & (111551 /* SymbolFlags.Value */ & ~
|
|
51272
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule
|
|
51351
|
+
function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
|
|
51352
|
+
if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
|
|
51353
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51273
51354
|
if (symbol) {
|
|
51274
51355
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
|
|
51275
51356
|
return true;
|
|
51276
51357
|
}
|
|
51277
51358
|
}
|
|
51278
|
-
else if (meaning & (788968 /* SymbolFlags.Type */ & ~
|
|
51279
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name,
|
|
51359
|
+
else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
|
|
51360
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51280
51361
|
if (symbol) {
|
|
51281
51362
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
|
|
51282
51363
|
return true;
|
|
@@ -51866,6 +51947,52 @@ var ts;
|
|
|
51866
51947
|
}
|
|
51867
51948
|
return undefined;
|
|
51868
51949
|
}
|
|
51950
|
+
/**
|
|
51951
|
+
* Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
|
|
51952
|
+
* is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
|
|
51953
|
+
* with another exported symbol, e.g.
|
|
51954
|
+
* ```ts
|
|
51955
|
+
* // a.ts
|
|
51956
|
+
* export const a = 0;
|
|
51957
|
+
* // b.ts
|
|
51958
|
+
* export { a } from "./a";
|
|
51959
|
+
* export type a = number;
|
|
51960
|
+
* // c.ts
|
|
51961
|
+
* import { a } from "./b";
|
|
51962
|
+
* ```
|
|
51963
|
+
* Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
|
|
51964
|
+
* from b.ts, even though there is still more alias to resolve. Consequently, if we were
|
|
51965
|
+
* trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
|
|
51966
|
+
* the local symbol and on the symbol returned by `resolveAlias` is not enough.
|
|
51967
|
+
* @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
|
|
51968
|
+
* combined flags of all alias targets otherwise.
|
|
51969
|
+
*/
|
|
51970
|
+
function getAllSymbolFlags(symbol) {
|
|
51971
|
+
var flags = symbol.flags;
|
|
51972
|
+
var seenSymbols;
|
|
51973
|
+
while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51974
|
+
var target = resolveAlias(symbol);
|
|
51975
|
+
if (target === unknownSymbol) {
|
|
51976
|
+
return 67108863 /* SymbolFlags.All */;
|
|
51977
|
+
}
|
|
51978
|
+
// Optimizations - try to avoid creating or adding to
|
|
51979
|
+
// `seenSymbols` if possible
|
|
51980
|
+
if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
|
|
51981
|
+
break;
|
|
51982
|
+
}
|
|
51983
|
+
if (target.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51984
|
+
if (seenSymbols) {
|
|
51985
|
+
seenSymbols.add(target);
|
|
51986
|
+
}
|
|
51987
|
+
else {
|
|
51988
|
+
seenSymbols = new ts.Set([symbol, target]);
|
|
51989
|
+
}
|
|
51990
|
+
}
|
|
51991
|
+
flags |= target.flags;
|
|
51992
|
+
symbol = target;
|
|
51993
|
+
}
|
|
51994
|
+
return flags;
|
|
51995
|
+
}
|
|
51869
51996
|
/**
|
|
51870
51997
|
* Marks a symbol as type-only if its declaration is syntactically type-only.
|
|
51871
51998
|
* If it is not itself marked type-only, but resolves to a type-only alias
|
|
@@ -51911,19 +52038,25 @@ var ts;
|
|
|
51911
52038
|
return !!aliasDeclarationLinks.typeOnlyDeclaration;
|
|
51912
52039
|
}
|
|
51913
52040
|
/** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
|
|
51914
|
-
function getTypeOnlyAliasDeclaration(symbol) {
|
|
52041
|
+
function getTypeOnlyAliasDeclaration(symbol, include) {
|
|
51915
52042
|
if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
|
|
51916
52043
|
return undefined;
|
|
51917
52044
|
}
|
|
51918
52045
|
var links = getSymbolLinks(symbol);
|
|
51919
|
-
|
|
52046
|
+
if (include === undefined) {
|
|
52047
|
+
return links.typeOnlyDeclaration || undefined;
|
|
52048
|
+
}
|
|
52049
|
+
if (links.typeOnlyDeclaration) {
|
|
52050
|
+
return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
|
|
52051
|
+
}
|
|
52052
|
+
return undefined;
|
|
51920
52053
|
}
|
|
51921
52054
|
function markExportAsReferenced(node) {
|
|
51922
52055
|
var symbol = getSymbolOfNode(node);
|
|
51923
52056
|
var target = resolveAlias(symbol);
|
|
51924
52057
|
if (target) {
|
|
51925
52058
|
var markAlias = target === unknownSymbol ||
|
|
51926
|
-
((target
|
|
52059
|
+
((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
|
|
51927
52060
|
if (markAlias) {
|
|
51928
52061
|
markAliasSymbolAsReferenced(symbol);
|
|
51929
52062
|
}
|
|
@@ -51943,8 +52076,7 @@ var ts;
|
|
|
51943
52076
|
// This way a chain of imports can be elided if ultimately the final input is only used in a type
|
|
51944
52077
|
// position.
|
|
51945
52078
|
if (ts.isInternalModuleImportEqualsDeclaration(node)) {
|
|
51946
|
-
|
|
51947
|
-
if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
|
|
52079
|
+
if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
|
|
51948
52080
|
// import foo = <symbol>
|
|
51949
52081
|
checkExpressionCached(node.moduleReference);
|
|
51950
52082
|
}
|
|
@@ -52766,7 +52898,7 @@ var ts;
|
|
|
52766
52898
|
}
|
|
52767
52899
|
function symbolIsValue(symbol, includeTypeOnlyMembers) {
|
|
52768
52900
|
return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
|
|
52769
|
-
symbol.flags & 2097152 /* SymbolFlags.Alias */ &&
|
|
52901
|
+
symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
|
|
52770
52902
|
}
|
|
52771
52903
|
function findConstructorDeclaration(node) {
|
|
52772
52904
|
var members = node.members;
|
|
@@ -53035,8 +53167,10 @@ var ts;
|
|
|
53035
53167
|
return true;
|
|
53036
53168
|
}
|
|
53037
53169
|
// Qualify if the symbol from symbol table has same meaning as expected
|
|
53038
|
-
|
|
53039
|
-
|
|
53170
|
+
var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
|
|
53171
|
+
symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
|
|
53172
|
+
var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
|
|
53173
|
+
if (flags & meaning) {
|
|
53040
53174
|
qualify = true;
|
|
53041
53175
|
return true;
|
|
53042
53176
|
}
|
|
@@ -55348,7 +55482,7 @@ var ts;
|
|
|
55348
55482
|
// export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it
|
|
55349
55483
|
var indices = ts.indicesOf(statements);
|
|
55350
55484
|
var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
|
|
55351
|
-
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
|
|
55485
|
+
if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return ts.canHaveExportModifier(statements[i]); })) {
|
|
55352
55486
|
for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
|
|
55353
55487
|
var index_1 = associatedIndices_1[_i];
|
|
55354
55488
|
statements[index_1] = addExportModifier(statements[index_1]);
|
|
@@ -55382,15 +55516,6 @@ var ts;
|
|
|
55382
55516
|
}
|
|
55383
55517
|
return statements;
|
|
55384
55518
|
}
|
|
55385
|
-
function canHaveExportModifier(node) {
|
|
55386
|
-
return ts.isEnumDeclaration(node) ||
|
|
55387
|
-
ts.isVariableStatement(node) ||
|
|
55388
|
-
ts.isFunctionDeclaration(node) ||
|
|
55389
|
-
ts.isClassDeclaration(node) ||
|
|
55390
|
-
(ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
|
|
55391
|
-
ts.isInterfaceDeclaration(node) ||
|
|
55392
|
-
isTypeDeclaration(node);
|
|
55393
|
-
}
|
|
55394
55519
|
function addExportModifier(node) {
|
|
55395
55520
|
var flags = (ts.getEffectiveModifierFlags(node) | 1 /* ModifierFlags.Export */) & ~2 /* ModifierFlags.Ambient */;
|
|
55396
55521
|
return ts.factory.updateModifiers(node, flags);
|
|
@@ -55637,7 +55762,7 @@ var ts;
|
|
|
55637
55762
|
(ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
|
|
55638
55763
|
if (additionalModifierFlags & 1 /* ModifierFlags.Export */ &&
|
|
55639
55764
|
enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
|
|
55640
|
-
canHaveExportModifier(node)) {
|
|
55765
|
+
ts.canHaveExportModifier(node)) {
|
|
55641
55766
|
// Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private
|
|
55642
55767
|
newModifierFlags |= 1 /* ModifierFlags.Export */;
|
|
55643
55768
|
}
|
|
@@ -55693,7 +55818,7 @@ var ts;
|
|
|
55693
55818
|
return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
|
|
55694
55819
|
}
|
|
55695
55820
|
function isTypeOnlyNamespace(symbol) {
|
|
55696
|
-
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m)
|
|
55821
|
+
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
|
|
55697
55822
|
}
|
|
55698
55823
|
function serializeModule(symbol, symbolName, modifierFlags) {
|
|
55699
55824
|
var members = getNamespaceMembersForSerialization(symbol);
|
|
@@ -57913,7 +58038,7 @@ var ts;
|
|
|
57913
58038
|
links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
|
|
57914
58039
|
: isDuplicatedCommonJSExport(symbol.declarations) ? autoType
|
|
57915
58040
|
: declaredType ? declaredType
|
|
57916
|
-
: targetSymbol
|
|
58041
|
+
: getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
|
|
57917
58042
|
: errorType;
|
|
57918
58043
|
}
|
|
57919
58044
|
return links.type;
|
|
@@ -59796,7 +59921,20 @@ var ts;
|
|
|
59796
59921
|
return !!(ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */ && getMappedTypeModifiers(type) & 4 /* MappedTypeModifiers.IncludeOptional */);
|
|
59797
59922
|
}
|
|
59798
59923
|
function isGenericMappedType(type) {
|
|
59799
|
-
|
|
59924
|
+
if (ts.getObjectFlags(type) & 32 /* ObjectFlags.Mapped */) {
|
|
59925
|
+
var constraint = getConstraintTypeFromMappedType(type);
|
|
59926
|
+
if (isGenericIndexType(constraint)) {
|
|
59927
|
+
return true;
|
|
59928
|
+
}
|
|
59929
|
+
// A mapped type is generic if the 'as' clause references generic types other than the iteration type.
|
|
59930
|
+
// To determine this, we substitute the constraint type (that we now know isn't generic) for the iteration
|
|
59931
|
+
// type and check whether the resulting type is generic.
|
|
59932
|
+
var nameType = getNameTypeFromMappedType(type);
|
|
59933
|
+
if (nameType && isGenericIndexType(instantiateType(nameType, makeUnaryTypeMapper(getTypeParameterFromMappedType(type), constraint)))) {
|
|
59934
|
+
return true;
|
|
59935
|
+
}
|
|
59936
|
+
}
|
|
59937
|
+
return false;
|
|
59800
59938
|
}
|
|
59801
59939
|
function resolveStructuredTypeMembers(type) {
|
|
59802
59940
|
if (!type.members) {
|
|
@@ -60266,7 +60404,7 @@ var ts;
|
|
|
60266
60404
|
var indexTypes;
|
|
60267
60405
|
var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
|
|
60268
60406
|
// Flags we want to propagate to the result if they exist in all source symbols
|
|
60269
|
-
var optionalFlag
|
|
60407
|
+
var optionalFlag;
|
|
60270
60408
|
var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
|
|
60271
60409
|
var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
|
|
60272
60410
|
var mergedInstantiations = false;
|
|
@@ -60277,11 +60415,14 @@ var ts;
|
|
|
60277
60415
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
60278
60416
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
60279
60417
|
if (prop) {
|
|
60280
|
-
if (
|
|
60281
|
-
optionalFlag
|
|
60282
|
-
|
|
60283
|
-
|
|
60284
|
-
|
|
60418
|
+
if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
|
|
60419
|
+
optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
|
|
60420
|
+
if (isUnion) {
|
|
60421
|
+
optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
|
|
60422
|
+
}
|
|
60423
|
+
else {
|
|
60424
|
+
optionalFlag &= prop.flags;
|
|
60425
|
+
}
|
|
60285
60426
|
}
|
|
60286
60427
|
if (!singleProp) {
|
|
60287
60428
|
singleProp = prop;
|
|
@@ -60400,7 +60541,7 @@ var ts;
|
|
|
60400
60541
|
propTypes.push(type);
|
|
60401
60542
|
}
|
|
60402
60543
|
ts.addRange(propTypes, indexTypes);
|
|
60403
|
-
var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
|
|
60544
|
+
var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
|
|
60404
60545
|
result.containingType = containingType;
|
|
60405
60546
|
if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
|
|
60406
60547
|
result.valueDeclaration = firstValueDeclaration;
|
|
@@ -63113,8 +63254,14 @@ var ts;
|
|
|
63113
63254
|
return getStringLiteralType(text);
|
|
63114
63255
|
}
|
|
63115
63256
|
newTexts.push(text);
|
|
63116
|
-
if (ts.every(newTexts, function (t) { return t === ""; })
|
|
63117
|
-
return
|
|
63257
|
+
if (ts.every(newTexts, function (t) { return t === ""; })) {
|
|
63258
|
+
if (ts.every(newTypes, function (t) { return !!(t.flags & 4 /* TypeFlags.String */); })) {
|
|
63259
|
+
return stringType;
|
|
63260
|
+
}
|
|
63261
|
+
// Normalize `${Mapping<xxx>}` into Mapping<xxx>
|
|
63262
|
+
if (newTypes.length === 1 && isPatternLiteralType(newTypes[0])) {
|
|
63263
|
+
return newTypes[0];
|
|
63264
|
+
}
|
|
63118
63265
|
}
|
|
63119
63266
|
var id = "".concat(getTypeListId(newTypes), "|").concat(ts.map(newTexts, function (t) { return t.length; }).join(","), "|").concat(newTexts.join(""));
|
|
63120
63267
|
var type = templateLiteralTypes.get(id);
|
|
@@ -63173,12 +63320,14 @@ var ts;
|
|
|
63173
63320
|
}
|
|
63174
63321
|
function getStringMappingType(symbol, type) {
|
|
63175
63322
|
return type.flags & (1048576 /* TypeFlags.Union */ | 131072 /* TypeFlags.Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
63176
|
-
|
|
63177
|
-
|
|
63178
|
-
|
|
63179
|
-
type.flags &
|
|
63180
|
-
type.flags &
|
|
63181
|
-
|
|
63323
|
+
type.flags & 128 /* TypeFlags.StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
63324
|
+
type.flags & 134217728 /* TypeFlags.TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
63325
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
63326
|
+
type.flags & 268435456 /* TypeFlags.StringMapping */ && symbol === type.symbol ? type :
|
|
63327
|
+
type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 268435456 /* TypeFlags.StringMapping */) || isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
|
|
63328
|
+
// This handles Mapping<`${number}`> and Mapping<`${bigint}`>
|
|
63329
|
+
isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, getTemplateLiteralType(["", ""], [type])) :
|
|
63330
|
+
type;
|
|
63182
63331
|
}
|
|
63183
63332
|
function applyStringMapping(symbol, str) {
|
|
63184
63333
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -63343,7 +63492,18 @@ var ts;
|
|
|
63343
63492
|
return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
|
|
63344
63493
|
}
|
|
63345
63494
|
errorIfWritingToReadonlyIndex(indexInfo);
|
|
63346
|
-
|
|
63495
|
+
// When accessing an enum object with its own type,
|
|
63496
|
+
// e.g. E[E.A] for enum E { A }, undefined shouldn't
|
|
63497
|
+
// be included in the result type
|
|
63498
|
+
if ((accessFlags & 1 /* AccessFlags.IncludeUndefined */) &&
|
|
63499
|
+
!(objectType.symbol &&
|
|
63500
|
+
objectType.symbol.flags & (256 /* SymbolFlags.RegularEnum */ | 128 /* SymbolFlags.ConstEnum */) &&
|
|
63501
|
+
(indexType.symbol &&
|
|
63502
|
+
indexType.flags & 1024 /* TypeFlags.EnumLiteral */ &&
|
|
63503
|
+
getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
|
|
63504
|
+
return getUnionType([indexInfo.type, undefinedType]);
|
|
63505
|
+
}
|
|
63506
|
+
return indexInfo.type;
|
|
63347
63507
|
}
|
|
63348
63508
|
if (indexType.flags & 131072 /* TypeFlags.Never */) {
|
|
63349
63509
|
return neverType;
|
|
@@ -63446,10 +63606,11 @@ var ts;
|
|
|
63446
63606
|
accessNode;
|
|
63447
63607
|
}
|
|
63448
63608
|
function isPatternLiteralPlaceholderType(type) {
|
|
63449
|
-
return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) ||
|
|
63609
|
+
return !!(type.flags & (1 /* TypeFlags.Any */ | 4 /* TypeFlags.String */ | 8 /* TypeFlags.Number */ | 64 /* TypeFlags.BigInt */)) || isPatternLiteralType(type);
|
|
63450
63610
|
}
|
|
63451
63611
|
function isPatternLiteralType(type) {
|
|
63452
|
-
return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType)
|
|
63612
|
+
return !!(type.flags & 134217728 /* TypeFlags.TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType) ||
|
|
63613
|
+
!!(type.flags & 268435456 /* TypeFlags.StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
63453
63614
|
}
|
|
63454
63615
|
function isGenericType(type) {
|
|
63455
63616
|
return !!getGenericObjectFlags(type);
|
|
@@ -63728,18 +63889,23 @@ var ts;
|
|
|
63728
63889
|
var result;
|
|
63729
63890
|
var extraTypes;
|
|
63730
63891
|
var tailCount = 0;
|
|
63731
|
-
|
|
63892
|
+
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63893
|
+
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63894
|
+
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63895
|
+
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63896
|
+
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63897
|
+
while (true) {
|
|
63732
63898
|
if (tailCount === 1000) {
|
|
63733
63899
|
error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
|
|
63734
63900
|
result = errorType;
|
|
63735
|
-
|
|
63901
|
+
break;
|
|
63736
63902
|
}
|
|
63737
63903
|
var isUnwrapped = isTypicalNondistributiveConditional(root);
|
|
63738
63904
|
var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, getActualTypeVariable(root.checkType)), mapper);
|
|
63739
63905
|
var checkTypeInstantiable = isGenericType(checkType);
|
|
63740
63906
|
var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
|
|
63741
63907
|
if (checkType === wildcardType || extendsType === wildcardType) {
|
|
63742
|
-
return
|
|
63908
|
+
return wildcardType;
|
|
63743
63909
|
}
|
|
63744
63910
|
var combinedMapper = void 0;
|
|
63745
63911
|
if (root.inferTypeParameters) {
|
|
@@ -63772,11 +63938,7 @@ var ts;
|
|
|
63772
63938
|
}
|
|
63773
63939
|
}
|
|
63774
63940
|
}
|
|
63775
|
-
|
|
63776
|
-
// if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
|
|
63777
|
-
// "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
|
|
63778
|
-
// so in those cases we refain from performing inference and retain the uninfered type parameter
|
|
63779
|
-
if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
|
|
63941
|
+
if (!checkTypeInstantiable) {
|
|
63780
63942
|
// We don't want inferences from constraints as they may cause us to eagerly resolve the
|
|
63781
63943
|
// conditional type instead of deferring resolution. Also, we always want strict function
|
|
63782
63944
|
// types rules (i.e. proper contravariance) for inferences.
|
|
@@ -63808,14 +63970,14 @@ var ts;
|
|
|
63808
63970
|
var newRoot = falseType_1.root;
|
|
63809
63971
|
if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
|
|
63810
63972
|
root = newRoot;
|
|
63811
|
-
|
|
63973
|
+
continue;
|
|
63812
63974
|
}
|
|
63813
63975
|
if (canTailRecurse(falseType_1, mapper)) {
|
|
63814
|
-
|
|
63976
|
+
continue;
|
|
63815
63977
|
}
|
|
63816
63978
|
}
|
|
63817
63979
|
result = instantiateType(falseType_1, mapper);
|
|
63818
|
-
|
|
63980
|
+
break;
|
|
63819
63981
|
}
|
|
63820
63982
|
// Return trueType for a definitely true extends check. We check instantiations of the two
|
|
63821
63983
|
// types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
|
|
@@ -63826,10 +63988,10 @@ var ts;
|
|
|
63826
63988
|
var trueType_1 = getTypeFromTypeNode(root.node.trueType);
|
|
63827
63989
|
var trueMapper = combinedMapper || mapper;
|
|
63828
63990
|
if (canTailRecurse(trueType_1, trueMapper)) {
|
|
63829
|
-
|
|
63991
|
+
continue;
|
|
63830
63992
|
}
|
|
63831
63993
|
result = instantiateType(trueType_1, trueMapper);
|
|
63832
|
-
|
|
63994
|
+
break;
|
|
63833
63995
|
}
|
|
63834
63996
|
}
|
|
63835
63997
|
// Return a deferred type for a check that is neither definitely true nor definitely false
|
|
@@ -63841,19 +64003,7 @@ var ts;
|
|
|
63841
64003
|
result.combinedMapper = combinedMapper;
|
|
63842
64004
|
result.aliasSymbol = aliasSymbol || root.aliasSymbol;
|
|
63843
64005
|
result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper); // TODO: GH#18217
|
|
63844
|
-
|
|
63845
|
-
};
|
|
63846
|
-
// We loop here for an immediately nested conditional type in the false position, effectively treating
|
|
63847
|
-
// types of the form 'A extends B ? X : C extends D ? Y : E extends F ? Z : ...' as a single construct for
|
|
63848
|
-
// purposes of resolution. We also loop here when resolution of a conditional type ends in resolution of
|
|
63849
|
-
// another (or, through recursion, possibly the same) conditional type. In the potentially tail-recursive
|
|
63850
|
-
// cases we increment the tail recursion counter and stop after 1000 iterations.
|
|
63851
|
-
while (true) {
|
|
63852
|
-
var state_6 = _loop_20();
|
|
63853
|
-
if (typeof state_6 === "object")
|
|
63854
|
-
return state_6.value;
|
|
63855
|
-
if (state_6 === "break")
|
|
63856
|
-
break;
|
|
64006
|
+
break;
|
|
63857
64007
|
}
|
|
63858
64008
|
return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
|
|
63859
64009
|
// We tail-recurse for generic conditional types that (a) have not already been evaluated and cached, and
|
|
@@ -66307,7 +66457,7 @@ var ts;
|
|
|
66307
66457
|
return 0 /* Ternary.False */;
|
|
66308
66458
|
}
|
|
66309
66459
|
}
|
|
66310
|
-
var isPerformingCommonPropertyChecks = (relation !== comparableRelation ||
|
|
66460
|
+
var isPerformingCommonPropertyChecks = (relation !== comparableRelation || isUnitType(source)) &&
|
|
66311
66461
|
!(intersectionState & 2 /* IntersectionState.Target */) &&
|
|
66312
66462
|
source.flags & (131068 /* TypeFlags.Primitive */ | 524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && source !== globalObjectType &&
|
|
66313
66463
|
target.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) && isWeakType(target) &&
|
|
@@ -66335,27 +66485,6 @@ var ts;
|
|
|
66335
66485
|
var result_7 = skipCaching ?
|
|
66336
66486
|
unionOrIntersectionRelatedTo(source, target, reportErrors, intersectionState) :
|
|
66337
66487
|
recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags);
|
|
66338
|
-
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
66339
|
-
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
66340
|
-
// examples that all should be errors, but aren't without this extra property check:
|
|
66341
|
-
//
|
|
66342
|
-
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
66343
|
-
//
|
|
66344
|
-
// declare let wrong: { a: { y: string } };
|
|
66345
|
-
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
66346
|
-
//
|
|
66347
|
-
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
66348
|
-
// x = y; // Mismatched property in source intersection
|
|
66349
|
-
// }
|
|
66350
|
-
//
|
|
66351
|
-
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
66352
|
-
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
66353
|
-
if (result_7 && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
|
|
66354
|
-
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 */); }))) {
|
|
66355
|
-
inPropertyCheck = true;
|
|
66356
|
-
result_7 &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* IntersectionState.PropertyCheck */, recursionFlags);
|
|
66357
|
-
inPropertyCheck = false;
|
|
66358
|
-
}
|
|
66359
66488
|
if (result_7) {
|
|
66360
66489
|
return result_7;
|
|
66361
66490
|
}
|
|
@@ -66467,7 +66596,7 @@ var ts;
|
|
|
66467
66596
|
reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
|
|
66468
66597
|
checkTypes = reducedTarget.flags & 1048576 /* TypeFlags.Union */ ? reducedTarget.types : [reducedTarget];
|
|
66469
66598
|
}
|
|
66470
|
-
var
|
|
66599
|
+
var _loop_20 = function (prop) {
|
|
66471
66600
|
if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
|
|
66472
66601
|
if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
|
|
66473
66602
|
if (reportErrors) {
|
|
@@ -66530,9 +66659,9 @@ var ts;
|
|
|
66530
66659
|
};
|
|
66531
66660
|
for (var _i = 0, _b = getPropertiesOfType(source); _i < _b.length; _i++) {
|
|
66532
66661
|
var prop = _b[_i];
|
|
66533
|
-
var
|
|
66534
|
-
if (typeof
|
|
66535
|
-
return
|
|
66662
|
+
var state_6 = _loop_20(prop);
|
|
66663
|
+
if (typeof state_6 === "object")
|
|
66664
|
+
return state_6.value;
|
|
66536
66665
|
}
|
|
66537
66666
|
return false;
|
|
66538
66667
|
}
|
|
@@ -66753,8 +66882,7 @@ var ts;
|
|
|
66753
66882
|
if (overflow) {
|
|
66754
66883
|
return 0 /* Ternary.False */;
|
|
66755
66884
|
}
|
|
66756
|
-
var
|
|
66757
|
-
var id = getRelationKey(source, target, keyIntersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66885
|
+
var id = getRelationKey(source, target, intersectionState, relation, /*ingnoreConstraints*/ false);
|
|
66758
66886
|
var entry = relation.get(id);
|
|
66759
66887
|
if (entry !== undefined) {
|
|
66760
66888
|
if (reportErrors && entry & 2 /* RelationComparisonResult.Failed */ && !(entry & 4 /* RelationComparisonResult.Reported */)) {
|
|
@@ -66784,7 +66912,7 @@ var ts;
|
|
|
66784
66912
|
// A key that starts with "*" is an indication that we have type references that reference constrained
|
|
66785
66913
|
// type parameters. For such keys we also check against the key we would have gotten if all type parameters
|
|
66786
66914
|
// were unconstrained.
|
|
66787
|
-
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target,
|
|
66915
|
+
var broadestEquivalentId = id.startsWith("*") ? getRelationKey(source, target, intersectionState, relation, /*ignoreConstraints*/ true) : undefined;
|
|
66788
66916
|
for (var i = 0; i < maybeCount; i++) {
|
|
66789
66917
|
// If source and target are already being compared, consider them related with assumptions
|
|
66790
66918
|
if (id === maybeKeys[i] || broadestEquivalentId && broadestEquivalentId === maybeKeys[i]) {
|
|
@@ -66871,7 +66999,7 @@ var ts;
|
|
|
66871
66999
|
function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
|
|
66872
67000
|
var saveErrorInfo = captureErrorCalculationState();
|
|
66873
67001
|
var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo);
|
|
66874
|
-
if (
|
|
67002
|
+
if (relation !== identityRelation) {
|
|
66875
67003
|
// The combined constraint of an intersection type is the intersection of the constraints of
|
|
66876
67004
|
// the constituents. When an intersection type contains instantiable types with union type
|
|
66877
67005
|
// constraints, there are situations where we need to examine the combined constraint. One is
|
|
@@ -66885,10 +67013,33 @@ var ts;
|
|
|
66885
67013
|
// needs to have its constraint hoisted into an intersection with said type parameter, this way
|
|
66886
67014
|
// the type param can be compared with itself in the target (with the influence of its constraint to match other parts)
|
|
66887
67015
|
// For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)`
|
|
66888
|
-
|
|
66889
|
-
|
|
66890
|
-
|
|
66891
|
-
|
|
67016
|
+
if (!result && (source.flags & 2097152 /* TypeFlags.Intersection */ || source.flags & 262144 /* TypeFlags.TypeParameter */ && target.flags & 1048576 /* TypeFlags.Union */)) {
|
|
67017
|
+
var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* TypeFlags.Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* TypeFlags.Union */));
|
|
67018
|
+
if (constraint && everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself
|
|
67019
|
+
// TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this
|
|
67020
|
+
result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false, /*headMessage*/ undefined, intersectionState);
|
|
67021
|
+
}
|
|
67022
|
+
}
|
|
67023
|
+
// For certain combinations involving intersections and optional, excess, or mismatched properties we need
|
|
67024
|
+
// an extra property check where the intersection is viewed as a single object. The following are motivating
|
|
67025
|
+
// examples that all should be errors, but aren't without this extra property check:
|
|
67026
|
+
//
|
|
67027
|
+
// let obj: { a: { x: string } } & { c: number } = { a: { x: 'hello', y: 2 }, c: 5 }; // Nested excess property
|
|
67028
|
+
//
|
|
67029
|
+
// declare let wrong: { a: { y: string } };
|
|
67030
|
+
// let weak: { a?: { x?: number } } & { c?: string } = wrong; // Nested weak object type
|
|
67031
|
+
//
|
|
67032
|
+
// function foo<T extends object>(x: { a?: string }, y: T & { a: boolean }) {
|
|
67033
|
+
// x = y; // Mismatched property in source intersection
|
|
67034
|
+
// }
|
|
67035
|
+
//
|
|
67036
|
+
// We suppress recursive intersection property checks because they can generate lots of work when relating
|
|
67037
|
+
// recursive intersections that are structurally similar but not exactly identical. See #37854.
|
|
67038
|
+
if (result && !inPropertyCheck && (target.flags & 2097152 /* TypeFlags.Intersection */ && !isGenericObjectType(target) && source.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */) ||
|
|
67039
|
+
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 */); }))) {
|
|
67040
|
+
inPropertyCheck = true;
|
|
67041
|
+
result &= propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
67042
|
+
inPropertyCheck = false;
|
|
66892
67043
|
}
|
|
66893
67044
|
}
|
|
66894
67045
|
if (result) {
|
|
@@ -66897,9 +67048,6 @@ var ts;
|
|
|
66897
67048
|
return result;
|
|
66898
67049
|
}
|
|
66899
67050
|
function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState, saveErrorInfo) {
|
|
66900
|
-
if (intersectionState & 4 /* IntersectionState.PropertyCheck */) {
|
|
66901
|
-
return propertiesRelatedTo(source, target, reportErrors, /*excludedProperties*/ undefined, 0 /* IntersectionState.None */);
|
|
66902
|
-
}
|
|
66903
67051
|
var result;
|
|
66904
67052
|
var originalErrorInfo;
|
|
66905
67053
|
var varianceCheckFailed = false;
|
|
@@ -67000,7 +67148,7 @@ var ts;
|
|
|
67000
67148
|
// with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
|
|
67001
67149
|
var constraint = getConstraintOfTypeParameter(source);
|
|
67002
67150
|
if (constraint && hasNonCircularBaseConstraint(source)) {
|
|
67003
|
-
while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
|
|
67151
|
+
while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
|
|
67004
67152
|
if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
|
|
67005
67153
|
return result;
|
|
67006
67154
|
}
|
|
@@ -67523,11 +67671,11 @@ var ts;
|
|
|
67523
67671
|
// constituents of 'target'. If any combination does not have a match then 'source' is not relatable.
|
|
67524
67672
|
var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
|
|
67525
67673
|
var matchingTypes = [];
|
|
67526
|
-
var
|
|
67674
|
+
var _loop_21 = function (combination) {
|
|
67527
67675
|
var hasMatch = false;
|
|
67528
67676
|
outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
|
|
67529
67677
|
var type = _d[_c];
|
|
67530
|
-
var
|
|
67678
|
+
var _loop_22 = function (i) {
|
|
67531
67679
|
var sourceProperty = sourcePropertiesFiltered[i];
|
|
67532
67680
|
var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
|
|
67533
67681
|
if (!targetProperty)
|
|
@@ -67543,8 +67691,8 @@ var ts;
|
|
|
67543
67691
|
}
|
|
67544
67692
|
};
|
|
67545
67693
|
for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
|
|
67546
|
-
var
|
|
67547
|
-
switch (
|
|
67694
|
+
var state_8 = _loop_22(i);
|
|
67695
|
+
switch (state_8) {
|
|
67548
67696
|
case "continue-outer": continue outer;
|
|
67549
67697
|
}
|
|
67550
67698
|
}
|
|
@@ -67557,9 +67705,9 @@ var ts;
|
|
|
67557
67705
|
};
|
|
67558
67706
|
for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
|
|
67559
67707
|
var combination = discriminantCombinations_1[_a];
|
|
67560
|
-
var
|
|
67561
|
-
if (typeof
|
|
67562
|
-
return
|
|
67708
|
+
var state_7 = _loop_21(combination);
|
|
67709
|
+
if (typeof state_7 === "object")
|
|
67710
|
+
return state_7.value;
|
|
67563
67711
|
}
|
|
67564
67712
|
// Compare the remaining non-discriminant properties of each match.
|
|
67565
67713
|
var result = -1 /* Ternary.True */;
|
|
@@ -67656,7 +67804,7 @@ var ts;
|
|
|
67656
67804
|
return 0 /* Ternary.False */;
|
|
67657
67805
|
}
|
|
67658
67806
|
// When checking for comparability, be more lenient with optional properties.
|
|
67659
|
-
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67807
|
+
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67660
67808
|
// TypeScript 1.0 spec (April 2014): 3.8.3
|
|
67661
67809
|
// S is a subtype of a type T, and T is a supertype of S if ...
|
|
67662
67810
|
// S' and T are object types and, for each member M in T..
|
|
@@ -68264,7 +68412,7 @@ var ts;
|
|
|
68264
68412
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* tracing.Phase.CheckTypes */, "getVariancesWorker", { arity: typeParameters.length, id: getTypeId(getDeclaredTypeOfSymbol(symbol)) });
|
|
68265
68413
|
links.variances = ts.emptyArray;
|
|
68266
68414
|
var variances = [];
|
|
68267
|
-
var
|
|
68415
|
+
var _loop_23 = function (tp) {
|
|
68268
68416
|
var modifiers = getVarianceModifiers(tp);
|
|
68269
68417
|
var variance = modifiers & 65536 /* ModifierFlags.Out */ ?
|
|
68270
68418
|
modifiers & 32768 /* ModifierFlags.In */ ? 0 /* VarianceFlags.Invariant */ : 1 /* VarianceFlags.Covariant */ :
|
|
@@ -68302,7 +68450,7 @@ var ts;
|
|
|
68302
68450
|
};
|
|
68303
68451
|
for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
|
|
68304
68452
|
var tp = typeParameters_2[_i];
|
|
68305
|
-
|
|
68453
|
+
_loop_23(tp);
|
|
68306
68454
|
}
|
|
68307
68455
|
links.variances = variances;
|
|
68308
68456
|
ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
|
|
@@ -68756,8 +68904,7 @@ var ts;
|
|
|
68756
68904
|
return !!(type.flags & 109440 /* TypeFlags.Unit */);
|
|
68757
68905
|
}
|
|
68758
68906
|
function isUnitLikeType(type) {
|
|
68759
|
-
return
|
|
68760
|
-
!!(type.flags & 109440 /* TypeFlags.Unit */);
|
|
68907
|
+
return isUnitType(getBaseConstraintOrType(type));
|
|
68761
68908
|
}
|
|
68762
68909
|
function extractUnitType(type) {
|
|
68763
68910
|
return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type;
|
|
@@ -69636,7 +69783,7 @@ var ts;
|
|
|
69636
69783
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
69637
69784
|
}
|
|
69638
69785
|
function isMemberOfStringMapping(source, target) {
|
|
69639
|
-
if (target.flags & (4 /* TypeFlags.String */ |
|
|
69786
|
+
if (target.flags & (4 /* TypeFlags.String */ | 1 /* TypeFlags.Any */)) {
|
|
69640
69787
|
return true;
|
|
69641
69788
|
}
|
|
69642
69789
|
if (target.flags & 134217728 /* TypeFlags.TemplateLiteral */) {
|
|
@@ -70260,7 +70407,7 @@ var ts;
|
|
|
70260
70407
|
// upon instantiation, would collapse all the placeholders to just 'string', and an assignment check might
|
|
70261
70408
|
// succeed. That would be a pointless and confusing outcome.
|
|
70262
70409
|
if (matches || ts.every(target.texts, function (s) { return s.length === 0; })) {
|
|
70263
|
-
var
|
|
70410
|
+
var _loop_24 = function (i) {
|
|
70264
70411
|
var source_1 = matches ? matches[i] : neverType;
|
|
70265
70412
|
var target_3 = types[i];
|
|
70266
70413
|
// If we are inferring from a string literal type to a type variable whose constraint includes one of the
|
|
@@ -70310,7 +70457,7 @@ var ts;
|
|
|
70310
70457
|
inferFromTypes(source_1, target_3);
|
|
70311
70458
|
};
|
|
70312
70459
|
for (var i = 0; i < types.length; i++) {
|
|
70313
|
-
|
|
70460
|
+
_loop_24(i);
|
|
70314
70461
|
}
|
|
70315
70462
|
}
|
|
70316
70463
|
}
|
|
@@ -70762,7 +70909,7 @@ var ts;
|
|
|
70762
70909
|
}
|
|
70763
70910
|
if (ts.isEntityNameExpression(node.argumentExpression)) {
|
|
70764
70911
|
var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
|
|
70765
|
-
if (!symbol || !isConstVariable(symbol))
|
|
70912
|
+
if (!symbol || !(isConstVariable(symbol) || (symbol.flags & 8 /* SymbolFlags.EnumMember */)))
|
|
70766
70913
|
return undefined;
|
|
70767
70914
|
var declaration = symbol.valueDeclaration;
|
|
70768
70915
|
if (declaration === undefined)
|
|
@@ -70776,7 +70923,12 @@ var ts;
|
|
|
70776
70923
|
}
|
|
70777
70924
|
if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
|
|
70778
70925
|
var initializer = ts.getEffectiveInitializer(declaration);
|
|
70779
|
-
|
|
70926
|
+
if (initializer) {
|
|
70927
|
+
return tryGetNameFromType(getTypeOfExpression(initializer));
|
|
70928
|
+
}
|
|
70929
|
+
if (ts.isEnumMember(declaration)) {
|
|
70930
|
+
return ts.getTextOfPropertyName(declaration.name);
|
|
70931
|
+
}
|
|
70780
70932
|
}
|
|
70781
70933
|
}
|
|
70782
70934
|
return undefined;
|
|
@@ -70834,7 +70986,7 @@ var ts;
|
|
|
70834
70986
|
function mapTypesByKeyProperty(types, name) {
|
|
70835
70987
|
var map = new ts.Map();
|
|
70836
70988
|
var count = 0;
|
|
70837
|
-
var
|
|
70989
|
+
var _loop_25 = function (type) {
|
|
70838
70990
|
if (type.flags & (524288 /* TypeFlags.Object */ | 2097152 /* TypeFlags.Intersection */ | 58982400 /* TypeFlags.InstantiableNonPrimitive */)) {
|
|
70839
70991
|
var discriminant = getTypeOfPropertyOfType(type, name);
|
|
70840
70992
|
if (discriminant) {
|
|
@@ -70860,9 +71012,9 @@ var ts;
|
|
|
70860
71012
|
};
|
|
70861
71013
|
for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
|
|
70862
71014
|
var type = types_15[_i];
|
|
70863
|
-
var
|
|
70864
|
-
if (typeof
|
|
70865
|
-
return
|
|
71015
|
+
var state_9 = _loop_25(type);
|
|
71016
|
+
if (typeof state_9 === "object")
|
|
71017
|
+
return state_9.value;
|
|
70866
71018
|
}
|
|
70867
71019
|
return count >= 10 && count * 2 >= types.length ? map : undefined;
|
|
70868
71020
|
}
|
|
@@ -71459,6 +71611,7 @@ var ts;
|
|
|
71459
71611
|
ts.isInJSFile(node) && ts.hasInitializer(node) && node.initializer && ts.isFunctionExpressionOrArrowFunction(node.initializer) && ts.getEffectiveReturnTypeNode(node.initializer));
|
|
71460
71612
|
}
|
|
71461
71613
|
function getExplicitTypeOfSymbol(symbol, diagnostic) {
|
|
71614
|
+
symbol = resolveSymbol(symbol);
|
|
71462
71615
|
if (symbol.flags & (16 /* SymbolFlags.Function */ | 8192 /* SymbolFlags.Method */ | 32 /* SymbolFlags.Class */ | 512 /* SymbolFlags.ValueModule */)) {
|
|
71463
71616
|
return getTypeOfSymbol(symbol);
|
|
71464
71617
|
}
|
|
@@ -71497,7 +71650,7 @@ var ts;
|
|
|
71497
71650
|
switch (node.kind) {
|
|
71498
71651
|
case 79 /* SyntaxKind.Identifier */:
|
|
71499
71652
|
var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
|
|
71500
|
-
return getExplicitTypeOfSymbol(symbol
|
|
71653
|
+
return getExplicitTypeOfSymbol(symbol, diagnostic);
|
|
71501
71654
|
case 108 /* SyntaxKind.ThisKeyword */:
|
|
71502
71655
|
return getExplicitThisType(node);
|
|
71503
71656
|
case 106 /* SyntaxKind.SuperKeyword */:
|
|
@@ -71984,7 +72137,7 @@ var ts;
|
|
|
71984
72137
|
type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
|
|
71985
72138
|
}
|
|
71986
72139
|
else if (expr.kind === 218 /* SyntaxKind.TypeOfExpression */ && isMatchingReference(reference, expr.expression)) {
|
|
71987
|
-
type =
|
|
72140
|
+
type = narrowTypeBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
|
|
71988
72141
|
}
|
|
71989
72142
|
else {
|
|
71990
72143
|
if (strictNullChecks) {
|
|
@@ -72265,7 +72418,7 @@ var ts;
|
|
|
72265
72418
|
!!(prop.flags & 16777216 /* SymbolFlags.Optional */) || assumeTrue :
|
|
72266
72419
|
!!getApplicableIndexInfoForName(type, propName) || !assumeTrue;
|
|
72267
72420
|
}
|
|
72268
|
-
function
|
|
72421
|
+
function narrowTypeByInKeyword(type, nameType, assumeTrue) {
|
|
72269
72422
|
var name = getPropertyNameFromType(nameType);
|
|
72270
72423
|
var isKnownProperty = someType(type, function (t) { return isTypePresencePossible(t, name, /*assumeTrue*/ true); });
|
|
72271
72424
|
if (isKnownProperty) {
|
|
@@ -72346,7 +72499,7 @@ var ts;
|
|
|
72346
72499
|
return getTypeWithFacts(type, assumeTrue ? 524288 /* TypeFacts.NEUndefined */ : 65536 /* TypeFacts.EQUndefined */);
|
|
72347
72500
|
}
|
|
72348
72501
|
if (isMatchingReference(reference, target)) {
|
|
72349
|
-
return
|
|
72502
|
+
return narrowTypeByInKeyword(type, leftType, assumeTrue);
|
|
72350
72503
|
}
|
|
72351
72504
|
}
|
|
72352
72505
|
break;
|
|
@@ -72535,7 +72688,7 @@ var ts;
|
|
|
72535
72688
|
neverType;
|
|
72536
72689
|
});
|
|
72537
72690
|
}
|
|
72538
|
-
function
|
|
72691
|
+
function narrowTypeBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
|
|
72539
72692
|
var witnesses = getSwitchClauseTypeOfWitnesses(switchStatement);
|
|
72540
72693
|
if (!witnesses) {
|
|
72541
72694
|
return type;
|
|
@@ -72923,15 +73076,15 @@ var ts;
|
|
|
72923
73076
|
});
|
|
72924
73077
|
}
|
|
72925
73078
|
function markAliasReferenced(symbol, location) {
|
|
72926
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
73079
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
72927
73080
|
var target = resolveAlias(symbol);
|
|
72928
|
-
if (target
|
|
73081
|
+
if (getAllSymbolFlags(target) & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */)) {
|
|
72929
73082
|
// An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
|
|
72930
73083
|
// (because the const enum value will not be inlined), or if (2) the alias is an export
|
|
72931
73084
|
// of a const enum declaration that will be preserved.
|
|
72932
73085
|
if (compilerOptions.isolatedModules ||
|
|
72933
73086
|
ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) ||
|
|
72934
|
-
!isConstEnumOrConstEnumOnlyModule(target)) {
|
|
73087
|
+
!isConstEnumOrConstEnumOnlyModule(getExportSymbolOfValueSymbolIfExported(target))) {
|
|
72935
73088
|
markAliasSymbolAsReferenced(symbol);
|
|
72936
73089
|
}
|
|
72937
73090
|
else {
|
|
@@ -73159,7 +73312,7 @@ var ts;
|
|
|
73159
73312
|
// We only look for uninitialized variables in strict null checking mode, and only when we can analyze
|
|
73160
73313
|
// the entire control flow graph from the variable's declaration (i.e. when the flow container and
|
|
73161
73314
|
// declaration container are the same).
|
|
73162
|
-
var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports ||
|
|
73315
|
+
var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) ||
|
|
73163
73316
|
type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* TypeFlags.AnyOrUnknown */ | 16384 /* TypeFlags.Void */)) !== 0 ||
|
|
73164
73317
|
isInTypeQuery(node) || node.parent.kind === 278 /* SyntaxKind.ExportSpecifier */) ||
|
|
73165
73318
|
node.parent.kind === 232 /* SyntaxKind.NonNullExpression */ ||
|
|
@@ -73188,6 +73341,12 @@ var ts;
|
|
|
73188
73341
|
}
|
|
73189
73342
|
return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
|
|
73190
73343
|
}
|
|
73344
|
+
function isSameScopedBindingElement(node, declaration) {
|
|
73345
|
+
if (ts.isBindingElement(declaration)) {
|
|
73346
|
+
var bindingElement = ts.findAncestor(node, ts.isBindingElement);
|
|
73347
|
+
return bindingElement && ts.getRootDeclaration(bindingElement) === ts.getRootDeclaration(declaration);
|
|
73348
|
+
}
|
|
73349
|
+
}
|
|
73191
73350
|
function shouldMarkIdentifierAliasReferenced(node) {
|
|
73192
73351
|
var _a;
|
|
73193
73352
|
var parent = node.parent;
|
|
@@ -73529,12 +73688,17 @@ var ts;
|
|
|
73529
73688
|
var immediateContainer = ts.getSuperContainer(node, /*stopOnFunctions*/ true);
|
|
73530
73689
|
var container = immediateContainer;
|
|
73531
73690
|
var needToCaptureLexicalThis = false;
|
|
73691
|
+
var inAsyncFunction = false;
|
|
73532
73692
|
// adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting
|
|
73533
73693
|
if (!isCallExpression) {
|
|
73534
73694
|
while (container && container.kind === 216 /* SyntaxKind.ArrowFunction */) {
|
|
73695
|
+
if (ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
|
|
73696
|
+
inAsyncFunction = true;
|
|
73535
73697
|
container = ts.getSuperContainer(container, /*stopOnFunctions*/ true);
|
|
73536
73698
|
needToCaptureLexicalThis = languageVersion < 2 /* ScriptTarget.ES2015 */;
|
|
73537
73699
|
}
|
|
73700
|
+
if (container && ts.hasSyntacticModifier(container, 512 /* ModifierFlags.Async */))
|
|
73701
|
+
inAsyncFunction = true;
|
|
73538
73702
|
}
|
|
73539
73703
|
var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
|
|
73540
73704
|
var nodeCheckFlag = 0;
|
|
@@ -73640,12 +73804,12 @@ var ts;
|
|
|
73640
73804
|
// as a call expression cannot be used as the target of a destructuring assignment while a property access can.
|
|
73641
73805
|
//
|
|
73642
73806
|
// For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations.
|
|
73643
|
-
if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ &&
|
|
73807
|
+
if (container.kind === 171 /* SyntaxKind.MethodDeclaration */ && inAsyncFunction) {
|
|
73644
73808
|
if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
|
|
73645
|
-
getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.
|
|
73809
|
+
getNodeLinks(container).flags |= 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */;
|
|
73646
73810
|
}
|
|
73647
73811
|
else {
|
|
73648
|
-
getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.
|
|
73812
|
+
getNodeLinks(container).flags |= 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */;
|
|
73649
73813
|
}
|
|
73650
73814
|
}
|
|
73651
73815
|
if (needToCaptureLexicalThis) {
|
|
@@ -74341,9 +74505,10 @@ var ts;
|
|
|
74341
74505
|
function instantiateContextualType(contextualType, node, contextFlags) {
|
|
74342
74506
|
if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) {
|
|
74343
74507
|
var inferenceContext = getInferenceContext(node);
|
|
74344
|
-
// If no inferences have been made,
|
|
74345
|
-
//
|
|
74346
|
-
|
|
74508
|
+
// If no inferences have been made, and none of the type parameters for which we are inferring
|
|
74509
|
+
// specify default types, nothing is gained from instantiating as type parameters would just be
|
|
74510
|
+
// replaced with their constraints similar to the apparent type.
|
|
74511
|
+
if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
|
|
74347
74512
|
// For contextual signatures we incorporate all inferences made so far, e.g. from return
|
|
74348
74513
|
// types as well as arguments to the left in a function call.
|
|
74349
74514
|
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
@@ -77317,7 +77482,7 @@ var ts;
|
|
|
77317
77482
|
if (spreadIndex >= 0) {
|
|
77318
77483
|
// Create synthetic arguments from spreads of tuple types.
|
|
77319
77484
|
var effectiveArgs_1 = args.slice(0, spreadIndex);
|
|
77320
|
-
var
|
|
77485
|
+
var _loop_26 = function (i) {
|
|
77321
77486
|
var arg = args[i];
|
|
77322
77487
|
// We can call checkExpressionCached because spread expressions never have a contextual type.
|
|
77323
77488
|
var spreadType = arg.kind === 227 /* SyntaxKind.SpreadElement */ && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
|
|
@@ -77334,7 +77499,7 @@ var ts;
|
|
|
77334
77499
|
}
|
|
77335
77500
|
};
|
|
77336
77501
|
for (var i = spreadIndex; i < args.length; i++) {
|
|
77337
|
-
|
|
77502
|
+
_loop_26(i);
|
|
77338
77503
|
}
|
|
77339
77504
|
return effectiveArgs_1;
|
|
77340
77505
|
}
|
|
@@ -77663,7 +77828,7 @@ var ts;
|
|
|
77663
77828
|
var min_3 = Number.MAX_VALUE;
|
|
77664
77829
|
var minIndex = 0;
|
|
77665
77830
|
var i_1 = 0;
|
|
77666
|
-
var
|
|
77831
|
+
var _loop_27 = function (c) {
|
|
77667
77832
|
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)); };
|
|
77668
77833
|
var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* CheckMode.Normal */, /*reportErrors*/ true, chain_2);
|
|
77669
77834
|
if (diags_2) {
|
|
@@ -77681,7 +77846,7 @@ var ts;
|
|
|
77681
77846
|
};
|
|
77682
77847
|
for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
|
|
77683
77848
|
var c = candidatesForArgumentError_1[_a];
|
|
77684
|
-
|
|
77849
|
+
_loop_27(c);
|
|
77685
77850
|
}
|
|
77686
77851
|
var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
|
|
77687
77852
|
ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
|
|
@@ -77839,7 +78004,7 @@ var ts;
|
|
|
77839
78004
|
}
|
|
77840
78005
|
var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
|
|
77841
78006
|
var parameters = [];
|
|
77842
|
-
var
|
|
78007
|
+
var _loop_28 = function (i) {
|
|
77843
78008
|
var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
|
|
77844
78009
|
i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
|
|
77845
78010
|
i < s.parameters.length ? s.parameters[i] : undefined; });
|
|
@@ -77847,7 +78012,7 @@ var ts;
|
|
|
77847
78012
|
parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
|
|
77848
78013
|
};
|
|
77849
78014
|
for (var i = 0; i < maxNonRestParam; i++) {
|
|
77850
|
-
|
|
78015
|
+
_loop_28(i);
|
|
77851
78016
|
}
|
|
77852
78017
|
var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
|
|
77853
78018
|
var flags = 0 /* SignatureFlags.None */;
|
|
@@ -78817,7 +78982,7 @@ var ts;
|
|
|
78817
78982
|
if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
78818
78983
|
symbol = resolveAlias(symbol);
|
|
78819
78984
|
}
|
|
78820
|
-
return !!(symbol && (symbol
|
|
78985
|
+
return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
|
|
78821
78986
|
}
|
|
78822
78987
|
return false;
|
|
78823
78988
|
}
|
|
@@ -79479,7 +79644,17 @@ var ts;
|
|
|
79479
79644
|
}
|
|
79480
79645
|
function isExhaustiveSwitchStatement(node) {
|
|
79481
79646
|
var links = getNodeLinks(node);
|
|
79482
|
-
|
|
79647
|
+
if (links.isExhaustive === undefined) {
|
|
79648
|
+
links.isExhaustive = 0; // Indicate resolution is in process
|
|
79649
|
+
var exhaustive = computeExhaustiveSwitchStatement(node);
|
|
79650
|
+
if (links.isExhaustive === 0) {
|
|
79651
|
+
links.isExhaustive = exhaustive;
|
|
79652
|
+
}
|
|
79653
|
+
}
|
|
79654
|
+
else if (links.isExhaustive === 0) {
|
|
79655
|
+
links.isExhaustive = false; // Resolve circularity to false
|
|
79656
|
+
}
|
|
79657
|
+
return links.isExhaustive;
|
|
79483
79658
|
}
|
|
79484
79659
|
function computeExhaustiveSwitchStatement(node) {
|
|
79485
79660
|
if (node.expression.kind === 218 /* SyntaxKind.TypeOfExpression */) {
|
|
@@ -79487,7 +79662,7 @@ var ts;
|
|
|
79487
79662
|
if (!witnesses) {
|
|
79488
79663
|
return false;
|
|
79489
79664
|
}
|
|
79490
|
-
var operandConstraint = getBaseConstraintOrType(
|
|
79665
|
+
var operandConstraint = getBaseConstraintOrType(checkExpressionCached(node.expression.expression));
|
|
79491
79666
|
// Get the not-equal flags for all handled cases.
|
|
79492
79667
|
var notEqualFacts_2 = getNotEqualFactsFromTypeofSwitch(0, 0, witnesses);
|
|
79493
79668
|
if (operandConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */) {
|
|
@@ -79497,7 +79672,7 @@ var ts;
|
|
|
79497
79672
|
// A missing not-equal flag indicates that the type wasn't handled by some case.
|
|
79498
79673
|
return !someType(operandConstraint, function (t) { return (getTypeFacts(t) & notEqualFacts_2) === notEqualFacts_2; });
|
|
79499
79674
|
}
|
|
79500
|
-
var type =
|
|
79675
|
+
var type = checkExpressionCached(node.expression);
|
|
79501
79676
|
if (!isLiteralType(type)) {
|
|
79502
79677
|
return false;
|
|
79503
79678
|
}
|
|
@@ -81191,6 +81366,9 @@ var ts;
|
|
|
81191
81366
|
function hasInferenceCandidates(info) {
|
|
81192
81367
|
return !!(info.candidates || info.contraCandidates);
|
|
81193
81368
|
}
|
|
81369
|
+
function hasInferenceCandidatesOrDefault(info) {
|
|
81370
|
+
return !!(info.candidates || info.contraCandidates || hasTypeParameterDefault(info.typeParameter));
|
|
81371
|
+
}
|
|
81194
81372
|
function hasOverlappingInferences(a, b) {
|
|
81195
81373
|
for (var i = 0; i < a.length; i++) {
|
|
81196
81374
|
if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
|
|
@@ -81892,7 +82070,7 @@ var ts;
|
|
|
81892
82070
|
var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
|
|
81893
82071
|
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
|
|
81894
82072
|
var indexSignatureMap_1 = new ts.Map();
|
|
81895
|
-
var
|
|
82073
|
+
var _loop_29 = function (declaration) {
|
|
81896
82074
|
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
81897
82075
|
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), function (type) {
|
|
81898
82076
|
var entry = indexSignatureMap_1.get(getTypeId(type));
|
|
@@ -81907,7 +82085,7 @@ var ts;
|
|
|
81907
82085
|
};
|
|
81908
82086
|
for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
|
|
81909
82087
|
var declaration = _a[_i];
|
|
81910
|
-
|
|
82088
|
+
_loop_29(declaration);
|
|
81911
82089
|
}
|
|
81912
82090
|
indexSignatureMap_1.forEach(function (entry) {
|
|
81913
82091
|
if (entry.declarations.length > 1) {
|
|
@@ -82184,7 +82362,7 @@ var ts;
|
|
|
82184
82362
|
}
|
|
82185
82363
|
var symbol = getNodeLinks(node).resolvedSymbol;
|
|
82186
82364
|
if (symbol) {
|
|
82187
|
-
if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82365
|
+
if (ts.some(symbol.declarations, function (d) { return ts.isTypeDeclaration(d) && !!(d.flags & 268435456 /* NodeFlags.Deprecated */); })) {
|
|
82188
82366
|
addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
|
|
82189
82367
|
}
|
|
82190
82368
|
if (type.flags & 32 /* TypeFlags.Enum */ && symbol.flags & 8 /* SymbolFlags.EnumMember */) {
|
|
@@ -82787,7 +82965,7 @@ var ts;
|
|
|
82787
82965
|
return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
|
|
82788
82966
|
}
|
|
82789
82967
|
// primitives with a `{ then() }` won't be unwrapped/adopted.
|
|
82790
|
-
if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
|
|
82968
|
+
if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
|
|
82791
82969
|
return undefined;
|
|
82792
82970
|
}
|
|
82793
82971
|
var thenFunction = getTypeOfPropertyOfType(type, "then"); // TODO: GH#18217
|
|
@@ -82854,7 +83032,7 @@ var ts;
|
|
|
82854
83032
|
* Determines whether a type is an object with a callable `then` member.
|
|
82855
83033
|
*/
|
|
82856
83034
|
function isThenableType(type) {
|
|
82857
|
-
if (allTypesAssignableToKind(type, 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
|
|
83035
|
+
if (allTypesAssignableToKind(getBaseConstraintOrType(type), 131068 /* TypeFlags.Primitive */ | 131072 /* TypeFlags.Never */)) {
|
|
82858
83036
|
// primitive types cannot be considered "thenable" since they are not objects.
|
|
82859
83037
|
return false;
|
|
82860
83038
|
}
|
|
@@ -82888,7 +83066,7 @@ var ts;
|
|
|
82888
83066
|
// 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`,
|
|
82889
83067
|
// or is promise-like.
|
|
82890
83068
|
if (baseConstraint ?
|
|
82891
|
-
baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) ||
|
|
83069
|
+
baseConstraint.flags & 3 /* TypeFlags.AnyOrUnknown */ || isEmptyObjectType(baseConstraint) || someType(baseConstraint, isThenableType) :
|
|
82892
83070
|
maybeTypeOfKind(type, 8650752 /* TypeFlags.TypeVariable */)) {
|
|
82893
83071
|
return true;
|
|
82894
83072
|
}
|
|
@@ -83562,7 +83740,7 @@ var ts;
|
|
|
83562
83740
|
}
|
|
83563
83741
|
function errorUnusedLocal(declaration, name, addDiagnostic) {
|
|
83564
83742
|
var node = ts.getNameOfDeclaration(declaration) || declaration;
|
|
83565
|
-
var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83743
|
+
var message = ts.isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
|
|
83566
83744
|
addDiagnostic(declaration, 0 /* UnusedKind.Local */, ts.createDiagnosticForNode(node, message, name));
|
|
83567
83745
|
}
|
|
83568
83746
|
function isIdentifierThatStartsWithUnderscore(node) {
|
|
@@ -84992,7 +85170,16 @@ var ts;
|
|
|
84992
85170
|
var message = allowAsyncIterables
|
|
84993
85171
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
84994
85172
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
84995
|
-
|
|
85173
|
+
var suggestAwait =
|
|
85174
|
+
// for (const x of Promise<...>) or [...Promise<...>]
|
|
85175
|
+
!!getAwaitedTypeOfPromise(type)
|
|
85176
|
+
// for (const x of AsyncIterable<...>)
|
|
85177
|
+
|| (!allowAsyncIterables &&
|
|
85178
|
+
ts.isForOfStatement(errorNode.parent) &&
|
|
85179
|
+
errorNode.parent.expression === errorNode &&
|
|
85180
|
+
getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
|
|
85181
|
+
isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
|
|
85182
|
+
return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
|
|
84996
85183
|
}
|
|
84997
85184
|
/**
|
|
84998
85185
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -85507,7 +85694,7 @@ var ts;
|
|
|
85507
85694
|
var propDeclaration = declaration && declaration.kind === 223 /* SyntaxKind.BinaryExpression */ ||
|
|
85508
85695
|
name && name.kind === 164 /* SyntaxKind.ComputedPropertyName */ ? declaration : undefined;
|
|
85509
85696
|
var localPropDeclaration = getParentOfSymbol(prop) === type.symbol ? declaration : undefined;
|
|
85510
|
-
var
|
|
85697
|
+
var _loop_30 = function (info) {
|
|
85511
85698
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
85512
85699
|
// We check only when (a) the property is declared in the containing type, or (b) the applicable index signature is declared
|
|
85513
85700
|
// in the containing type, or (c) the containing type is an interface and no base interface contains both the property and
|
|
@@ -85524,7 +85711,7 @@ var ts;
|
|
|
85524
85711
|
};
|
|
85525
85712
|
for (var _i = 0, indexInfos_9 = indexInfos; _i < indexInfos_9.length; _i++) {
|
|
85526
85713
|
var info = indexInfos_9[_i];
|
|
85527
|
-
|
|
85714
|
+
_loop_30(info);
|
|
85528
85715
|
}
|
|
85529
85716
|
}
|
|
85530
85717
|
function checkIndexConstraintForIndexSignature(type, checkInfo) {
|
|
@@ -85532,7 +85719,7 @@ var ts;
|
|
|
85532
85719
|
var indexInfos = getApplicableIndexInfos(type, checkInfo.keyType);
|
|
85533
85720
|
var interfaceDeclaration = ts.getObjectFlags(type) & 2 /* ObjectFlags.Interface */ ? ts.getDeclarationOfKind(type.symbol, 261 /* SyntaxKind.InterfaceDeclaration */) : undefined;
|
|
85534
85721
|
var localCheckDeclaration = declaration && getParentOfSymbol(getSymbolOfNode(declaration)) === type.symbol ? declaration : undefined;
|
|
85535
|
-
var
|
|
85722
|
+
var _loop_31 = function (info) {
|
|
85536
85723
|
if (info === checkInfo)
|
|
85537
85724
|
return "continue";
|
|
85538
85725
|
var localIndexDeclaration = info.declaration && getParentOfSymbol(getSymbolOfNode(info.declaration)) === type.symbol ? info.declaration : undefined;
|
|
@@ -85547,7 +85734,7 @@ var ts;
|
|
|
85547
85734
|
};
|
|
85548
85735
|
for (var _i = 0, indexInfos_10 = indexInfos; _i < indexInfos_10.length; _i++) {
|
|
85549
85736
|
var info = indexInfos_10[_i];
|
|
85550
|
-
|
|
85737
|
+
_loop_31(info);
|
|
85551
85738
|
}
|
|
85552
85739
|
}
|
|
85553
85740
|
function checkTypeNameIsReserved(name, message) {
|
|
@@ -85602,7 +85789,7 @@ var ts;
|
|
|
85602
85789
|
}
|
|
85603
85790
|
else {
|
|
85604
85791
|
ts.forEach(jsdocParameters, function (_a, index) {
|
|
85605
|
-
var name = _a.name;
|
|
85792
|
+
var name = _a.name, isNameFirst = _a.isNameFirst;
|
|
85606
85793
|
if (excludedParameters.has(index) || ts.isIdentifier(name) && parameters.has(name.escapedText)) {
|
|
85607
85794
|
return;
|
|
85608
85795
|
}
|
|
@@ -85612,7 +85799,9 @@ var ts;
|
|
|
85612
85799
|
}
|
|
85613
85800
|
}
|
|
85614
85801
|
else {
|
|
85615
|
-
|
|
85802
|
+
if (!isNameFirst) {
|
|
85803
|
+
errorOrSuggestion(isJs, name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(name));
|
|
85804
|
+
}
|
|
85616
85805
|
}
|
|
85617
85806
|
});
|
|
85618
85807
|
}
|
|
@@ -85867,7 +86056,7 @@ var ts;
|
|
|
85867
86056
|
var baseTypes = baseTypeNode && getBaseTypes(type);
|
|
85868
86057
|
var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
|
|
85869
86058
|
var baseStaticType = getBaseConstructorTypeOfClass(type);
|
|
85870
|
-
var
|
|
86059
|
+
var _loop_32 = function (member) {
|
|
85871
86060
|
if (ts.hasAmbientModifier(member)) {
|
|
85872
86061
|
return "continue";
|
|
85873
86062
|
}
|
|
@@ -85884,7 +86073,7 @@ var ts;
|
|
|
85884
86073
|
};
|
|
85885
86074
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
85886
86075
|
var member = _a[_i];
|
|
85887
|
-
|
|
86076
|
+
_loop_32(member);
|
|
85888
86077
|
}
|
|
85889
86078
|
}
|
|
85890
86079
|
/**
|
|
@@ -85972,7 +86161,7 @@ var ts;
|
|
|
85972
86161
|
function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
|
|
85973
86162
|
// iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
|
|
85974
86163
|
var issuedMemberError = false;
|
|
85975
|
-
var
|
|
86164
|
+
var _loop_33 = function (member) {
|
|
85976
86165
|
if (ts.isStatic(member)) {
|
|
85977
86166
|
return "continue";
|
|
85978
86167
|
}
|
|
@@ -85991,7 +86180,7 @@ var ts;
|
|
|
85991
86180
|
};
|
|
85992
86181
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
85993
86182
|
var member = _a[_i];
|
|
85994
|
-
|
|
86183
|
+
_loop_33(member);
|
|
85995
86184
|
}
|
|
85996
86185
|
if (!issuedMemberError) {
|
|
85997
86186
|
// check again with diagnostics to generate a less-specific error
|
|
@@ -86062,7 +86251,7 @@ var ts;
|
|
|
86062
86251
|
var _a, _b, _c, _d;
|
|
86063
86252
|
// NOTE: assignability is checked in checkClassDeclaration
|
|
86064
86253
|
var baseProperties = getPropertiesOfType(baseType);
|
|
86065
|
-
var
|
|
86254
|
+
var _loop_34 = function (baseProperty) {
|
|
86066
86255
|
var base = getTargetSymbol(baseProperty);
|
|
86067
86256
|
if (base.flags & 4194304 /* SymbolFlags.Prototype */) {
|
|
86068
86257
|
return "continue";
|
|
@@ -86172,8 +86361,8 @@ var ts;
|
|
|
86172
86361
|
};
|
|
86173
86362
|
basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
|
|
86174
86363
|
var baseProperty = baseProperties_1[_i];
|
|
86175
|
-
var
|
|
86176
|
-
switch (
|
|
86364
|
+
var state_10 = _loop_34(baseProperty);
|
|
86365
|
+
switch (state_10) {
|
|
86177
86366
|
case "continue-basePropertyCheck": continue basePropertyCheck;
|
|
86178
86367
|
}
|
|
86179
86368
|
}
|
|
@@ -86692,12 +86881,11 @@ var ts;
|
|
|
86692
86881
|
}
|
|
86693
86882
|
}
|
|
86694
86883
|
function checkModuleAugmentationElement(node, isGlobalAugmentation) {
|
|
86695
|
-
var _a;
|
|
86696
86884
|
switch (node.kind) {
|
|
86697
86885
|
case 240 /* SyntaxKind.VariableStatement */:
|
|
86698
86886
|
// error each individual name in variable statement instead of marking the entire variable statement
|
|
86699
|
-
for (var _i = 0,
|
|
86700
|
-
var decl =
|
|
86887
|
+
for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
|
|
86888
|
+
var decl = _a[_i];
|
|
86701
86889
|
checkModuleAugmentationElement(decl, isGlobalAugmentation);
|
|
86702
86890
|
}
|
|
86703
86891
|
break;
|
|
@@ -86713,8 +86901,8 @@ var ts;
|
|
|
86713
86901
|
case 257 /* SyntaxKind.VariableDeclaration */:
|
|
86714
86902
|
var name = node.name;
|
|
86715
86903
|
if (ts.isBindingPattern(name)) {
|
|
86716
|
-
for (var
|
|
86717
|
-
var el =
|
|
86904
|
+
for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
|
|
86905
|
+
var el = _c[_b];
|
|
86718
86906
|
// mark individual names in binding pattern
|
|
86719
86907
|
checkModuleAugmentationElement(el, isGlobalAugmentation);
|
|
86720
86908
|
}
|
|
@@ -86730,18 +86918,6 @@ var ts;
|
|
|
86730
86918
|
if (isGlobalAugmentation) {
|
|
86731
86919
|
return;
|
|
86732
86920
|
}
|
|
86733
|
-
var symbol = getSymbolOfNode(node);
|
|
86734
|
-
if (symbol) {
|
|
86735
|
-
// module augmentations cannot introduce new names on the top level scope of the module
|
|
86736
|
-
// this is done it two steps
|
|
86737
|
-
// 1. quick check - if symbol for node is not merged - this is local symbol to this augmentation - report error
|
|
86738
|
-
// 2. main check - report error if value declaration of the parent symbol is module augmentation)
|
|
86739
|
-
var reportError = !(symbol.flags & 33554432 /* SymbolFlags.Transient */);
|
|
86740
|
-
if (!reportError) {
|
|
86741
|
-
// symbol should not originate in augmentation
|
|
86742
|
-
reportError = !!((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.declarations) && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
|
|
86743
|
-
}
|
|
86744
|
-
}
|
|
86745
86921
|
break;
|
|
86746
86922
|
}
|
|
86747
86923
|
}
|
|
@@ -86843,10 +87019,11 @@ var ts;
|
|
|
86843
87019
|
}
|
|
86844
87020
|
return;
|
|
86845
87021
|
}
|
|
87022
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
86846
87023
|
var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
|
|
86847
87024
|
(symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
|
|
86848
87025
|
(symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
|
|
86849
|
-
if (
|
|
87026
|
+
if (targetFlags & excludedMeanings) {
|
|
86850
87027
|
var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
|
|
86851
87028
|
ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
|
|
86852
87029
|
ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
|
@@ -86856,7 +87033,7 @@ var ts;
|
|
|
86856
87033
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
86857
87034
|
&& !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
|
|
86858
87035
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
86859
|
-
var isType = !(
|
|
87036
|
+
var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
|
|
86860
87037
|
if (isType || typeOnlyAlias) {
|
|
86861
87038
|
switch (node.kind) {
|
|
86862
87039
|
case 270 /* SyntaxKind.ImportClause */:
|
|
@@ -87016,14 +87193,15 @@ var ts;
|
|
|
87016
87193
|
if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
|
|
87017
87194
|
var target = resolveAlias(getSymbolOfNode(node));
|
|
87018
87195
|
if (target !== unknownSymbol) {
|
|
87019
|
-
|
|
87196
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
87197
|
+
if (targetFlags & 111551 /* SymbolFlags.Value */) {
|
|
87020
87198
|
// Target is a value symbol, check that it is not hidden by a local declaration with the same name
|
|
87021
87199
|
var moduleName = ts.getFirstIdentifier(node.moduleReference);
|
|
87022
87200
|
if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
|
|
87023
87201
|
error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
|
|
87024
87202
|
}
|
|
87025
87203
|
}
|
|
87026
|
-
if (
|
|
87204
|
+
if (targetFlags & 788968 /* SymbolFlags.Type */) {
|
|
87027
87205
|
checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
|
|
87028
87206
|
}
|
|
87029
87207
|
}
|
|
@@ -87162,7 +87340,7 @@ var ts;
|
|
|
87162
87340
|
markExportAsReferenced(node);
|
|
87163
87341
|
}
|
|
87164
87342
|
var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
|
|
87165
|
-
if (!target || target
|
|
87343
|
+
if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87166
87344
|
checkExpressionCached(node.propertyName || node.name);
|
|
87167
87345
|
}
|
|
87168
87346
|
}
|
|
@@ -87209,7 +87387,7 @@ var ts;
|
|
|
87209
87387
|
markAliasReferenced(sym, id);
|
|
87210
87388
|
// If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
|
|
87211
87389
|
var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
|
|
87212
|
-
if (target
|
|
87390
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87213
87391
|
// However if it is a value, we need to check it's being used correctly
|
|
87214
87392
|
checkExpressionCached(node.expression);
|
|
87215
87393
|
}
|
|
@@ -87881,29 +88059,9 @@ var ts;
|
|
|
87881
88059
|
}
|
|
87882
88060
|
function isTypeDeclarationName(name) {
|
|
87883
88061
|
return name.kind === 79 /* SyntaxKind.Identifier */ &&
|
|
87884
|
-
isTypeDeclaration(name.parent) &&
|
|
88062
|
+
ts.isTypeDeclaration(name.parent) &&
|
|
87885
88063
|
ts.getNameOfDeclaration(name.parent) === name;
|
|
87886
88064
|
}
|
|
87887
|
-
function isTypeDeclaration(node) {
|
|
87888
|
-
switch (node.kind) {
|
|
87889
|
-
case 165 /* SyntaxKind.TypeParameter */:
|
|
87890
|
-
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
87891
|
-
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
87892
|
-
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
87893
|
-
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
87894
|
-
case 348 /* SyntaxKind.JSDocTypedefTag */:
|
|
87895
|
-
case 341 /* SyntaxKind.JSDocCallbackTag */:
|
|
87896
|
-
case 342 /* SyntaxKind.JSDocEnumTag */:
|
|
87897
|
-
return true;
|
|
87898
|
-
case 270 /* SyntaxKind.ImportClause */:
|
|
87899
|
-
return node.isTypeOnly;
|
|
87900
|
-
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
87901
|
-
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
87902
|
-
return node.parent.parent.isTypeOnly;
|
|
87903
|
-
default:
|
|
87904
|
-
return false;
|
|
87905
|
-
}
|
|
87906
|
-
}
|
|
87907
88065
|
// True if the given identifier is part of a type reference
|
|
87908
88066
|
function isTypeReferenceIdentifier(node) {
|
|
87909
88067
|
while (node.parent.kind === 163 /* SyntaxKind.QualifiedName */) {
|
|
@@ -88336,7 +88494,7 @@ var ts;
|
|
|
88336
88494
|
var baseType = ts.firstOrUndefined(getBaseTypes(classType));
|
|
88337
88495
|
return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
|
|
88338
88496
|
}
|
|
88339
|
-
if (isTypeDeclaration(node)) {
|
|
88497
|
+
if (ts.isTypeDeclaration(node)) {
|
|
88340
88498
|
// In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration
|
|
88341
88499
|
var symbol = getSymbolOfNode(node);
|
|
88342
88500
|
return getDeclaredTypeOfSymbol(symbol);
|
|
@@ -88531,7 +88689,7 @@ var ts;
|
|
|
88531
88689
|
return symbolLinks.exportsSomeValue;
|
|
88532
88690
|
function isValue(s) {
|
|
88533
88691
|
s = resolveSymbol(s);
|
|
88534
|
-
return s && !!(s
|
|
88692
|
+
return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
|
|
88535
88693
|
}
|
|
88536
88694
|
}
|
|
88537
88695
|
function isNameOfModuleOrEnumDeclaration(node) {
|
|
@@ -88584,7 +88742,7 @@ var ts;
|
|
|
88584
88742
|
var symbol = getReferencedValueOrAliasSymbol(node);
|
|
88585
88743
|
// We should only get the declaration of an alias if there isn't a local value
|
|
88586
88744
|
// declaration for the symbol
|
|
88587
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
88745
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
88588
88746
|
return getDeclarationOfAliasSymbol(symbol);
|
|
88589
88747
|
}
|
|
88590
88748
|
}
|
|
@@ -88672,7 +88830,7 @@ var ts;
|
|
|
88672
88830
|
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88673
88831
|
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88674
88832
|
var symbol = getSymbolOfNode(node);
|
|
88675
|
-
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
|
|
88833
|
+
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
|
|
88676
88834
|
case 275 /* SyntaxKind.ExportDeclaration */:
|
|
88677
88835
|
var exportClause = node.exportClause;
|
|
88678
88836
|
return !!exportClause && (ts.isNamespaceExport(exportClause) ||
|
|
@@ -88694,6 +88852,7 @@ var ts;
|
|
|
88694
88852
|
return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
|
|
88695
88853
|
}
|
|
88696
88854
|
function isAliasResolvedToValue(symbol) {
|
|
88855
|
+
var _a;
|
|
88697
88856
|
if (!symbol) {
|
|
88698
88857
|
return false;
|
|
88699
88858
|
}
|
|
@@ -88703,7 +88862,7 @@ var ts;
|
|
|
88703
88862
|
}
|
|
88704
88863
|
// const enums and modules that contain only const enums are not considered values from the emit perspective
|
|
88705
88864
|
// unless 'preserveConstEnums' option is set to true
|
|
88706
|
-
return !!(target
|
|
88865
|
+
return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
|
|
88707
88866
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
|
|
88708
88867
|
}
|
|
88709
88868
|
function isConstEnumOrConstEnumOnlyModule(s) {
|
|
@@ -88718,7 +88877,7 @@ var ts;
|
|
|
88718
88877
|
}
|
|
88719
88878
|
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
88720
88879
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
|
|
88721
|
-
target
|
|
88880
|
+
getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
|
|
88722
88881
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
88723
88882
|
// An `export import ... =` of a value symbol is always considered referenced
|
|
88724
88883
|
return true;
|
|
@@ -98372,8 +98531,11 @@ var ts;
|
|
|
98372
98531
|
}
|
|
98373
98532
|
return ts.visitEachChild(node, visitor, context);
|
|
98374
98533
|
case 174 /* SyntaxKind.GetAccessor */:
|
|
98534
|
+
return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitGetAccessorDeclaration, node);
|
|
98375
98535
|
case 175 /* SyntaxKind.SetAccessor */:
|
|
98536
|
+
return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitSetAccessorDeclaration, node);
|
|
98376
98537
|
case 173 /* SyntaxKind.Constructor */:
|
|
98538
|
+
return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitConstructorDeclaration, node);
|
|
98377
98539
|
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
98378
98540
|
case 228 /* SyntaxKind.ClassExpression */:
|
|
98379
98541
|
return doWithContext(1 /* ContextFlags.NonTopLevel */ | 2 /* ContextFlags.HasLexicalThis */, visitDefault, node);
|
|
@@ -98474,6 +98636,9 @@ var ts;
|
|
|
98474
98636
|
return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(
|
|
98475
98637
|
/*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
|
|
98476
98638
|
}
|
|
98639
|
+
function visitConstructorDeclaration(node) {
|
|
98640
|
+
return factory.updateConstructorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
|
|
98641
|
+
}
|
|
98477
98642
|
/**
|
|
98478
98643
|
* Visits a MethodDeclaration node.
|
|
98479
98644
|
*
|
|
@@ -98488,7 +98653,14 @@ var ts;
|
|
|
98488
98653
|
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
|
|
98489
98654
|
/*type*/ undefined, ts.getFunctionFlags(node) & 2 /* FunctionFlags.Async */
|
|
98490
98655
|
? transformAsyncFunctionBody(node)
|
|
98491
|
-
:
|
|
98656
|
+
: transformMethodBody(node));
|
|
98657
|
+
}
|
|
98658
|
+
function visitGetAccessorDeclaration(node) {
|
|
98659
|
+
return factory.updateGetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context),
|
|
98660
|
+
/*type*/ undefined, transformMethodBody(node));
|
|
98661
|
+
}
|
|
98662
|
+
function visitSetAccessorDeclaration(node) {
|
|
98663
|
+
return factory.updateSetAccessorDeclaration(node, ts.visitNodes(node.modifiers, visitor, ts.isModifierLike), node.name, ts.visitParameterList(node.parameters, visitor, context), transformMethodBody(node));
|
|
98492
98664
|
}
|
|
98493
98665
|
/**
|
|
98494
98666
|
* Visits a FunctionDeclaration node.
|
|
@@ -98602,6 +98774,42 @@ var ts;
|
|
|
98602
98774
|
}
|
|
98603
98775
|
return false;
|
|
98604
98776
|
}
|
|
98777
|
+
function transformMethodBody(node) {
|
|
98778
|
+
ts.Debug.assertIsDefined(node.body);
|
|
98779
|
+
var savedCapturedSuperProperties = capturedSuperProperties;
|
|
98780
|
+
var savedHasSuperElementAccess = hasSuperElementAccess;
|
|
98781
|
+
capturedSuperProperties = new ts.Set();
|
|
98782
|
+
hasSuperElementAccess = false;
|
|
98783
|
+
var updated = ts.visitFunctionBody(node.body, visitor, context);
|
|
98784
|
+
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
|
98785
|
+
// This step isn't needed if we eventually transform this to ES5.
|
|
98786
|
+
var originalMethod = ts.getOriginalNode(node, ts.isFunctionLikeDeclaration);
|
|
98787
|
+
var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ &&
|
|
98788
|
+
resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) &&
|
|
98789
|
+
(ts.getFunctionFlags(originalMethod) & 3 /* FunctionFlags.AsyncGenerator */) !== 3 /* FunctionFlags.AsyncGenerator */;
|
|
98790
|
+
if (emitSuperHelpers) {
|
|
98791
|
+
enableSubstitutionForAsyncMethodsWithSuper();
|
|
98792
|
+
if (capturedSuperProperties.size) {
|
|
98793
|
+
var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
|
|
98794
|
+
substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
|
|
98795
|
+
var statements = updated.statements.slice();
|
|
98796
|
+
ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
|
|
98797
|
+
updated = factory.updateBlock(updated, statements);
|
|
98798
|
+
}
|
|
98799
|
+
if (hasSuperElementAccess) {
|
|
98800
|
+
// Emit helpers for super element access expressions (`super[x]`).
|
|
98801
|
+
if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
|
|
98802
|
+
ts.addEmitHelper(updated, ts.advancedAsyncSuperHelper);
|
|
98803
|
+
}
|
|
98804
|
+
else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
|
|
98805
|
+
ts.addEmitHelper(updated, ts.asyncSuperHelper);
|
|
98806
|
+
}
|
|
98807
|
+
}
|
|
98808
|
+
}
|
|
98809
|
+
capturedSuperProperties = savedCapturedSuperProperties;
|
|
98810
|
+
hasSuperElementAccess = savedHasSuperElementAccess;
|
|
98811
|
+
return updated;
|
|
98812
|
+
}
|
|
98605
98813
|
function transformAsyncFunctionBody(node) {
|
|
98606
98814
|
resumeLexicalEnvironment();
|
|
98607
98815
|
var original = ts.getOriginalNode(node, ts.isFunctionLike);
|
|
@@ -98634,7 +98842,7 @@ var ts;
|
|
|
98634
98842
|
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
|
|
98635
98843
|
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
|
98636
98844
|
// This step isn't needed if we eventually transform this to ES5.
|
|
98637
|
-
var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.
|
|
98845
|
+
var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
|
|
98638
98846
|
if (emitSuperHelpers) {
|
|
98639
98847
|
enableSubstitutionForAsyncMethodsWithSuper();
|
|
98640
98848
|
if (capturedSuperProperties.size) {
|
|
@@ -98647,10 +98855,10 @@ var ts;
|
|
|
98647
98855
|
ts.setTextRange(block, node.body);
|
|
98648
98856
|
if (emitSuperHelpers && hasSuperElementAccess) {
|
|
98649
98857
|
// Emit helpers for super element access expressions (`super[x]`).
|
|
98650
|
-
if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.
|
|
98858
|
+
if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
|
|
98651
98859
|
ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
|
|
98652
98860
|
}
|
|
98653
|
-
else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.
|
|
98861
|
+
else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
|
|
98654
98862
|
ts.addEmitHelper(block, ts.asyncSuperHelper);
|
|
98655
98863
|
}
|
|
98656
98864
|
}
|
|
@@ -98722,7 +98930,7 @@ var ts;
|
|
|
98722
98930
|
// If we need to support substitutions for `super` in an async method,
|
|
98723
98931
|
// we should track it here.
|
|
98724
98932
|
if (enabledSubstitutions & 1 /* ES2017SubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
|
|
98725
|
-
var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.
|
|
98933
|
+
var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
|
|
98726
98934
|
if (superContainerFlags !== enclosingSuperContainerFlags) {
|
|
98727
98935
|
var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
|
|
98728
98936
|
enclosingSuperContainerFlags = superContainerFlags;
|
|
@@ -98799,7 +99007,7 @@ var ts;
|
|
|
98799
99007
|
|| kind === 175 /* SyntaxKind.SetAccessor */;
|
|
98800
99008
|
}
|
|
98801
99009
|
function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
|
|
98802
|
-
if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.
|
|
99010
|
+
if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
|
|
98803
99011
|
return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 /* GeneratedIdentifierFlags.Optimistic */ | 32 /* GeneratedIdentifierFlags.FileLevel */),
|
|
98804
99012
|
/*typeArguments*/ undefined, [argumentExpression]), "value"), location);
|
|
98805
99013
|
}
|
|
@@ -98814,7 +99022,7 @@ var ts;
|
|
|
98814
99022
|
function createSuperAccessVariableStatement(factory, resolver, node, names) {
|
|
98815
99023
|
// Create a variable declaration with a getter/setter (if binding) definition for each name:
|
|
98816
99024
|
// const _super = Object.create(null, { x: { get: () => super.x, set: (v) => super.x = v }, ... });
|
|
98817
|
-
var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.
|
|
99025
|
+
var hasBinding = (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) !== 0;
|
|
98818
99026
|
var accessors = [];
|
|
98819
99027
|
names.forEach(function (_, key) {
|
|
98820
99028
|
var name = ts.unescapeLeadingUnderscores(key);
|
|
@@ -99307,11 +99515,22 @@ var ts;
|
|
|
99307
99515
|
}
|
|
99308
99516
|
return node;
|
|
99309
99517
|
}
|
|
99310
|
-
function convertForOfStatementHead(node, boundValue) {
|
|
99311
|
-
var
|
|
99518
|
+
function convertForOfStatementHead(node, boundValue, nonUserCode) {
|
|
99519
|
+
var value = factory.createTempVariable(hoistVariableDeclaration);
|
|
99520
|
+
var iteratorValueExpression = factory.createAssignment(value, boundValue);
|
|
99521
|
+
var iteratorValueStatement = factory.createExpressionStatement(iteratorValueExpression);
|
|
99522
|
+
ts.setSourceMapRange(iteratorValueStatement, node.expression);
|
|
99523
|
+
var exitNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createFalse());
|
|
99524
|
+
var exitNonUserCodeStatement = factory.createExpressionStatement(exitNonUserCodeExpression);
|
|
99525
|
+
ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
|
|
99526
|
+
var enterNonUserCodeExpression = factory.createAssignment(nonUserCode, factory.createTrue());
|
|
99527
|
+
var enterNonUserCodeStatement = factory.createExpressionStatement(enterNonUserCodeExpression);
|
|
99528
|
+
ts.setSourceMapRange(exitNonUserCodeStatement, node.expression);
|
|
99529
|
+
var statements = [];
|
|
99530
|
+
var binding = ts.createForOfBindingStatement(factory, node.initializer, value);
|
|
99531
|
+
statements.push(ts.visitNode(binding, visitor, ts.isStatement));
|
|
99312
99532
|
var bodyLocation;
|
|
99313
99533
|
var statementsLocation;
|
|
99314
|
-
var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
|
|
99315
99534
|
var statement = ts.visitIterationBody(node.statement, visitor, context);
|
|
99316
99535
|
if (ts.isBlock(statement)) {
|
|
99317
99536
|
ts.addRange(statements, statement.statements);
|
|
@@ -99321,8 +99540,16 @@ var ts;
|
|
|
99321
99540
|
else {
|
|
99322
99541
|
statements.push(statement);
|
|
99323
99542
|
}
|
|
99324
|
-
|
|
99543
|
+
var body = ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation),
|
|
99325
99544
|
/*multiLine*/ true), bodyLocation), 48 /* EmitFlags.NoSourceMap */ | 384 /* EmitFlags.NoTokenSourceMaps */);
|
|
99545
|
+
return factory.createBlock([
|
|
99546
|
+
iteratorValueStatement,
|
|
99547
|
+
exitNonUserCodeStatement,
|
|
99548
|
+
factory.createTryStatement(body,
|
|
99549
|
+
/*catchClause*/ undefined, factory.createBlock([
|
|
99550
|
+
enterNonUserCodeStatement
|
|
99551
|
+
]))
|
|
99552
|
+
]);
|
|
99326
99553
|
}
|
|
99327
99554
|
function createDownlevelAwait(expression) {
|
|
99328
99555
|
return enclosingFunctionFlags & 1 /* FunctionFlags.Generator */
|
|
@@ -99333,6 +99560,8 @@ var ts;
|
|
|
99333
99560
|
var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
|
|
99334
99561
|
var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(/*recordTempVariable*/ undefined);
|
|
99335
99562
|
var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(/*recordTempVariable*/ undefined);
|
|
99563
|
+
var nonUserCode = factory.createTempVariable(/*recordTempVariable*/ undefined);
|
|
99564
|
+
var done = factory.createTempVariable(hoistVariableDeclaration);
|
|
99336
99565
|
var errorRecord = factory.createUniqueName("e");
|
|
99337
99566
|
var catchVariable = factory.getGeneratedNameForNode(errorRecord);
|
|
99338
99567
|
var returnMethod = factory.createTempVariable(/*recordTempVariable*/ undefined);
|
|
@@ -99349,12 +99578,17 @@ var ts;
|
|
|
99349
99578
|
callValues;
|
|
99350
99579
|
var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(
|
|
99351
99580
|
/*initializer*/ ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
|
|
99581
|
+
factory.createVariableDeclaration(nonUserCode, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createTrue()),
|
|
99352
99582
|
ts.setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
|
|
99353
99583
|
factory.createVariableDeclaration(result)
|
|
99354
99584
|
]), node.expression), 2097152 /* EmitFlags.NoHoisting */),
|
|
99355
|
-
/*condition*/ factory.
|
|
99585
|
+
/*condition*/ factory.inlineExpressions([
|
|
99586
|
+
factory.createAssignment(result, createDownlevelAwait(callNext)),
|
|
99587
|
+
factory.createAssignment(done, getDone),
|
|
99588
|
+
factory.createLogicalNot(done)
|
|
99589
|
+
]),
|
|
99356
99590
|
/*incrementor*/ undefined,
|
|
99357
|
-
/*statement*/ convertForOfStatementHead(node, getValue)),
|
|
99591
|
+
/*statement*/ convertForOfStatementHead(node, getValue, nonUserCode)),
|
|
99358
99592
|
/*location*/ node), 256 /* EmitFlags.NoTokenTrailingSourceMaps */);
|
|
99359
99593
|
ts.setOriginalNode(forStatement, node);
|
|
99360
99594
|
return factory.createTryStatement(factory.createBlock([
|
|
@@ -99366,7 +99600,7 @@ var ts;
|
|
|
99366
99600
|
]), 1 /* EmitFlags.SingleLine */)), factory.createBlock([
|
|
99367
99601
|
factory.createTryStatement(
|
|
99368
99602
|
/*tryBlock*/ factory.createBlock([
|
|
99369
|
-
ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(
|
|
99603
|
+
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 */)
|
|
99370
99604
|
]),
|
|
99371
99605
|
/*catchClause*/ undefined,
|
|
99372
99606
|
/*finallyBlock*/ ts.setEmitFlags(factory.createBlock([
|
|
@@ -99522,7 +99756,7 @@ var ts;
|
|
|
99522
99756
|
/*type*/ undefined, factory.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !!(hierarchyFacts & 1 /* HierarchyFacts.HasLexicalThis */)));
|
|
99523
99757
|
// Minor optimization, emit `_super` helper to capture `super` access in an arrow.
|
|
99524
99758
|
// This step isn't needed if we eventually transform this to ES5.
|
|
99525
|
-
var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.
|
|
99759
|
+
var emitSuperHelpers = languageVersion >= 2 /* ScriptTarget.ES2015 */ && resolver.getNodeCheckFlags(node) & (4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */ | 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */);
|
|
99526
99760
|
if (emitSuperHelpers) {
|
|
99527
99761
|
enableSubstitutionForAsyncMethodsWithSuper();
|
|
99528
99762
|
var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
|
|
@@ -99533,10 +99767,10 @@ var ts;
|
|
|
99533
99767
|
ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
|
|
99534
99768
|
var block = factory.updateBlock(node.body, statements);
|
|
99535
99769
|
if (emitSuperHelpers && hasSuperElementAccess) {
|
|
99536
|
-
if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.
|
|
99770
|
+
if (resolver.getNodeCheckFlags(node) & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
|
|
99537
99771
|
ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
|
|
99538
99772
|
}
|
|
99539
|
-
else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.
|
|
99773
|
+
else if (resolver.getNodeCheckFlags(node) & 2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */) {
|
|
99540
99774
|
ts.addEmitHelper(block, ts.asyncSuperHelper);
|
|
99541
99775
|
}
|
|
99542
99776
|
}
|
|
@@ -99665,7 +99899,7 @@ var ts;
|
|
|
99665
99899
|
// If we need to support substitutions for `super` in an async method,
|
|
99666
99900
|
// we should track it here.
|
|
99667
99901
|
if (enabledSubstitutions & 1 /* ESNextSubstitutionFlags.AsyncMethodsWithSuper */ && isSuperContainer(node)) {
|
|
99668
|
-
var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.
|
|
99902
|
+
var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* NodeCheckFlags.MethodWithSuperPropertyAccessInAsync */ | 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */);
|
|
99669
99903
|
if (superContainerFlags !== enclosingSuperContainerFlags) {
|
|
99670
99904
|
var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
|
|
99671
99905
|
enclosingSuperContainerFlags = superContainerFlags;
|
|
@@ -99742,7 +99976,7 @@ var ts;
|
|
|
99742
99976
|
|| kind === 175 /* SyntaxKind.SetAccessor */;
|
|
99743
99977
|
}
|
|
99744
99978
|
function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
|
|
99745
|
-
if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.
|
|
99979
|
+
if (enclosingSuperContainerFlags & 4096 /* NodeCheckFlags.MethodWithSuperPropertyAssignmentInAsync */) {
|
|
99746
99980
|
return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"),
|
|
99747
99981
|
/*typeArguments*/ undefined, [argumentExpression]), "value"), location);
|
|
99748
99982
|
}
|
|
@@ -101211,11 +101445,13 @@ var ts;
|
|
|
101211
101445
|
return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
|
|
101212
101446
|
}
|
|
101213
101447
|
function visitIdentifier(node) {
|
|
101214
|
-
if (
|
|
101215
|
-
|
|
101448
|
+
if (convertedLoopState) {
|
|
101449
|
+
if (resolver.isArgumentsLocalBinding(node)) {
|
|
101450
|
+
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
|
|
101451
|
+
}
|
|
101216
101452
|
}
|
|
101217
|
-
if (
|
|
101218
|
-
return
|
|
101453
|
+
if (node.hasExtendedUnicodeEscape) {
|
|
101454
|
+
return ts.setOriginalNode(ts.setTextRange(factory.createIdentifier(ts.unescapeLeadingUnderscores(node.escapedText)), node), node);
|
|
101219
101455
|
}
|
|
101220
101456
|
return node;
|
|
101221
101457
|
}
|
|
@@ -105362,7 +105598,6 @@ var ts;
|
|
|
105362
105598
|
return node;
|
|
105363
105599
|
}
|
|
105364
105600
|
function transformAndEmitForInStatement(node) {
|
|
105365
|
-
// TODO(rbuckton): Source map locations
|
|
105366
105601
|
if (containsYield(node)) {
|
|
105367
105602
|
// [source]
|
|
105368
105603
|
// for (var p in o) {
|
|
@@ -105370,34 +105605,41 @@ var ts;
|
|
|
105370
105605
|
// }
|
|
105371
105606
|
//
|
|
105372
105607
|
// [intermediate]
|
|
105373
|
-
// .local _a,
|
|
105374
|
-
//
|
|
105375
|
-
//
|
|
105608
|
+
// .local _b, _a, _c, _i
|
|
105609
|
+
// _b = [];
|
|
105610
|
+
// _a = o;
|
|
105611
|
+
// for (_c in _a) _b.push(_c);
|
|
105376
105612
|
// _i = 0;
|
|
105377
105613
|
// .loop incrementLabel, endLoopLabel
|
|
105378
105614
|
// .mark conditionLabel
|
|
105379
|
-
// .brfalse endLoopLabel, (_i <
|
|
105380
|
-
//
|
|
105615
|
+
// .brfalse endLoopLabel, (_i < _b.length)
|
|
105616
|
+
// _c = _b[_i];
|
|
105617
|
+
// .brfalse incrementLabel, (_c in _a)
|
|
105618
|
+
// p = _c;
|
|
105381
105619
|
// /*body*/
|
|
105382
105620
|
// .mark incrementLabel
|
|
105383
|
-
//
|
|
105621
|
+
// _c++;
|
|
105384
105622
|
// .br conditionLabel
|
|
105385
105623
|
// .endloop
|
|
105386
105624
|
// .mark endLoopLabel
|
|
105387
|
-
var
|
|
105388
|
-
var
|
|
105625
|
+
var obj = declareLocal(); // _a
|
|
105626
|
+
var keysArray = declareLocal(); // _b
|
|
105627
|
+
var key = declareLocal(); // _c
|
|
105389
105628
|
var keysIndex = factory.createLoopVariable(); // _i
|
|
105390
105629
|
var initializer = node.initializer;
|
|
105391
105630
|
hoistVariableDeclaration(keysIndex);
|
|
105631
|
+
emitAssignment(obj, ts.visitNode(node.expression, visitor, ts.isExpression));
|
|
105392
105632
|
emitAssignment(keysArray, factory.createArrayLiteralExpression());
|
|
105393
|
-
emitStatement(factory.createForInStatement(key,
|
|
105633
|
+
emitStatement(factory.createForInStatement(key, obj, factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"),
|
|
105394
105634
|
/*typeArguments*/ undefined, [key]))));
|
|
105395
105635
|
emitAssignment(keysIndex, factory.createNumericLiteral(0));
|
|
105396
105636
|
var conditionLabel = defineLabel();
|
|
105397
105637
|
var incrementLabel = defineLabel();
|
|
105398
|
-
var
|
|
105638
|
+
var endLoopLabel = beginLoopBlock(incrementLabel);
|
|
105399
105639
|
markLabel(conditionLabel);
|
|
105400
|
-
emitBreakWhenFalse(
|
|
105640
|
+
emitBreakWhenFalse(endLoopLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
|
|
105641
|
+
emitAssignment(key, factory.createElementAccessExpression(keysArray, keysIndex));
|
|
105642
|
+
emitBreakWhenFalse(incrementLabel, factory.createBinaryExpression(key, 101 /* SyntaxKind.InKeyword */, obj));
|
|
105401
105643
|
var variable = void 0;
|
|
105402
105644
|
if (ts.isVariableDeclarationList(initializer)) {
|
|
105403
105645
|
for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
|
|
@@ -105410,7 +105652,7 @@ var ts;
|
|
|
105410
105652
|
variable = ts.visitNode(initializer, visitor, ts.isExpression);
|
|
105411
105653
|
ts.Debug.assert(ts.isLeftHandSideExpression(variable));
|
|
105412
105654
|
}
|
|
105413
|
-
emitAssignment(variable,
|
|
105655
|
+
emitAssignment(variable, key);
|
|
105414
105656
|
transformAndEmitEmbeddedStatement(node.statement);
|
|
105415
105657
|
markLabel(incrementLabel);
|
|
105416
105658
|
emitStatement(factory.createExpressionStatement(factory.createPostfixIncrement(keysIndex)));
|
|
@@ -107251,7 +107493,7 @@ var ts;
|
|
|
107251
107493
|
return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
|
|
107252
107494
|
case ts.ModuleKind.CommonJS:
|
|
107253
107495
|
default:
|
|
107254
|
-
return createImportCallExpressionCommonJS(argument
|
|
107496
|
+
return createImportCallExpressionCommonJS(argument);
|
|
107255
107497
|
}
|
|
107256
107498
|
}
|
|
107257
107499
|
function createImportCallExpressionUMD(arg, containsLexicalThis) {
|
|
@@ -107274,7 +107516,7 @@ var ts;
|
|
|
107274
107516
|
return factory.createConditionalExpression(
|
|
107275
107517
|
/*condition*/ factory.createIdentifier("__syncRequire"),
|
|
107276
107518
|
/*questionToken*/ undefined,
|
|
107277
|
-
/*whenTrue*/ createImportCallExpressionCommonJS(arg
|
|
107519
|
+
/*whenTrue*/ createImportCallExpressionCommonJS(arg),
|
|
107278
107520
|
/*colonToken*/ undefined,
|
|
107279
107521
|
/*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis));
|
|
107280
107522
|
}
|
|
@@ -107283,7 +107525,7 @@ var ts;
|
|
|
107283
107525
|
return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(
|
|
107284
107526
|
/*condition*/ factory.createIdentifier("__syncRequire"),
|
|
107285
107527
|
/*questionToken*/ undefined,
|
|
107286
|
-
/*whenTrue*/ createImportCallExpressionCommonJS(temp,
|
|
107528
|
+
/*whenTrue*/ createImportCallExpressionCommonJS(temp, /* isInlineable */ true),
|
|
107287
107529
|
/*colonToken*/ undefined,
|
|
107288
107530
|
/*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)));
|
|
107289
107531
|
}
|
|
@@ -107333,14 +107575,20 @@ var ts;
|
|
|
107333
107575
|
}
|
|
107334
107576
|
return promise;
|
|
107335
107577
|
}
|
|
107336
|
-
function createImportCallExpressionCommonJS(arg,
|
|
107337
|
-
// import(
|
|
107578
|
+
function createImportCallExpressionCommonJS(arg, isInlineable) {
|
|
107579
|
+
// import(x)
|
|
107338
107580
|
// emit as
|
|
107339
|
-
//
|
|
107581
|
+
// var _a;
|
|
107582
|
+
// (_a = x, Promise.resolve().then(() => require(_a)) /*CommonJs Require*/
|
|
107340
107583
|
// We have to wrap require in then callback so that require is done in asynchronously
|
|
107341
107584
|
// if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
|
|
107342
|
-
|
|
107343
|
-
var
|
|
107585
|
+
// If the arg is not inlineable, we have to evaluate it in the current scope with a temp var
|
|
107586
|
+
var temp = arg && !ts.isSimpleInlineableExpression(arg) && !isInlineable ? factory.createTempVariable(hoistVariableDeclaration) : undefined;
|
|
107587
|
+
var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"),
|
|
107588
|
+
/*typeArguments*/ undefined,
|
|
107589
|
+
/*argumentsArray*/ []);
|
|
107590
|
+
var requireCall = factory.createCallExpression(factory.createIdentifier("require"),
|
|
107591
|
+
/*typeArguments*/ undefined, temp ? [temp] : arg ? [arg] : []);
|
|
107344
107592
|
if (ts.getESModuleInterop(compilerOptions)) {
|
|
107345
107593
|
requireCall = emitHelpers().createImportStarHelper(requireCall);
|
|
107346
107594
|
}
|
|
@@ -107361,14 +107609,9 @@ var ts;
|
|
|
107361
107609
|
/*typeParameters*/ undefined,
|
|
107362
107610
|
/*parameters*/ [],
|
|
107363
107611
|
/*type*/ undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
|
|
107364
|
-
// if there is a lexical 'this' in the import call arguments, ensure we indicate
|
|
107365
|
-
// that this new function expression indicates it captures 'this' so that the
|
|
107366
|
-
// es2015 transformer will properly substitute 'this' with '_this'.
|
|
107367
|
-
if (containsLexicalThis) {
|
|
107368
|
-
ts.setEmitFlags(func, 8 /* EmitFlags.CapturesThis */);
|
|
107369
|
-
}
|
|
107370
107612
|
}
|
|
107371
|
-
|
|
107613
|
+
var downleveledImport = factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), /*typeArguments*/ undefined, [func]);
|
|
107614
|
+
return temp === undefined ? downleveledImport : factory.createCommaListExpression([factory.createAssignment(temp, arg), downleveledImport]);
|
|
107372
107615
|
}
|
|
107373
107616
|
function getHelperExpressionForExport(node, innerExpr) {
|
|
107374
107617
|
if (!ts.getESModuleInterop(compilerOptions) || ts.getEmitFlags(node) & 67108864 /* EmitFlags.NeverApplyImportHelper */) {
|
|
@@ -118361,14 +118604,16 @@ var ts;
|
|
|
118361
118604
|
}
|
|
118362
118605
|
return setReadFileCache(key, fileName);
|
|
118363
118606
|
};
|
|
118364
|
-
var getSourceFileWithCache = getSourceFile ? function (fileName,
|
|
118607
|
+
var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
|
|
118365
118608
|
var key = toPath(fileName);
|
|
118366
|
-
var
|
|
118609
|
+
var impliedNodeFormat = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions.impliedNodeFormat : undefined;
|
|
118610
|
+
var forImpliedNodeFormat = sourceFileCache.get(impliedNodeFormat);
|
|
118611
|
+
var value = forImpliedNodeFormat === null || forImpliedNodeFormat === void 0 ? void 0 : forImpliedNodeFormat.get(key);
|
|
118367
118612
|
if (value)
|
|
118368
118613
|
return value;
|
|
118369
|
-
var sourceFile = getSourceFile(fileName,
|
|
118614
|
+
var sourceFile = getSourceFile(fileName, languageVersionOrOptions, onError, shouldCreateNewSourceFile);
|
|
118370
118615
|
if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json" /* Extension.Json */))) {
|
|
118371
|
-
sourceFileCache.set(key, sourceFile);
|
|
118616
|
+
sourceFileCache.set(impliedNodeFormat, (forImpliedNodeFormat || new ts.Map()).set(key, sourceFile));
|
|
118372
118617
|
}
|
|
118373
118618
|
return sourceFile;
|
|
118374
118619
|
} : undefined;
|
|
@@ -118393,13 +118638,15 @@ var ts;
|
|
|
118393
118638
|
var value = readFileCache.get(key);
|
|
118394
118639
|
if (value !== undefined && value !== data) {
|
|
118395
118640
|
readFileCache.delete(key);
|
|
118396
|
-
sourceFileCache.delete(key);
|
|
118641
|
+
sourceFileCache.forEach(function (map) { return map.delete(key); });
|
|
118397
118642
|
}
|
|
118398
118643
|
else if (getSourceFileWithCache) {
|
|
118399
|
-
|
|
118400
|
-
|
|
118401
|
-
|
|
118402
|
-
|
|
118644
|
+
sourceFileCache.forEach(function (map) {
|
|
118645
|
+
var sourceFile = map.get(key);
|
|
118646
|
+
if (sourceFile && sourceFile.text !== data) {
|
|
118647
|
+
map.delete(key);
|
|
118648
|
+
}
|
|
118649
|
+
});
|
|
118403
118650
|
}
|
|
118404
118651
|
originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
|
|
118405
118652
|
};
|
|
@@ -122541,10 +122788,16 @@ var ts;
|
|
|
122541
122788
|
var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
|
|
122542
122789
|
var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
|
|
122543
122790
|
!ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
|
|
122791
|
+
// We can only reuse emit signatures (i.e. .d.ts signatures) if the .d.ts file is unchanged,
|
|
122792
|
+
// which will eg be depedent on change in options like declarationDir and outDir options are unchanged.
|
|
122793
|
+
// We need to look in oldState.compilerOptions, rather than oldCompilerOptions (i.e.we need to disregard useOldState) because
|
|
122794
|
+
// oldCompilerOptions can be undefined if there was change in say module from None to some other option
|
|
122795
|
+
// 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
|
|
122796
|
+
// but that option change does not affect d.ts file name so emitSignatures should still be reused.
|
|
122544
122797
|
var canCopyEmitSignatures = compilerOptions.composite &&
|
|
122545
122798
|
(oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
|
|
122546
122799
|
!outFilePath &&
|
|
122547
|
-
!ts.compilerOptionsAffectDeclarationPath(compilerOptions,
|
|
122800
|
+
!ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
|
|
122548
122801
|
if (useOldState) {
|
|
122549
122802
|
// Copy old state's changed files set
|
|
122550
122803
|
(_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
|
|
@@ -123759,7 +124012,7 @@ var ts;
|
|
|
123759
124012
|
var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* CharacterCodes.slash */;
|
|
123760
124013
|
if (isNonDirectorySeparatorRoot &&
|
|
123761
124014
|
dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths
|
|
123762
|
-
pathPartForUserCheck.search(/[a-zA-
|
|
124015
|
+
pathPartForUserCheck.search(/[a-zA-Z]\$\//) === 0) { // Dos style nextPart
|
|
123763
124016
|
nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
|
|
123764
124017
|
if (nextDirectorySeparator === -1) {
|
|
123765
124018
|
// ignore "//vda1cs4850/c$/folderAtRoot"
|
|
@@ -125013,7 +125266,7 @@ var ts;
|
|
|
125013
125266
|
});
|
|
125014
125267
|
// Sort by paths closest to importing file Name directory
|
|
125015
125268
|
var sortedPaths = [];
|
|
125016
|
-
var
|
|
125269
|
+
var _loop_35 = function (directory) {
|
|
125017
125270
|
var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
|
|
125018
125271
|
var pathsInDirectory;
|
|
125019
125272
|
allFileNames.forEach(function (_a, fileName) {
|
|
@@ -125037,9 +125290,9 @@ var ts;
|
|
|
125037
125290
|
};
|
|
125038
125291
|
var out_directory_1;
|
|
125039
125292
|
for (var directory = ts.getDirectoryPath(importingFileName); allFileNames.size !== 0;) {
|
|
125040
|
-
var
|
|
125293
|
+
var state_11 = _loop_35(directory);
|
|
125041
125294
|
directory = out_directory_1;
|
|
125042
|
-
if (
|
|
125295
|
+
if (state_11 === "break")
|
|
125043
125296
|
break;
|
|
125044
125297
|
}
|
|
125045
125298
|
if (allFileNames.size) {
|
|
@@ -125108,7 +125361,7 @@ var ts;
|
|
|
125108
125361
|
}
|
|
125109
125362
|
function tryGetModuleNameFromPaths(relativeToBaseUrl, paths, allowedEndings, host, compilerOptions) {
|
|
125110
125363
|
for (var key in paths) {
|
|
125111
|
-
var
|
|
125364
|
+
var _loop_36 = function (patternText_1) {
|
|
125112
125365
|
var pattern = ts.normalizePath(patternText_1);
|
|
125113
125366
|
var indexOfStar = pattern.indexOf("*");
|
|
125114
125367
|
// In module resolution, if `pattern` itself has an extension, a file with that extension is looked up directly,
|
|
@@ -125175,9 +125428,9 @@ var ts;
|
|
|
125175
125428
|
};
|
|
125176
125429
|
for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
|
|
125177
125430
|
var patternText_1 = _a[_i];
|
|
125178
|
-
var
|
|
125179
|
-
if (typeof
|
|
125180
|
-
return
|
|
125431
|
+
var state_12 = _loop_36(patternText_1);
|
|
125432
|
+
if (typeof state_12 === "object")
|
|
125433
|
+
return state_12.value;
|
|
125181
125434
|
}
|
|
125182
125435
|
}
|
|
125183
125436
|
function validateEnding(_a) {
|
|
@@ -125265,15 +125518,21 @@ var ts;
|
|
|
125265
125518
|
return undefined;
|
|
125266
125519
|
}
|
|
125267
125520
|
function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
|
|
125268
|
-
var
|
|
125269
|
-
if (
|
|
125521
|
+
var normalizedTargetPaths = getPathsRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
|
|
125522
|
+
if (normalizedTargetPaths === undefined) {
|
|
125523
|
+
return undefined;
|
|
125524
|
+
}
|
|
125525
|
+
var normalizedSourcePaths = getPathsRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
|
|
125526
|
+
var relativePaths = ts.flatMap(normalizedSourcePaths, function (sourcePath) {
|
|
125527
|
+
return ts.map(normalizedTargetPaths, function (targetPath) { return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourcePath, targetPath, getCanonicalFileName)); });
|
|
125528
|
+
});
|
|
125529
|
+
var shortest = ts.min(relativePaths, ts.compareNumberOfDirectorySeparators);
|
|
125530
|
+
if (!shortest) {
|
|
125270
125531
|
return undefined;
|
|
125271
125532
|
}
|
|
125272
|
-
var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
|
|
125273
|
-
var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
|
|
125274
125533
|
return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
|
|
125275
|
-
? removeExtensionAndIndexPostFix(
|
|
125276
|
-
: ts.removeFileExtension(
|
|
125534
|
+
? removeExtensionAndIndexPostFix(shortest, ending, compilerOptions)
|
|
125535
|
+
: ts.removeFileExtension(shortest);
|
|
125277
125536
|
}
|
|
125278
125537
|
function tryGetModuleNameAsNodeModule(_a, _b, importingSourceFile, host, options, userPreferences, packageNameOnly, overrideMode) {
|
|
125279
125538
|
var path = _a.path, isRedirect = _a.isRedirect;
|
|
@@ -125410,8 +125669,8 @@ var ts;
|
|
|
125410
125669
|
}
|
|
125411
125670
|
}
|
|
125412
125671
|
}
|
|
125413
|
-
function
|
|
125414
|
-
return ts.
|
|
125672
|
+
function getPathsRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
125673
|
+
return ts.mapDefined(rootDirs, function (rootDir) {
|
|
125415
125674
|
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
125416
125675
|
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
125417
125676
|
});
|
|
@@ -127979,8 +128238,15 @@ var ts;
|
|
|
127979
128238
|
}
|
|
127980
128239
|
if (buildInfo.program) {
|
|
127981
128240
|
// If there are pending changes that are not emitted, project is out of date
|
|
128241
|
+
// When there are syntax errors, changeFileSet will have list of files changed (irrespective of noEmit)
|
|
128242
|
+
// But in case of semantic error we need special treatment.
|
|
128243
|
+
// Checking presence of affectedFilesPendingEmit list is fast and good way to tell if there were semantic errors and file emit was blocked
|
|
128244
|
+
// 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
|
|
128245
|
+
// 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
|
|
127982
128246
|
if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
127983
|
-
(!project.options.noEmit
|
|
128247
|
+
(!project.options.noEmit ?
|
|
128248
|
+
(_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length :
|
|
128249
|
+
ts.some(buildInfo.program.semanticDiagnosticsPerFile, ts.isArray))) {
|
|
127984
128250
|
return {
|
|
127985
128251
|
type: ts.UpToDateStatusType.OutOfDateBuildInfo,
|
|
127986
128252
|
buildInfoFile: buildInfoPath
|
|
@@ -128742,6 +129008,12 @@ var ts;
|
|
|
128742
129008
|
SemanticClassificationFormat["Original"] = "original";
|
|
128743
129009
|
SemanticClassificationFormat["TwentyTwenty"] = "2020";
|
|
128744
129010
|
})(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
|
|
129011
|
+
var OrganizeImportsMode;
|
|
129012
|
+
(function (OrganizeImportsMode) {
|
|
129013
|
+
OrganizeImportsMode["All"] = "All";
|
|
129014
|
+
OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
|
|
129015
|
+
OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
|
|
129016
|
+
})(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
|
|
128745
129017
|
var CompletionTriggerKind;
|
|
128746
129018
|
(function (CompletionTriggerKind) {
|
|
128747
129019
|
/** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
|
|
@@ -129787,6 +130059,8 @@ var ts;
|
|
|
129787
130059
|
return lastTypeNode;
|
|
129788
130060
|
}
|
|
129789
130061
|
function getContextualTypeFromParentOrAncestorTypeNode(node, checker) {
|
|
130062
|
+
if (node.flags & (8388608 /* NodeFlags.JSDoc */ & ~262144 /* NodeFlags.JavaScriptFile */))
|
|
130063
|
+
return undefined;
|
|
129790
130064
|
var contextualType = getContextualTypeFromParent(node, checker);
|
|
129791
130065
|
if (contextualType)
|
|
129792
130066
|
return contextualType;
|
|
@@ -132273,6 +132547,10 @@ var ts;
|
|
|
132273
132547
|
return jsx === 2 /* JsxEmit.React */ || jsx === 3 /* JsxEmit.ReactNative */;
|
|
132274
132548
|
}
|
|
132275
132549
|
ts.jsxModeNeedsExplicitImport = jsxModeNeedsExplicitImport;
|
|
132550
|
+
function isSourceFileFromLibrary(program, node) {
|
|
132551
|
+
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
132552
|
+
}
|
|
132553
|
+
ts.isSourceFileFromLibrary = isSourceFileFromLibrary;
|
|
132276
132554
|
// #endregion
|
|
132277
132555
|
})(ts || (ts = {}));
|
|
132278
132556
|
/*@internal*/
|
|
@@ -135299,7 +135577,7 @@ var ts;
|
|
|
135299
135577
|
if (preferences.includeCompletionsWithClassMemberSnippets &&
|
|
135300
135578
|
preferences.includeCompletionsWithInsertText &&
|
|
135301
135579
|
completionKind === 3 /* CompletionKind.MemberLike */ &&
|
|
135302
|
-
isClassLikeMemberCompletion(symbol, location)) {
|
|
135580
|
+
isClassLikeMemberCompletion(symbol, location, sourceFile)) {
|
|
135303
135581
|
var importAdder = void 0;
|
|
135304
135582
|
(_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken, formatContext), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder, replacementSpan = _b.replacementSpan);
|
|
135305
135583
|
sortText = Completions.SortText.ClassMemberSnippets; // sortText has to be lower priority than the sortText for keywords. See #47852.
|
|
@@ -135371,7 +135649,7 @@ var ts;
|
|
|
135371
135649
|
data: data,
|
|
135372
135650
|
};
|
|
135373
135651
|
}
|
|
135374
|
-
function isClassLikeMemberCompletion(symbol, location) {
|
|
135652
|
+
function isClassLikeMemberCompletion(symbol, location, sourceFile) {
|
|
135375
135653
|
// TODO: support JS files.
|
|
135376
135654
|
if (ts.isInJSFile(location)) {
|
|
135377
135655
|
return false;
|
|
@@ -135405,6 +135683,7 @@ var ts;
|
|
|
135405
135683
|
location.parent.parent &&
|
|
135406
135684
|
ts.isClassElement(location.parent) &&
|
|
135407
135685
|
location === location.parent.name &&
|
|
135686
|
+
location.parent.getLastToken(sourceFile) === location.parent.name &&
|
|
135408
135687
|
ts.isClassLike(location.parent.parent)) ||
|
|
135409
135688
|
(location.parent &&
|
|
135410
135689
|
ts.isSyntaxList(location) &&
|
|
@@ -142566,6 +142845,12 @@ var ts;
|
|
|
142566
142845
|
var label = ts.getTargetLabel(node.parent, node.text);
|
|
142567
142846
|
return label ? [createDefinitionInfoFromName(typeChecker, label, "label" /* ScriptElementKind.label */, node.text, /*containerName*/ undefined)] : undefined; // TODO: GH#18217
|
|
142568
142847
|
}
|
|
142848
|
+
if (node.kind === 105 /* SyntaxKind.ReturnKeyword */) {
|
|
142849
|
+
var functionDeclaration = ts.findAncestor(node.parent, function (n) {
|
|
142850
|
+
return ts.isClassStaticBlockDeclaration(n) ? "quit" : ts.isFunctionLikeDeclaration(n);
|
|
142851
|
+
});
|
|
142852
|
+
return functionDeclaration ? [createDefinitionFromSignatureDeclaration(typeChecker, functionDeclaration)] : undefined;
|
|
142853
|
+
}
|
|
142569
142854
|
if (ts.isStaticModifier(node) && ts.isClassStaticBlockDeclaration(node.parent)) {
|
|
142570
142855
|
var classDecl = node.parent.parent;
|
|
142571
142856
|
var _c = getSymbol(classDecl, typeChecker, stopAtAlias), symbol_1 = _c.symbol, failedAliasResolution_1 = _c.failedAliasResolution;
|
|
@@ -142701,13 +142986,16 @@ var ts;
|
|
|
142701
142986
|
if (!baseDeclaration)
|
|
142702
142987
|
return;
|
|
142703
142988
|
var baseTypeNode = ts.getEffectiveBaseTypeNode(baseDeclaration);
|
|
142704
|
-
|
|
142705
|
-
|
|
142989
|
+
if (!baseTypeNode)
|
|
142990
|
+
return;
|
|
142991
|
+
var expression = ts.skipParentheses(baseTypeNode.expression);
|
|
142992
|
+
var base = ts.isClassExpression(expression) ? expression.symbol : typeChecker.getSymbolAtLocation(expression);
|
|
142993
|
+
if (!base)
|
|
142706
142994
|
return;
|
|
142707
142995
|
var name = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(classElement.name));
|
|
142708
142996
|
var symbol = ts.hasStaticModifier(classElement)
|
|
142709
|
-
? typeChecker.getPropertyOfType(typeChecker.
|
|
142710
|
-
: typeChecker.getPropertyOfType(
|
|
142997
|
+
? typeChecker.getPropertyOfType(typeChecker.getTypeOfSymbol(base), name)
|
|
142998
|
+
: typeChecker.getPropertyOfType(typeChecker.getDeclaredTypeOfSymbol(base), name);
|
|
142711
142999
|
if (!symbol)
|
|
142712
143000
|
return;
|
|
142713
143001
|
return getDefinitionFromSymbol(typeChecker, symbol, node);
|
|
@@ -143414,19 +143702,24 @@ var ts;
|
|
|
143414
143702
|
return getCommentOwnerInfoWorker(commentOwner.initializer, options);
|
|
143415
143703
|
case 260 /* SyntaxKind.ClassDeclaration */:
|
|
143416
143704
|
case 261 /* SyntaxKind.InterfaceDeclaration */:
|
|
143417
|
-
case 168 /* SyntaxKind.PropertySignature */:
|
|
143418
143705
|
case 263 /* SyntaxKind.EnumDeclaration */:
|
|
143419
143706
|
case 302 /* SyntaxKind.EnumMember */:
|
|
143420
143707
|
case 262 /* SyntaxKind.TypeAliasDeclaration */:
|
|
143421
143708
|
return { commentOwner: commentOwner };
|
|
143709
|
+
case 168 /* SyntaxKind.PropertySignature */: {
|
|
143710
|
+
var host_1 = commentOwner;
|
|
143711
|
+
return host_1.type && ts.isFunctionTypeNode(host_1.type)
|
|
143712
|
+
? { commentOwner: commentOwner, parameters: host_1.type.parameters, hasReturn: hasReturn(host_1.type, options) }
|
|
143713
|
+
: { commentOwner: commentOwner };
|
|
143714
|
+
}
|
|
143422
143715
|
case 240 /* SyntaxKind.VariableStatement */: {
|
|
143423
143716
|
var varStatement = commentOwner;
|
|
143424
143717
|
var varDeclarations = varStatement.declarationList.declarations;
|
|
143425
|
-
var
|
|
143718
|
+
var host_2 = varDeclarations.length === 1 && varDeclarations[0].initializer
|
|
143426
143719
|
? getRightHandSideOfAssignment(varDeclarations[0].initializer)
|
|
143427
143720
|
: undefined;
|
|
143428
|
-
return
|
|
143429
|
-
? { commentOwner: commentOwner, parameters:
|
|
143721
|
+
return host_2
|
|
143722
|
+
? { commentOwner: commentOwner, parameters: host_2.parameters, hasReturn: hasReturn(host_2, options) }
|
|
143430
143723
|
: { commentOwner: commentOwner };
|
|
143431
143724
|
}
|
|
143432
143725
|
case 308 /* SyntaxKind.SourceFile */:
|
|
@@ -143456,7 +143749,7 @@ var ts;
|
|
|
143456
143749
|
}
|
|
143457
143750
|
function hasReturn(node, options) {
|
|
143458
143751
|
return !!(options === null || options === void 0 ? void 0 : options.generateReturnInDocTemplate) &&
|
|
143459
|
-
(ts.isArrowFunction(node) && ts.isExpression(node.body)
|
|
143752
|
+
(ts.isFunctionTypeNode(node) || ts.isArrowFunction(node) && ts.isExpression(node.body)
|
|
143460
143753
|
|| ts.isFunctionLikeDeclaration(node) && node.body && ts.isBlock(node.body) && !!ts.forEachReturnStatement(node.body, function (n) { return n; }));
|
|
143461
143754
|
}
|
|
143462
143755
|
function getRightHandSideOfAssignment(rightHandSide) {
|
|
@@ -144497,23 +144790,39 @@ var ts;
|
|
|
144497
144790
|
* 2) Coalescing imports from the same module
|
|
144498
144791
|
* 3) Sorting imports
|
|
144499
144792
|
*/
|
|
144500
|
-
function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
144793
|
+
function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
|
|
144501
144794
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
144502
|
-
var
|
|
144795
|
+
var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
144796
|
+
var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
|
|
144797
|
+
var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
144798
|
+
var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
|
|
144799
|
+
var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
|
|
144800
|
+
var processImportsOfSameModuleSpecifier = function (importGroup) {
|
|
144801
|
+
var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
|
|
144802
|
+
return shouldSort
|
|
144803
|
+
? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
|
|
144804
|
+
: processedDeclarations;
|
|
144805
|
+
};
|
|
144503
144806
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
144504
144807
|
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
144505
|
-
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144506
|
-
//
|
|
144507
|
-
|
|
144508
|
-
|
|
144808
|
+
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
144809
|
+
// Exports are always used
|
|
144810
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
144811
|
+
// All of the old ExportDeclarations in the file, in syntactic order.
|
|
144812
|
+
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
|
|
144813
|
+
organizeImportsWorker(topLevelExportDecls, coalesceExports);
|
|
144814
|
+
}
|
|
144509
144815
|
for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
|
|
144510
144816
|
var ambientModule = _a[_i];
|
|
144511
144817
|
if (!ambientModule.body)
|
|
144512
144818
|
continue;
|
|
144513
144819
|
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
144514
|
-
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144515
|
-
|
|
144516
|
-
|
|
144820
|
+
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
144821
|
+
// Exports are always used
|
|
144822
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
144823
|
+
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
|
|
144824
|
+
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
|
|
144825
|
+
}
|
|
144517
144826
|
}
|
|
144518
144827
|
return changeTracker.getChanges();
|
|
144519
144828
|
function organizeImportsWorker(oldImportDecls, coalesce) {
|
|
@@ -144526,8 +144835,12 @@ var ts;
|
|
|
144526
144835
|
// Consider: we could do a more careful check that this trivia is actually a header,
|
|
144527
144836
|
// but the consequences of being wrong are very minor.
|
|
144528
144837
|
ts.suppressLeadingTrivia(oldImportDecls[0]);
|
|
144529
|
-
var oldImportGroups =
|
|
144530
|
-
|
|
144838
|
+
var oldImportGroups = shouldCombine
|
|
144839
|
+
? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
|
|
144840
|
+
: [oldImportDecls];
|
|
144841
|
+
var sortedImportGroups = shouldSort
|
|
144842
|
+
? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
|
|
144843
|
+
: oldImportGroups;
|
|
144531
144844
|
var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
|
|
144532
144845
|
return getExternalModuleName(importGroup[0].moduleSpecifier)
|
|
144533
144846
|
? coalesce(importGroup)
|
|
@@ -144591,11 +144904,7 @@ var ts;
|
|
|
144591
144904
|
}
|
|
144592
144905
|
return false;
|
|
144593
144906
|
}
|
|
144594
|
-
function removeUnusedImports(oldImports, sourceFile, program
|
|
144595
|
-
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
144596
|
-
if (skipDestructiveCodeActions) {
|
|
144597
|
-
return oldImports;
|
|
144598
|
-
}
|
|
144907
|
+
function removeUnusedImports(oldImports, sourceFile, program) {
|
|
144599
144908
|
var typeChecker = program.getTypeChecker();
|
|
144600
144909
|
var compilerOptions = program.getCompilerOptions();
|
|
144601
144910
|
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
|
@@ -145451,7 +145760,7 @@ var ts;
|
|
|
145451
145760
|
return bestMatch;
|
|
145452
145761
|
}
|
|
145453
145762
|
function betterMatch(a, b) {
|
|
145454
|
-
return ts.min(a, b, compareMatches);
|
|
145763
|
+
return ts.min([a, b], compareMatches);
|
|
145455
145764
|
}
|
|
145456
145765
|
function compareMatches(a, b) {
|
|
145457
145766
|
return a === undefined ? 1 /* Comparison.GreaterThan */ : b === undefined ? -1 /* Comparison.LessThan */
|
|
@@ -146060,8 +146369,8 @@ var ts;
|
|
|
146060
146369
|
}
|
|
146061
146370
|
if (ts.scanner.getToken() === 15 /* SyntaxKind.TemplateHead */) {
|
|
146062
146371
|
var stack = [ts.scanner.getToken()];
|
|
146063
|
-
var token = ts.scanner.scan();
|
|
146064
146372
|
loop: while (ts.length(stack)) {
|
|
146373
|
+
var token = ts.scanner.scan();
|
|
146065
146374
|
switch (token) {
|
|
146066
146375
|
case 1 /* SyntaxKind.EndOfFileToken */:
|
|
146067
146376
|
break loop;
|
|
@@ -146089,7 +146398,6 @@ var ts;
|
|
|
146089
146398
|
}
|
|
146090
146399
|
break;
|
|
146091
146400
|
}
|
|
146092
|
-
token = ts.scanner.scan();
|
|
146093
146401
|
}
|
|
146094
146402
|
nextToken();
|
|
146095
146403
|
}
|
|
@@ -148568,7 +148876,7 @@ var ts;
|
|
|
148568
148876
|
tags = signature.getJsDocTags();
|
|
148569
148877
|
if (allSignatures.length > 1 && documentation.length === 0 && tags.length === 0) {
|
|
148570
148878
|
documentation = allSignatures[0].getDocumentationComment(typeChecker);
|
|
148571
|
-
tags = allSignatures[0].getJsDocTags();
|
|
148879
|
+
tags = allSignatures[0].getJsDocTags().filter(function (tag) { return tag.name !== "deprecated"; }); // should only include @deprecated JSDoc tag on the first overload (#49368)
|
|
148572
148880
|
}
|
|
148573
148881
|
}
|
|
148574
148882
|
function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) {
|
|
@@ -148911,7 +149219,7 @@ var ts;
|
|
|
148911
149219
|
return false;
|
|
148912
149220
|
}
|
|
148913
149221
|
function shouldRescanJsxText(node) {
|
|
148914
|
-
return ts.isJsxText(node)
|
|
149222
|
+
return ts.isJsxText(node) || ts.isJsxElement(node) && (lastTokenInfo === null || lastTokenInfo === void 0 ? void 0 : lastTokenInfo.token.kind) === 11 /* SyntaxKind.JsxText */;
|
|
148915
149223
|
}
|
|
148916
149224
|
function shouldRescanSlashToken(container) {
|
|
148917
149225
|
return container.kind === 13 /* SyntaxKind.RegularExpressionLiteral */;
|
|
@@ -149680,10 +149988,10 @@ var ts;
|
|
|
149680
149988
|
!nodeIsInDecoratorContext(context.nextTokenParent);
|
|
149681
149989
|
}
|
|
149682
149990
|
function nodeIsInDecoratorContext(node) {
|
|
149683
|
-
while (ts.
|
|
149991
|
+
while (node && ts.isExpression(node)) {
|
|
149684
149992
|
node = node.parent;
|
|
149685
149993
|
}
|
|
149686
|
-
return node.kind === 167 /* SyntaxKind.Decorator */;
|
|
149994
|
+
return node && node.kind === 167 /* SyntaxKind.Decorator */;
|
|
149687
149995
|
}
|
|
149688
149996
|
function isStartOfVariableDeclarationList(context) {
|
|
149689
149997
|
return context.currentTokenParent.kind === 258 /* SyntaxKind.VariableDeclarationList */ &&
|
|
@@ -152601,6 +152909,26 @@ var ts;
|
|
|
152601
152909
|
function startPositionToDeleteNodeInList(sourceFile, node) {
|
|
152602
152910
|
return ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, { leadingTriviaOption: LeadingTriviaOption.IncludeAll }), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true);
|
|
152603
152911
|
}
|
|
152912
|
+
function endPositionToDeleteNodeInList(sourceFile, node, prevNode, nextNode) {
|
|
152913
|
+
var end = startPositionToDeleteNodeInList(sourceFile, nextNode);
|
|
152914
|
+
if (prevNode === undefined || ts.positionsAreOnSameLine(getAdjustedEndPosition(sourceFile, node, {}), end, sourceFile)) {
|
|
152915
|
+
return end;
|
|
152916
|
+
}
|
|
152917
|
+
var token = ts.findPrecedingToken(nextNode.getStart(sourceFile), sourceFile);
|
|
152918
|
+
if (isSeparator(node, token)) {
|
|
152919
|
+
var prevToken = ts.findPrecedingToken(node.getStart(sourceFile), sourceFile);
|
|
152920
|
+
if (isSeparator(prevNode, prevToken)) {
|
|
152921
|
+
var pos = ts.skipTrivia(sourceFile.text, token.getEnd(), /*stopAfterLineBreak*/ true, /*stopAtComments*/ true);
|
|
152922
|
+
if (ts.positionsAreOnSameLine(prevToken.getStart(sourceFile), token.getStart(sourceFile), sourceFile)) {
|
|
152923
|
+
return ts.isLineBreak(sourceFile.text.charCodeAt(pos - 1)) ? pos - 1 : pos;
|
|
152924
|
+
}
|
|
152925
|
+
if (ts.isLineBreak(sourceFile.text.charCodeAt(pos))) {
|
|
152926
|
+
return pos;
|
|
152927
|
+
}
|
|
152928
|
+
}
|
|
152929
|
+
}
|
|
152930
|
+
return end;
|
|
152931
|
+
}
|
|
152604
152932
|
function getClassOrObjectBraceEnds(cls, sourceFile) {
|
|
152605
152933
|
var open = ts.findChildOfKind(cls, 18 /* SyntaxKind.OpenBraceToken */, sourceFile);
|
|
152606
152934
|
var close = ts.findChildOfKind(cls, 19 /* SyntaxKind.CloseBraceToken */, sourceFile);
|
|
@@ -153158,7 +153486,7 @@ var ts;
|
|
|
153158
153486
|
deletedNodesInLists.add(node);
|
|
153159
153487
|
changes.deleteRange(sourceFile, {
|
|
153160
153488
|
pos: startPositionToDeleteNodeInList(sourceFile, node),
|
|
153161
|
-
end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) :
|
|
153489
|
+
end: index === containingList.length - 1 ? getAdjustedEndPosition(sourceFile, node, {}) : endPositionToDeleteNodeInList(sourceFile, node, containingList[index - 1], containingList[index + 1]),
|
|
153162
153490
|
});
|
|
153163
153491
|
}
|
|
153164
153492
|
})(textChanges = ts.textChanges || (ts.textChanges = {}));
|
|
@@ -153628,6 +153956,15 @@ var ts;
|
|
|
153628
153956
|
});
|
|
153629
153957
|
}
|
|
153630
153958
|
function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
|
|
153959
|
+
if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
|
|
153960
|
+
var exprType = checker.getTypeAtLocation(insertionSite);
|
|
153961
|
+
var asyncIter = checker.getAsyncIterableType();
|
|
153962
|
+
if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
|
|
153963
|
+
var forOf = insertionSite.parent;
|
|
153964
|
+
changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
|
|
153965
|
+
return;
|
|
153966
|
+
}
|
|
153967
|
+
}
|
|
153631
153968
|
if (ts.isBinaryExpression(insertionSite)) {
|
|
153632
153969
|
for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
|
|
153633
153970
|
var side = _a[_i];
|
|
@@ -157353,6 +157690,143 @@ var ts;
|
|
|
157353
157690
|
})(ts || (ts = {}));
|
|
157354
157691
|
/* @internal */
|
|
157355
157692
|
var ts;
|
|
157693
|
+
(function (ts) {
|
|
157694
|
+
var codefix;
|
|
157695
|
+
(function (codefix) {
|
|
157696
|
+
var fixId = "fixImportNonExportedMember";
|
|
157697
|
+
var errorCodes = [
|
|
157698
|
+
ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported.code,
|
|
157699
|
+
];
|
|
157700
|
+
codefix.registerCodeFix({
|
|
157701
|
+
errorCodes: errorCodes,
|
|
157702
|
+
fixIds: [fixId],
|
|
157703
|
+
getCodeActions: function (context) {
|
|
157704
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
157705
|
+
var info = getInfo(sourceFile, span.start, program);
|
|
157706
|
+
if (info === undefined)
|
|
157707
|
+
return undefined;
|
|
157708
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, program, info); });
|
|
157709
|
+
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)];
|
|
157710
|
+
},
|
|
157711
|
+
getAllCodeActions: function (context) {
|
|
157712
|
+
var program = context.program;
|
|
157713
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
157714
|
+
var exports = new ts.Map();
|
|
157715
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
157716
|
+
var info = getInfo(diag.file, diag.start, program);
|
|
157717
|
+
if (info === undefined)
|
|
157718
|
+
return undefined;
|
|
157719
|
+
var exportName = info.exportName, node = info.node, moduleSourceFile = info.moduleSourceFile;
|
|
157720
|
+
if (tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly) === undefined && ts.canHaveExportModifier(node)) {
|
|
157721
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
157722
|
+
}
|
|
157723
|
+
else {
|
|
157724
|
+
var moduleExports = exports.get(moduleSourceFile) || { typeOnlyExports: [], exports: [] };
|
|
157725
|
+
if (exportName.isTypeOnly) {
|
|
157726
|
+
moduleExports.typeOnlyExports.push(exportName);
|
|
157727
|
+
}
|
|
157728
|
+
else {
|
|
157729
|
+
moduleExports.exports.push(exportName);
|
|
157730
|
+
}
|
|
157731
|
+
exports.set(moduleSourceFile, moduleExports);
|
|
157732
|
+
}
|
|
157733
|
+
});
|
|
157734
|
+
exports.forEach(function (moduleExports, moduleSourceFile) {
|
|
157735
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ true);
|
|
157736
|
+
if (exportDeclaration && exportDeclaration.isTypeOnly) {
|
|
157737
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.typeOnlyExports, exportDeclaration);
|
|
157738
|
+
doChanges(changes, program, moduleSourceFile, moduleExports.exports, tryGetExportDeclaration(moduleSourceFile, /*isTypeOnly*/ false));
|
|
157739
|
+
}
|
|
157740
|
+
else {
|
|
157741
|
+
doChanges(changes, program, moduleSourceFile, __spreadArray(__spreadArray([], moduleExports.exports, true), moduleExports.typeOnlyExports, true), exportDeclaration);
|
|
157742
|
+
}
|
|
157743
|
+
});
|
|
157744
|
+
}));
|
|
157745
|
+
}
|
|
157746
|
+
});
|
|
157747
|
+
function getInfo(sourceFile, pos, program) {
|
|
157748
|
+
var _a;
|
|
157749
|
+
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
157750
|
+
if (ts.isIdentifier(token)) {
|
|
157751
|
+
var importDeclaration = ts.findAncestor(token, ts.isImportDeclaration);
|
|
157752
|
+
if (importDeclaration === undefined)
|
|
157753
|
+
return undefined;
|
|
157754
|
+
var moduleSpecifier = ts.isStringLiteral(importDeclaration.moduleSpecifier) ? importDeclaration.moduleSpecifier.text : undefined;
|
|
157755
|
+
if (moduleSpecifier === undefined)
|
|
157756
|
+
return undefined;
|
|
157757
|
+
var resolvedModule = ts.getResolvedModule(sourceFile, moduleSpecifier, /*mode*/ undefined);
|
|
157758
|
+
if (resolvedModule === undefined)
|
|
157759
|
+
return undefined;
|
|
157760
|
+
var moduleSourceFile = program.getSourceFile(resolvedModule.resolvedFileName);
|
|
157761
|
+
if (moduleSourceFile === undefined || ts.isSourceFileFromLibrary(program, moduleSourceFile))
|
|
157762
|
+
return undefined;
|
|
157763
|
+
var moduleSymbol = moduleSourceFile.symbol;
|
|
157764
|
+
var locals = (_a = moduleSymbol.valueDeclaration) === null || _a === void 0 ? void 0 : _a.locals;
|
|
157765
|
+
if (locals === undefined)
|
|
157766
|
+
return undefined;
|
|
157767
|
+
var localSymbol = locals.get(token.escapedText);
|
|
157768
|
+
if (localSymbol === undefined)
|
|
157769
|
+
return undefined;
|
|
157770
|
+
var node = getNodeOfSymbol(localSymbol);
|
|
157771
|
+
if (node === undefined)
|
|
157772
|
+
return undefined;
|
|
157773
|
+
var exportName = { node: token, isTypeOnly: ts.isTypeDeclaration(node) };
|
|
157774
|
+
return { exportName: exportName, node: node, moduleSourceFile: moduleSourceFile, moduleSpecifier: moduleSpecifier };
|
|
157775
|
+
}
|
|
157776
|
+
return undefined;
|
|
157777
|
+
}
|
|
157778
|
+
function doChange(changes, program, _a) {
|
|
157779
|
+
var exportName = _a.exportName, node = _a.node, moduleSourceFile = _a.moduleSourceFile;
|
|
157780
|
+
var exportDeclaration = tryGetExportDeclaration(moduleSourceFile, exportName.isTypeOnly);
|
|
157781
|
+
if (exportDeclaration) {
|
|
157782
|
+
updateExport(changes, program, moduleSourceFile, exportDeclaration, [exportName]);
|
|
157783
|
+
}
|
|
157784
|
+
else if (ts.canHaveExportModifier(node)) {
|
|
157785
|
+
changes.insertExportModifier(moduleSourceFile, node);
|
|
157786
|
+
}
|
|
157787
|
+
else {
|
|
157788
|
+
createExport(changes, program, moduleSourceFile, [exportName]);
|
|
157789
|
+
}
|
|
157790
|
+
}
|
|
157791
|
+
function doChanges(changes, program, sourceFile, moduleExports, node) {
|
|
157792
|
+
if (ts.length(moduleExports)) {
|
|
157793
|
+
if (node) {
|
|
157794
|
+
updateExport(changes, program, sourceFile, node, moduleExports);
|
|
157795
|
+
}
|
|
157796
|
+
else {
|
|
157797
|
+
createExport(changes, program, sourceFile, moduleExports);
|
|
157798
|
+
}
|
|
157799
|
+
}
|
|
157800
|
+
}
|
|
157801
|
+
function tryGetExportDeclaration(sourceFile, isTypeOnly) {
|
|
157802
|
+
var predicate = function (node) {
|
|
157803
|
+
return ts.isExportDeclaration(node) && (isTypeOnly && node.isTypeOnly || !node.isTypeOnly);
|
|
157804
|
+
};
|
|
157805
|
+
return ts.findLast(sourceFile.statements, predicate);
|
|
157806
|
+
}
|
|
157807
|
+
function updateExport(changes, program, sourceFile, node, names) {
|
|
157808
|
+
var namedExports = node.exportClause && ts.isNamedExports(node.exportClause) ? node.exportClause.elements : ts.factory.createNodeArray([]);
|
|
157809
|
+
var allowTypeModifier = !node.isTypeOnly && !!(program.getCompilerOptions().isolatedModules || ts.find(namedExports, function (e) { return e.isTypeOnly; }));
|
|
157810
|
+
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));
|
|
157811
|
+
}
|
|
157812
|
+
function createExport(changes, program, sourceFile, names) {
|
|
157813
|
+
changes.insertNodeAtEndOfScope(sourceFile, sourceFile, ts.factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, ts.factory.createNamedExports(createExportSpecifiers(names, /*allowTypeModifier*/ !!program.getCompilerOptions().isolatedModules)), /*moduleSpecifier*/ undefined, /*assertClause*/ undefined));
|
|
157814
|
+
}
|
|
157815
|
+
function createExportSpecifiers(names, allowTypeModifier) {
|
|
157816
|
+
return ts.factory.createNodeArray(ts.map(names, function (n) { return ts.factory.createExportSpecifier(allowTypeModifier && n.isTypeOnly, /*propertyName*/ undefined, n.node); }));
|
|
157817
|
+
}
|
|
157818
|
+
function getNodeOfSymbol(symbol) {
|
|
157819
|
+
if (symbol.valueDeclaration === undefined) {
|
|
157820
|
+
return ts.firstOrUndefined(symbol.declarations);
|
|
157821
|
+
}
|
|
157822
|
+
var declaration = symbol.valueDeclaration;
|
|
157823
|
+
var variableStatement = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : undefined;
|
|
157824
|
+
return variableStatement && ts.length(variableStatement.declarationList.declarations) === 1 ? variableStatement : declaration;
|
|
157825
|
+
}
|
|
157826
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
157827
|
+
})(ts || (ts = {}));
|
|
157828
|
+
/* @internal */
|
|
157829
|
+
var ts;
|
|
157356
157830
|
(function (ts) {
|
|
157357
157831
|
var codefix;
|
|
157358
157832
|
(function (codefix) {
|
|
@@ -157883,7 +158357,7 @@ var ts;
|
|
|
157883
158357
|
var argIndex = ts.findIndex(parent.parent.arguments, function (arg) { return arg === parent; });
|
|
157884
158358
|
if (argIndex < 0)
|
|
157885
158359
|
return undefined;
|
|
157886
|
-
var signature =
|
|
158360
|
+
var signature = checker.getResolvedSignature(parent.parent);
|
|
157887
158361
|
if (!(signature && signature.declaration && signature.parameters[argIndex]))
|
|
157888
158362
|
return undefined;
|
|
157889
158363
|
var param = signature.parameters[argIndex].valueDeclaration;
|
|
@@ -157930,13 +158404,13 @@ var ts;
|
|
|
157930
158404
|
if (ts.isIdentifier(token) && ts.isCallExpression(parent.parent)) {
|
|
157931
158405
|
var moduleDeclaration = ts.find(symbol.declarations, ts.isModuleDeclaration);
|
|
157932
158406
|
var moduleDeclarationSourceFile = moduleDeclaration === null || moduleDeclaration === void 0 ? void 0 : moduleDeclaration.getSourceFile();
|
|
157933
|
-
if (moduleDeclaration && moduleDeclarationSourceFile && !isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
158407
|
+
if (moduleDeclaration && moduleDeclarationSourceFile && !ts.isSourceFileFromLibrary(program, moduleDeclarationSourceFile)) {
|
|
157934
158408
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: sourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleDeclaration };
|
|
157935
158409
|
}
|
|
157936
158410
|
var moduleSourceFile = ts.find(symbol.declarations, ts.isSourceFile);
|
|
157937
158411
|
if (sourceFile.commonJsModuleIndicator)
|
|
157938
158412
|
return undefined;
|
|
157939
|
-
if (moduleSourceFile && !isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
158413
|
+
if (moduleSourceFile && !ts.isSourceFileFromLibrary(program, moduleSourceFile)) {
|
|
157940
158414
|
return { kind: InfoKind.Function, token: token, call: parent.parent, sourceFile: moduleSourceFile, modifierFlags: 1 /* ModifierFlags.Export */, parentDeclaration: moduleSourceFile };
|
|
157941
158415
|
}
|
|
157942
158416
|
}
|
|
@@ -157946,7 +158420,7 @@ var ts;
|
|
|
157946
158420
|
return undefined;
|
|
157947
158421
|
// Prefer to change the class instead of the interface if they are merged
|
|
157948
158422
|
var declaration = classDeclaration || ts.find(symbol.declarations, function (d) { return ts.isInterfaceDeclaration(d) || ts.isTypeLiteralNode(d); });
|
|
157949
|
-
if (declaration && !isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
158423
|
+
if (declaration && !ts.isSourceFileFromLibrary(program, declaration.getSourceFile())) {
|
|
157950
158424
|
var makeStatic = !ts.isTypeLiteralNode(declaration) && (leftExpressionType.target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol);
|
|
157951
158425
|
if (makeStatic && (ts.isPrivateIdentifier(token) || ts.isInterfaceDeclaration(declaration)))
|
|
157952
158426
|
return undefined;
|
|
@@ -157958,14 +158432,11 @@ var ts;
|
|
|
157958
158432
|
return { kind: InfoKind.TypeLikeDeclaration, token: token, call: call, modifierFlags: modifierFlags, parentDeclaration: declaration, declSourceFile: declSourceFile, isJSFile: isJSFile };
|
|
157959
158433
|
}
|
|
157960
158434
|
var enumDeclaration = ts.find(symbol.declarations, ts.isEnumDeclaration);
|
|
157961
|
-
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
158435
|
+
if (enumDeclaration && !(leftExpressionType.flags & 1056 /* TypeFlags.EnumLike */) && !ts.isPrivateIdentifier(token) && !ts.isSourceFileFromLibrary(program, enumDeclaration.getSourceFile())) {
|
|
157962
158436
|
return { kind: InfoKind.Enum, token: token, parentDeclaration: enumDeclaration };
|
|
157963
158437
|
}
|
|
157964
158438
|
return undefined;
|
|
157965
158439
|
}
|
|
157966
|
-
function isSourceFileFromLibrary(program, node) {
|
|
157967
|
-
return program.isSourceFileFromExternalLibrary(node) || program.isSourceFileDefaultLibrary(node);
|
|
157968
|
-
}
|
|
157969
158440
|
function getActionsForMissingMemberDeclaration(context, info) {
|
|
157970
158441
|
return info.isJSFile ? ts.singleElementArray(createActionForAddMissingMemberInJavascriptFile(context, info)) :
|
|
157971
158442
|
createActionsForAddMissingMemberInTypeScriptFile(context, info);
|
|
@@ -163391,8 +163862,8 @@ var ts;
|
|
|
163391
163862
|
var i = 0;
|
|
163392
163863
|
for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) {
|
|
163393
163864
|
var _a = extractions_1[_i], functionExtraction = _a.functionExtraction, constantExtraction = _a.constantExtraction;
|
|
163394
|
-
var description = functionExtraction.description;
|
|
163395
163865
|
if (refactor.refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
|
163866
|
+
var description = functionExtraction.description;
|
|
163396
163867
|
if (functionExtraction.errors.length === 0) {
|
|
163397
163868
|
// Don't issue refactorings with duplicated names.
|
|
163398
163869
|
// Scopes come back in "innermost first" order, so extractions will
|
|
@@ -163416,15 +163887,15 @@ var ts;
|
|
|
163416
163887
|
}
|
|
163417
163888
|
}
|
|
163418
163889
|
if (refactor.refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
|
163890
|
+
var description = constantExtraction.description;
|
|
163419
163891
|
if (constantExtraction.errors.length === 0) {
|
|
163420
163892
|
// Don't issue refactorings with duplicated names.
|
|
163421
163893
|
// Scopes come back in "innermost first" order, so extractions will
|
|
163422
163894
|
// preferentially go into nearer scopes
|
|
163423
|
-
|
|
163424
|
-
|
|
163425
|
-
usedConstantNames.set(description_1, true);
|
|
163895
|
+
if (!usedConstantNames.has(description)) {
|
|
163896
|
+
usedConstantNames.set(description, true);
|
|
163426
163897
|
constantActions.push({
|
|
163427
|
-
description:
|
|
163898
|
+
description: description,
|
|
163428
163899
|
name: "constant_scope_".concat(i),
|
|
163429
163900
|
kind: extractConstantAction.kind
|
|
163430
163901
|
});
|
|
@@ -163569,7 +164040,6 @@ var ts;
|
|
|
163569
164040
|
var start = cursorRequest ? getExtractableParent(startToken) : ts.getParentNodeInSpan(startToken, sourceFile, adjustedSpan);
|
|
163570
164041
|
// Do the same for the ending position
|
|
163571
164042
|
var end = cursorRequest ? start : ts.getParentNodeInSpan(endToken, sourceFile, adjustedSpan);
|
|
163572
|
-
var declarations = [];
|
|
163573
164043
|
// We'll modify these flags as we walk the tree to collect data
|
|
163574
164044
|
// about what things need to be done as part of the extraction.
|
|
163575
164045
|
var rangeFacts = RangeFacts.None;
|
|
@@ -163612,7 +164082,7 @@ var ts;
|
|
|
163612
164082
|
// the expression.
|
|
163613
164083
|
return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] };
|
|
163614
164084
|
}
|
|
163615
|
-
return { targetRange: { range: statements, facts: rangeFacts,
|
|
164085
|
+
return { targetRange: { range: statements, facts: rangeFacts, thisNode: thisNode } };
|
|
163616
164086
|
}
|
|
163617
164087
|
if (ts.isReturnStatement(start) && !start.expression) {
|
|
163618
164088
|
// Makes no sense to extract an expression-less return statement.
|
|
@@ -163624,7 +164094,7 @@ var ts;
|
|
|
163624
164094
|
if (errors) {
|
|
163625
164095
|
return { errors: errors };
|
|
163626
164096
|
}
|
|
163627
|
-
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts,
|
|
164097
|
+
return { targetRange: { range: getStatementOrExpressionRange(node), facts: rangeFacts, thisNode: thisNode } }; // TODO: GH#18217
|
|
163628
164098
|
/**
|
|
163629
164099
|
* Attempt to refine the extraction node (generally, by shrinking it) to produce better results.
|
|
163630
164100
|
* @param node The unrefined extraction node.
|
|
@@ -163636,10 +164106,10 @@ var ts;
|
|
|
163636
164106
|
}
|
|
163637
164107
|
}
|
|
163638
164108
|
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
|
|
163639
|
-
var
|
|
164109
|
+
var declarations = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
|
163640
164110
|
var numInitializers = 0;
|
|
163641
164111
|
var lastInitializer = void 0;
|
|
163642
|
-
for (var _i = 0, declarations_5 =
|
|
164112
|
+
for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
|
|
163643
164113
|
var declaration = declarations_5[_i];
|
|
163644
164114
|
if (declaration.initializer) {
|
|
163645
164115
|
numInitializers++;
|
|
@@ -163739,7 +164209,6 @@ var ts;
|
|
|
163739
164209
|
(errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractExportedEntity));
|
|
163740
164210
|
return true;
|
|
163741
164211
|
}
|
|
163742
|
-
declarations.push(node.symbol);
|
|
163743
164212
|
}
|
|
163744
164213
|
// Some things can't be extracted in certain situations
|
|
163745
164214
|
switch (node.kind) {
|
|
@@ -165464,7 +165933,7 @@ var ts;
|
|
|
165464
165933
|
function getNewStatementsAndRemoveFromOldFile(oldFile, usage, changes, toMove, program, newModuleName, preferences) {
|
|
165465
165934
|
var checker = program.getTypeChecker();
|
|
165466
165935
|
var prologueDirectives = ts.takeWhile(oldFile.statements, ts.isPrologueDirective);
|
|
165467
|
-
if (
|
|
165936
|
+
if (oldFile.externalModuleIndicator === undefined && oldFile.commonJsModuleIndicator === undefined && usage.oldImportsNeededByNewFile.size() === 0) {
|
|
165468
165937
|
deleteMovedStatements(oldFile, toMove.ranges, changes);
|
|
165469
165938
|
return __spreadArray(__spreadArray([], prologueDirectives, true), toMove.all, true);
|
|
165470
165939
|
}
|
|
@@ -165705,7 +166174,12 @@ var ts;
|
|
|
165705
166174
|
switch (name.kind) {
|
|
165706
166175
|
case 79 /* SyntaxKind.Identifier */:
|
|
165707
166176
|
if (isUnused(name)) {
|
|
165708
|
-
|
|
166177
|
+
if (varDecl.initializer && ts.isRequireCall(varDecl.initializer, /*requireStringLiteralLikeArgument*/ true)) {
|
|
166178
|
+
changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && ts.length(varDecl.parent.declarations) === 1 ? varDecl.parent.parent : varDecl);
|
|
166179
|
+
}
|
|
166180
|
+
else {
|
|
166181
|
+
changes.delete(sourceFile, name);
|
|
166182
|
+
}
|
|
165709
166183
|
}
|
|
165710
166184
|
break;
|
|
165711
166185
|
case 204 /* SyntaxKind.ArrayBindingPattern */:
|
|
@@ -165937,6 +166411,9 @@ var ts;
|
|
|
165937
166411
|
ts.copyEntries(this.map, clone.map);
|
|
165938
166412
|
return clone;
|
|
165939
166413
|
};
|
|
166414
|
+
SymbolSet.prototype.size = function () {
|
|
166415
|
+
return this.map.size;
|
|
166416
|
+
};
|
|
165940
166417
|
return SymbolSet;
|
|
165941
166418
|
}());
|
|
165942
166419
|
function isTopLevelDeclaration(node) {
|
|
@@ -166025,7 +166502,8 @@ var ts;
|
|
|
166025
166502
|
if (useEs6Exports) {
|
|
166026
166503
|
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)));
|
|
166027
166504
|
}
|
|
166028
|
-
return
|
|
166505
|
+
return !!sourceFile.symbol && !!sourceFile.symbol.exports &&
|
|
166506
|
+
getNamesToExportInCommonJS(decl).some(function (name) { return sourceFile.symbol.exports.has(ts.escapeLeadingUnderscores(name)); });
|
|
166029
166507
|
}
|
|
166030
166508
|
function addExport(decl, useEs6Exports) {
|
|
166031
166509
|
return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl);
|
|
@@ -167785,8 +168263,8 @@ var ts;
|
|
|
167785
168263
|
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
167786
168264
|
}
|
|
167787
168265
|
};
|
|
167788
|
-
for (var _i = 0,
|
|
167789
|
-
var declaration =
|
|
168266
|
+
for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
|
|
168267
|
+
var declaration = declarations_6[_i];
|
|
167790
168268
|
_loop_20(declaration);
|
|
167791
168269
|
}
|
|
167792
168270
|
}
|
|
@@ -167812,8 +168290,8 @@ var ts;
|
|
|
167812
168290
|
if (inheritedDocs)
|
|
167813
168291
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
167814
168292
|
};
|
|
167815
|
-
for (var _i = 0,
|
|
167816
|
-
var declaration =
|
|
168293
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
168294
|
+
var declaration = declarations_7[_i];
|
|
167817
168295
|
_loop_21(declaration);
|
|
167818
168296
|
}
|
|
167819
168297
|
}
|
|
@@ -168983,12 +169461,14 @@ var ts;
|
|
|
168983
169461
|
return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
|
|
168984
169462
|
}
|
|
168985
169463
|
function organizeImports(args, formatOptions, preferences) {
|
|
169464
|
+
var _a;
|
|
168986
169465
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
168987
169466
|
synchronizeHostData();
|
|
168988
169467
|
ts.Debug.assert(args.type === "file");
|
|
168989
169468
|
var sourceFile = getValidSourceFile(args.fileName);
|
|
168990
169469
|
var formatContext = ts.formatting.getFormatContext(formatOptions, host);
|
|
168991
|
-
|
|
169470
|
+
var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
|
|
169471
|
+
return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
|
|
168992
169472
|
}
|
|
168993
169473
|
function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
|
|
168994
169474
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
@@ -171987,6 +172467,12 @@ var ts;
|
|
|
171987
172467
|
CommandTypes["ProvideInlayHints"] = "provideInlayHints";
|
|
171988
172468
|
// NOTE: If updating this, be sure to also update `allCommandNames` in `testRunner/unittests/tsserver/session.ts`.
|
|
171989
172469
|
})(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {}));
|
|
172470
|
+
var OrganizeImportsMode;
|
|
172471
|
+
(function (OrganizeImportsMode) {
|
|
172472
|
+
OrganizeImportsMode["All"] = "All";
|
|
172473
|
+
OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
|
|
172474
|
+
OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
|
|
172475
|
+
})(OrganizeImportsMode = protocol.OrganizeImportsMode || (protocol.OrganizeImportsMode = {}));
|
|
171990
172476
|
var WatchFileKind;
|
|
171991
172477
|
(function (WatchFileKind) {
|
|
171992
172478
|
WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval";
|
|
@@ -172873,6 +173359,7 @@ var ts;
|
|
|
172873
173359
|
this.watchOptions = watchOptions;
|
|
172874
173360
|
this.rootFiles = [];
|
|
172875
173361
|
this.rootFilesMap = new ts.Map();
|
|
173362
|
+
/*@internal*/
|
|
172876
173363
|
this.plugins = [];
|
|
172877
173364
|
/*@internal*/
|
|
172878
173365
|
/**
|
|
@@ -173401,6 +173888,7 @@ var ts;
|
|
|
173401
173888
|
this.directoryStructureHost = undefined;
|
|
173402
173889
|
this.exportMapCache = undefined;
|
|
173403
173890
|
this.projectErrors = undefined;
|
|
173891
|
+
this.plugins.length = 0;
|
|
173404
173892
|
// Clean up file watchers waiting for missing files
|
|
173405
173893
|
if (this.missingFilesMap) {
|
|
173406
173894
|
ts.clearMap(this.missingFilesMap, ts.closeFileWatcher);
|
|
@@ -174074,35 +174562,39 @@ var ts;
|
|
|
174074
174562
|
Project.prototype.isSourceOfProjectReferenceRedirect = function (fileName) {
|
|
174075
174563
|
return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName);
|
|
174076
174564
|
};
|
|
174565
|
+
/*@internal*/
|
|
174566
|
+
Project.prototype.getGlobalPluginSearchPaths = function () {
|
|
174567
|
+
// Search any globally-specified probe paths, then our peer node_modules
|
|
174568
|
+
return __spreadArray(__spreadArray([], this.projectService.pluginProbeLocations, true), [
|
|
174569
|
+
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
|
|
174570
|
+
ts.combinePaths(this.projectService.getExecutingFilePath(), "../../.."),
|
|
174571
|
+
], false);
|
|
174572
|
+
};
|
|
174077
174573
|
Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
|
|
174574
|
+
if (!this.projectService.globalPlugins.length)
|
|
174575
|
+
return;
|
|
174078
174576
|
var host = this.projectService.host;
|
|
174079
174577
|
if (!host.require && !host.importPlugin) {
|
|
174080
174578
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
174081
174579
|
return;
|
|
174082
174580
|
}
|
|
174083
|
-
//
|
|
174084
|
-
var searchPaths =
|
|
174085
|
-
|
|
174086
|
-
|
|
174087
|
-
|
|
174088
|
-
|
|
174089
|
-
|
|
174090
|
-
|
|
174091
|
-
|
|
174092
|
-
|
|
174093
|
-
|
|
174094
|
-
|
|
174095
|
-
|
|
174096
|
-
|
|
174097
|
-
|
|
174098
|
-
|
|
174099
|
-
|
|
174100
|
-
var this_1 = this;
|
|
174101
|
-
// Enable global plugins with synthetic configuration entries
|
|
174102
|
-
for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
|
|
174103
|
-
var globalPluginName = _a[_i];
|
|
174104
|
-
_loop_1(globalPluginName);
|
|
174105
|
-
}
|
|
174581
|
+
// Enable global plugins with synthetic configuration entries
|
|
174582
|
+
var searchPaths = this.getGlobalPluginSearchPaths();
|
|
174583
|
+
var _loop_1 = function (globalPluginName) {
|
|
174584
|
+
// Skip empty names from odd commandline parses
|
|
174585
|
+
if (!globalPluginName)
|
|
174586
|
+
return "continue";
|
|
174587
|
+
// Skip already-locally-loaded plugins
|
|
174588
|
+
if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; }))
|
|
174589
|
+
return "continue";
|
|
174590
|
+
// Provide global: true so plugins can detect why they can't find their config
|
|
174591
|
+
this_1.projectService.logger.info("Loading global plugin ".concat(globalPluginName));
|
|
174592
|
+
this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths, pluginConfigOverrides);
|
|
174593
|
+
};
|
|
174594
|
+
var this_1 = this;
|
|
174595
|
+
for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) {
|
|
174596
|
+
var globalPluginName = _a[_i];
|
|
174597
|
+
_loop_1(globalPluginName);
|
|
174106
174598
|
}
|
|
174107
174599
|
};
|
|
174108
174600
|
/**
|
|
@@ -174833,14 +175325,16 @@ var ts;
|
|
|
174833
175325
|
};
|
|
174834
175326
|
/*@internal*/
|
|
174835
175327
|
ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
|
|
175328
|
+
var _a;
|
|
175329
|
+
this.plugins.length = 0;
|
|
175330
|
+
if (!((_a = options.plugins) === null || _a === void 0 ? void 0 : _a.length) && !this.projectService.globalPlugins.length)
|
|
175331
|
+
return;
|
|
174836
175332
|
var host = this.projectService.host;
|
|
174837
175333
|
if (!host.require && !host.importPlugin) {
|
|
174838
175334
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
174839
175335
|
return;
|
|
174840
175336
|
}
|
|
174841
|
-
|
|
174842
|
-
// ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/
|
|
174843
|
-
var searchPaths = __spreadArray([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations, true);
|
|
175337
|
+
var searchPaths = this.getGlobalPluginSearchPaths();
|
|
174844
175338
|
if (this.projectService.allowLocalPluginLoads) {
|
|
174845
175339
|
var local = ts.getDirectoryPath(this.canonicalConfigFilePath);
|
|
174846
175340
|
this.projectService.logger.info("Local plugin loading enabled; adding ".concat(local, " to search paths"));
|
|
@@ -174848,8 +175342,8 @@ var ts;
|
|
|
174848
175342
|
}
|
|
174849
175343
|
// Enable tsconfig-specified plugins
|
|
174850
175344
|
if (options.plugins) {
|
|
174851
|
-
for (var _i = 0,
|
|
174852
|
-
var pluginConfigEntry =
|
|
175345
|
+
for (var _i = 0, _b = options.plugins; _i < _b.length; _i++) {
|
|
175346
|
+
var pluginConfigEntry = _b[_i];
|
|
174853
175347
|
this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
174854
175348
|
}
|
|
174855
175349
|
}
|
|
@@ -175694,18 +176188,20 @@ var ts;
|
|
|
175694
176188
|
return ensureProject ? this.ensureDefaultProjectForFile(fileName) : this.tryGetDefaultProjectForFile(fileName);
|
|
175695
176189
|
};
|
|
175696
176190
|
/* @internal */
|
|
175697
|
-
ProjectService.prototype.tryGetDefaultProjectForFile = function (
|
|
175698
|
-
var scriptInfo = this.getScriptInfoForNormalizedPath(
|
|
176191
|
+
ProjectService.prototype.tryGetDefaultProjectForFile = function (fileNameOrScriptInfo) {
|
|
176192
|
+
var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
|
|
175699
176193
|
return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined;
|
|
175700
176194
|
};
|
|
175701
176195
|
/* @internal */
|
|
175702
|
-
ProjectService.prototype.ensureDefaultProjectForFile = function (
|
|
175703
|
-
return this.tryGetDefaultProjectForFile(
|
|
176196
|
+
ProjectService.prototype.ensureDefaultProjectForFile = function (fileNameOrScriptInfo) {
|
|
176197
|
+
return this.tryGetDefaultProjectForFile(fileNameOrScriptInfo) || this.doEnsureDefaultProjectForFile(fileNameOrScriptInfo);
|
|
175704
176198
|
};
|
|
175705
|
-
ProjectService.prototype.doEnsureDefaultProjectForFile = function (
|
|
176199
|
+
ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileNameOrScriptInfo) {
|
|
175706
176200
|
this.ensureProjectStructuresUptoDate();
|
|
175707
|
-
var scriptInfo = this.getScriptInfoForNormalizedPath(
|
|
175708
|
-
return scriptInfo ?
|
|
176201
|
+
var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
|
|
176202
|
+
return scriptInfo ?
|
|
176203
|
+
scriptInfo.getDefaultProject() :
|
|
176204
|
+
(this.logErrorForScriptInfoNotFound(ts.isString(fileNameOrScriptInfo) ? fileNameOrScriptInfo : fileNameOrScriptInfo.fileName), server.Errors.ThrowNoProject());
|
|
175709
176205
|
};
|
|
175710
176206
|
ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) {
|
|
175711
176207
|
this.ensureProjectStructuresUptoDate();
|
|
@@ -177877,7 +178373,7 @@ var ts;
|
|
|
177877
178373
|
if (this.serverMode !== ts.LanguageServiceMode.Semantic || !this.eventHandler || !scriptInfo.isJavaScript() || !ts.addToSeen(this.allJsFilesForOpenFileTelemetry, scriptInfo.path)) {
|
|
177878
178374
|
return;
|
|
177879
178375
|
}
|
|
177880
|
-
var project =
|
|
178376
|
+
var project = this.ensureDefaultProjectForFile(scriptInfo);
|
|
177881
178377
|
if (!project.languageServiceEnabled) {
|
|
177882
178378
|
return;
|
|
177883
178379
|
}
|
|
@@ -180477,6 +180973,10 @@ var ts;
|
|
|
180477
180973
|
this.projectService.logErrorForScriptInfoNotFound(args.file);
|
|
180478
180974
|
return server.Errors.ThrowNoProject();
|
|
180479
180975
|
}
|
|
180976
|
+
else if (!getScriptInfoEnsuringProjectsUptoDate) {
|
|
180977
|
+
// Ensure there are containing projects are present
|
|
180978
|
+
this.projectService.ensureDefaultProjectForFile(scriptInfo);
|
|
180979
|
+
}
|
|
180480
180980
|
projects = scriptInfo.containingProjects;
|
|
180481
180981
|
symLinkedProjects = this.projectService.getSymlinkedProjects(scriptInfo);
|
|
180482
180982
|
}
|
|
@@ -180545,6 +181045,7 @@ var ts;
|
|
|
180545
181045
|
var references = getReferencesWorker(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
|
|
180546
181046
|
if (!simplifiedResult)
|
|
180547
181047
|
return references;
|
|
181048
|
+
var preferences = this.getPreferences(file);
|
|
180548
181049
|
var defaultProject = this.getDefaultProject(args);
|
|
180549
181050
|
var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file);
|
|
180550
181051
|
var nameInfo = defaultProject.getLanguageService().getQuickInfoAtPosition(file, position);
|
|
@@ -180553,7 +181054,7 @@ var ts;
|
|
|
180553
181054
|
var symbolStartOffset = nameSpan ? scriptInfo.positionToLineOffset(nameSpan.start).offset : 0;
|
|
180554
181055
|
var symbolName = nameSpan ? scriptInfo.getSnapshot().getText(nameSpan.start, ts.textSpanEnd(nameSpan)) : "";
|
|
180555
181056
|
var refs = ts.flatMap(references, function (referencedSymbol) {
|
|
180556
|
-
return referencedSymbol.references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); });
|
|
181057
|
+
return referencedSymbol.references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry, preferences); });
|
|
180557
181058
|
});
|
|
180558
181059
|
return { refs: refs, symbolName: symbolName, symbolStartOffset: symbolStartOffset, symbolDisplayString: symbolDisplayString };
|
|
180559
181060
|
};
|
|
@@ -180561,6 +181062,7 @@ var ts;
|
|
|
180561
181062
|
var _this = this;
|
|
180562
181063
|
var projects = this.getProjects(args);
|
|
180563
181064
|
var fileName = args.file;
|
|
181065
|
+
var preferences = this.getPreferences(server.toNormalizedPath(fileName));
|
|
180564
181066
|
var references = [];
|
|
180565
181067
|
var seen = createDocumentSpanSet();
|
|
180566
181068
|
forEachProjectInProjects(projects, /*path*/ undefined, function (project) {
|
|
@@ -180579,7 +181081,7 @@ var ts;
|
|
|
180579
181081
|
});
|
|
180580
181082
|
if (!simplifiedResult)
|
|
180581
181083
|
return references;
|
|
180582
|
-
var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry); });
|
|
181084
|
+
var refs = references.map(function (entry) { return referenceEntryToReferencesResponseItem(_this.projectService, entry, preferences); });
|
|
180583
181085
|
return {
|
|
180584
181086
|
refs: refs,
|
|
180585
181087
|
symbolName: "\"".concat(args.file, "\"")
|
|
@@ -180603,13 +181105,7 @@ var ts;
|
|
|
180603
181105
|
return this.getFileAndProjectWorker(args.file, args.projectFileName);
|
|
180604
181106
|
};
|
|
180605
181107
|
Session.prototype.getFileAndLanguageServiceForSyntacticOperation = function (args) {
|
|
180606
|
-
|
|
180607
|
-
// throw if we dont get project
|
|
180608
|
-
var file = server.toNormalizedPath(args.file);
|
|
180609
|
-
var project = this.getProject(args.projectFileName) || this.projectService.ensureDefaultProjectForFile(file);
|
|
180610
|
-
if (!project) {
|
|
180611
|
-
return server.Errors.ThrowNoProject();
|
|
180612
|
-
}
|
|
181108
|
+
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
180613
181109
|
return {
|
|
180614
181110
|
file: file,
|
|
180615
181111
|
languageService: project.getLanguageService(/*ensureSynchronized*/ false)
|
|
@@ -181150,11 +181646,12 @@ var ts;
|
|
|
181150
181646
|
}
|
|
181151
181647
|
};
|
|
181152
181648
|
Session.prototype.organizeImports = function (args, simplifiedResult) {
|
|
181649
|
+
var _a;
|
|
181153
181650
|
ts.Debug.assert(args.scope.type === "file");
|
|
181154
|
-
var
|
|
181651
|
+
var _b = this.getFileAndProject(args.scope.args), file = _b.file, project = _b.project;
|
|
181155
181652
|
var changes = project.getLanguageService().organizeImports({
|
|
181156
181653
|
fileName: file,
|
|
181157
|
-
|
|
181654
|
+
mode: (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : undefined),
|
|
181158
181655
|
type: "file",
|
|
181159
181656
|
}, this.getFormatOptions(file), this.getPreferences(file));
|
|
181160
181657
|
if (simplifiedResult) {
|
|
@@ -181648,14 +182145,18 @@ var ts;
|
|
|
181648
182145
|
}
|
|
181649
182146
|
return text;
|
|
181650
182147
|
}
|
|
181651
|
-
function referenceEntryToReferencesResponseItem(projectService, _a) {
|
|
182148
|
+
function referenceEntryToReferencesResponseItem(projectService, _a, _b) {
|
|
181652
182149
|
var fileName = _a.fileName, textSpan = _a.textSpan, contextSpan = _a.contextSpan, isWriteAccess = _a.isWriteAccess, isDefinition = _a.isDefinition;
|
|
182150
|
+
var disableLineTextInReferences = _b.disableLineTextInReferences;
|
|
181653
182151
|
var scriptInfo = ts.Debug.checkDefined(projectService.getScriptInfo(fileName));
|
|
181654
182152
|
var span = toProtocolTextSpanWithContext(textSpan, contextSpan, scriptInfo);
|
|
181655
|
-
var
|
|
181656
|
-
var lineText = scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, "");
|
|
182153
|
+
var lineText = disableLineTextInReferences ? undefined : getLineText(scriptInfo, span);
|
|
181657
182154
|
return __assign(__assign({ file: fileName }, span), { lineText: lineText, isWriteAccess: isWriteAccess, isDefinition: isDefinition });
|
|
181658
182155
|
}
|
|
182156
|
+
function getLineText(scriptInfo, span) {
|
|
182157
|
+
var lineSpan = scriptInfo.lineToTextSpan(span.start.line - 1);
|
|
182158
|
+
return scriptInfo.getSnapshot().getText(lineSpan.start, ts.textSpanEnd(lineSpan)).replace(/\r|\n/g, "");
|
|
182159
|
+
}
|
|
181659
182160
|
function isCompletionEntryData(data) {
|
|
181660
182161
|
return data === undefined || data && typeof data === "object"
|
|
181661
182162
|
&& typeof data.exportName === "string"
|
|
@@ -185695,6 +186196,9 @@ var ts;
|
|
|
185695
186196
|
process.on("message", function (e) {
|
|
185696
186197
|
_this.onMessage(e);
|
|
185697
186198
|
});
|
|
186199
|
+
process.on("disconnect", function () {
|
|
186200
|
+
_this.exit();
|
|
186201
|
+
});
|
|
185698
186202
|
};
|
|
185699
186203
|
return IpcIOSession;
|
|
185700
186204
|
}(IOSession));
|