typescript 4.9.0-dev.20220928 → 4.9.0-dev.20220930
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/lib.es2015.symbol.wellknown.d.ts +3 -3
- package/lib/lib.es5.d.ts +2 -2
- package/lib/protocol.d.ts +7 -0
- package/lib/tsc.js +115 -56
- package/lib/tsserver.js +204 -76
- package/lib/tsserverlibrary.d.ts +14 -0
- package/lib/tsserverlibrary.js +204 -76
- package/lib/typescript.d.ts +7 -0
- package/lib/typescript.js +195 -74
- package/lib/typescriptServices.d.ts +7 -0
- package/lib/typescriptServices.js +195 -74
- package/lib/typingsInstaller.js +145 -57
- package/package.json +2 -2
package/lib/tsserverlibrary.js
CHANGED
|
@@ -108,7 +108,7 @@ var ts;
|
|
|
108
108
|
// The following is baselined as a literal template type without intervention
|
|
109
109
|
/** The version of the TypeScript compiler release */
|
|
110
110
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
111
|
-
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.
|
|
111
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220930");
|
|
112
112
|
/* @internal */
|
|
113
113
|
var Comparison;
|
|
114
114
|
(function (Comparison) {
|
|
@@ -3214,11 +3214,13 @@ var ts;
|
|
|
3214
3214
|
// > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers
|
|
3215
3215
|
// > MUST NOT include leading zeroes.
|
|
3216
3216
|
var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
|
|
3217
|
+
var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
|
|
3217
3218
|
// https://semver.org/#spec-item-10
|
|
3218
3219
|
// > Build metadata MAY be denoted by appending a plus sign and a series of dot separated
|
|
3219
3220
|
// > identifiers immediately following the patch or pre-release version. Identifiers MUST
|
|
3220
3221
|
// > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
|
|
3221
3222
|
var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
|
|
3223
|
+
var buildPartRegExp = /^[a-z0-9-]+$/i;
|
|
3222
3224
|
// https://semver.org/#spec-item-9
|
|
3223
3225
|
// > Numeric identifiers MUST NOT include leading zeroes.
|
|
3224
3226
|
var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
|
|
@@ -3238,13 +3240,15 @@ var ts;
|
|
|
3238
3240
|
ts.Debug.assert(major >= 0, "Invalid argument: major");
|
|
3239
3241
|
ts.Debug.assert(minor >= 0, "Invalid argument: minor");
|
|
3240
3242
|
ts.Debug.assert(patch >= 0, "Invalid argument: patch");
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
+
var prereleaseArray = prerelease ? ts.isArray(prerelease) ? prerelease : prerelease.split(".") : ts.emptyArray;
|
|
3244
|
+
var buildArray = build ? ts.isArray(build) ? build : build.split(".") : ts.emptyArray;
|
|
3245
|
+
ts.Debug.assert(ts.every(prereleaseArray, function (s) { return prereleasePartRegExp.test(s); }), "Invalid argument: prerelease");
|
|
3246
|
+
ts.Debug.assert(ts.every(buildArray, function (s) { return buildPartRegExp.test(s); }), "Invalid argument: build");
|
|
3243
3247
|
this.major = major;
|
|
3244
3248
|
this.minor = minor;
|
|
3245
3249
|
this.patch = patch;
|
|
3246
|
-
this.prerelease =
|
|
3247
|
-
this.build =
|
|
3250
|
+
this.prerelease = prereleaseArray;
|
|
3251
|
+
this.build = buildArray;
|
|
3248
3252
|
}
|
|
3249
3253
|
Version.tryParse = function (text) {
|
|
3250
3254
|
var result = tryParseComponents(text);
|
|
@@ -3283,6 +3287,10 @@ var ts;
|
|
|
3283
3287
|
default: return ts.Debug.assertNever(field);
|
|
3284
3288
|
}
|
|
3285
3289
|
};
|
|
3290
|
+
Version.prototype.with = function (fields) {
|
|
3291
|
+
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;
|
|
3292
|
+
return new Version(major, minor, patch, prerelease, build);
|
|
3293
|
+
};
|
|
3286
3294
|
Version.prototype.toString = function () {
|
|
3287
3295
|
var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
|
|
3288
3296
|
if (ts.some(this.prerelease))
|
|
@@ -3291,7 +3299,7 @@ var ts;
|
|
|
3291
3299
|
result += "+".concat(this.build.join("."));
|
|
3292
3300
|
return result;
|
|
3293
3301
|
};
|
|
3294
|
-
Version.zero = new Version(0, 0, 0);
|
|
3302
|
+
Version.zero = new Version(0, 0, 0, ["0"]);
|
|
3295
3303
|
return Version;
|
|
3296
3304
|
}());
|
|
3297
3305
|
ts.Version = Version;
|
|
@@ -3374,6 +3382,10 @@ var ts;
|
|
|
3374
3382
|
}
|
|
3375
3383
|
return undefined;
|
|
3376
3384
|
};
|
|
3385
|
+
/**
|
|
3386
|
+
* Tests whether a version matches the range. This is equivalent to `satisfies(version, range, { includePrerelease: true })`.
|
|
3387
|
+
* in `node-semver`.
|
|
3388
|
+
*/
|
|
3377
3389
|
VersionRange.prototype.test = function (version) {
|
|
3378
3390
|
if (typeof version === "string")
|
|
3379
3391
|
version = new Version(version);
|
|
@@ -3484,19 +3496,20 @@ var ts;
|
|
|
3484
3496
|
break;
|
|
3485
3497
|
case "<":
|
|
3486
3498
|
case ">=":
|
|
3487
|
-
comparators.push(createComparator(operator, version))
|
|
3499
|
+
comparators.push(isWildcard(minor) || isWildcard(patch) ? createComparator(operator, version.with({ prerelease: "0" })) :
|
|
3500
|
+
createComparator(operator, version));
|
|
3488
3501
|
break;
|
|
3489
3502
|
case "<=":
|
|
3490
3503
|
case ">":
|
|
3491
|
-
comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
|
|
3492
|
-
isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
|
|
3504
|
+
comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major").with({ prerelease: "0" })) :
|
|
3505
|
+
isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor").with({ prerelease: "0" })) :
|
|
3493
3506
|
createComparator(operator, version));
|
|
3494
3507
|
break;
|
|
3495
3508
|
case "=":
|
|
3496
3509
|
case undefined:
|
|
3497
3510
|
if (isWildcard(minor) || isWildcard(patch)) {
|
|
3498
|
-
comparators.push(createComparator(">=", version));
|
|
3499
|
-
comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
|
|
3511
|
+
comparators.push(createComparator(">=", version.with({ prerelease: "0" })));
|
|
3512
|
+
comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor").with({ prerelease: "0" })));
|
|
3500
3513
|
}
|
|
3501
3514
|
else {
|
|
3502
3515
|
comparators.push(createComparator("=", version));
|
|
@@ -49484,6 +49497,12 @@ var ts;
|
|
|
49484
49497
|
getOptionalType: function () { return optionalType; },
|
|
49485
49498
|
getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
|
|
49486
49499
|
getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
|
|
49500
|
+
getAsyncIterableType: function () {
|
|
49501
|
+
var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
|
|
49502
|
+
if (type === emptyGenericType)
|
|
49503
|
+
return undefined;
|
|
49504
|
+
return type;
|
|
49505
|
+
},
|
|
49487
49506
|
isSymbolAccessible: isSymbolAccessible,
|
|
49488
49507
|
isArrayType: isArrayType,
|
|
49489
49508
|
isTupleType: isTupleType,
|
|
@@ -50321,9 +50340,9 @@ var ts;
|
|
|
50321
50340
|
return symbol;
|
|
50322
50341
|
}
|
|
50323
50342
|
if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
50324
|
-
var
|
|
50325
|
-
//
|
|
50326
|
-
if (
|
|
50343
|
+
var targetFlags = getAllSymbolFlags(symbol);
|
|
50344
|
+
// `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
|
|
50345
|
+
if (targetFlags & meaning) {
|
|
50327
50346
|
return symbol;
|
|
50328
50347
|
}
|
|
50329
50348
|
}
|
|
@@ -50956,8 +50975,8 @@ var ts;
|
|
|
50956
50975
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
50957
50976
|
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
50958
50977
|
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
50978
|
+
!checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
|
|
50959
50979
|
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
|
|
50960
|
-
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
50961
50980
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
50962
50981
|
var suggestion = void 0;
|
|
50963
50982
|
var suggestedLib = void 0;
|
|
@@ -51044,7 +51063,7 @@ var ts;
|
|
|
51044
51063
|
}
|
|
51045
51064
|
}
|
|
51046
51065
|
if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
51047
|
-
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
|
|
51066
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
|
|
51048
51067
|
if (typeOnlyDeclaration) {
|
|
51049
51068
|
var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
|
|
51050
51069
|
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
@@ -51207,7 +51226,7 @@ var ts;
|
|
|
51207
51226
|
return false;
|
|
51208
51227
|
}
|
|
51209
51228
|
function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
|
|
51210
|
-
if (meaning &
|
|
51229
|
+
if (meaning & 111551 /* SymbolFlags.Value */) {
|
|
51211
51230
|
if (isPrimitiveTypeName(name)) {
|
|
51212
51231
|
if (isExtendedByInterface(errorLocation)) {
|
|
51213
51232
|
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));
|
|
@@ -51218,7 +51237,8 @@ var ts;
|
|
|
51218
51237
|
return true;
|
|
51219
51238
|
}
|
|
51220
51239
|
var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51221
|
-
|
|
51240
|
+
var allFlags = symbol && getAllSymbolFlags(symbol);
|
|
51241
|
+
if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
|
|
51222
51242
|
var rawName = ts.unescapeLeadingUnderscores(name);
|
|
51223
51243
|
if (isES2015OrLaterConstructorName(name)) {
|
|
51224
51244
|
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);
|
|
@@ -51266,16 +51286,16 @@ var ts;
|
|
|
51266
51286
|
}
|
|
51267
51287
|
return false;
|
|
51268
51288
|
}
|
|
51269
|
-
function
|
|
51270
|
-
if (meaning & (111551 /* SymbolFlags.Value */ & ~
|
|
51271
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule
|
|
51289
|
+
function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
|
|
51290
|
+
if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
|
|
51291
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51272
51292
|
if (symbol) {
|
|
51273
51293
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
|
|
51274
51294
|
return true;
|
|
51275
51295
|
}
|
|
51276
51296
|
}
|
|
51277
|
-
else if (meaning & (788968 /* SymbolFlags.Type */ & ~
|
|
51278
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name,
|
|
51297
|
+
else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
|
|
51298
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51279
51299
|
if (symbol) {
|
|
51280
51300
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
|
|
51281
51301
|
return true;
|
|
@@ -51865,6 +51885,52 @@ var ts;
|
|
|
51865
51885
|
}
|
|
51866
51886
|
return undefined;
|
|
51867
51887
|
}
|
|
51888
|
+
/**
|
|
51889
|
+
* Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
|
|
51890
|
+
* is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
|
|
51891
|
+
* with another exported symbol, e.g.
|
|
51892
|
+
* ```ts
|
|
51893
|
+
* // a.ts
|
|
51894
|
+
* export const a = 0;
|
|
51895
|
+
* // b.ts
|
|
51896
|
+
* export { a } from "./a";
|
|
51897
|
+
* export type a = number;
|
|
51898
|
+
* // c.ts
|
|
51899
|
+
* import { a } from "./b";
|
|
51900
|
+
* ```
|
|
51901
|
+
* Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
|
|
51902
|
+
* from b.ts, even though there is still more alias to resolve. Consequently, if we were
|
|
51903
|
+
* trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
|
|
51904
|
+
* the local symbol and on the symbol returned by `resolveAlias` is not enough.
|
|
51905
|
+
* @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
|
|
51906
|
+
* combined flags of all alias targets otherwise.
|
|
51907
|
+
*/
|
|
51908
|
+
function getAllSymbolFlags(symbol) {
|
|
51909
|
+
var flags = symbol.flags;
|
|
51910
|
+
var seenSymbols;
|
|
51911
|
+
while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51912
|
+
var target = resolveAlias(symbol);
|
|
51913
|
+
if (target === unknownSymbol) {
|
|
51914
|
+
return 67108863 /* SymbolFlags.All */;
|
|
51915
|
+
}
|
|
51916
|
+
// Optimizations - try to avoid creating or adding to
|
|
51917
|
+
// `seenSymbols` if possible
|
|
51918
|
+
if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
|
|
51919
|
+
break;
|
|
51920
|
+
}
|
|
51921
|
+
if (target.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51922
|
+
if (seenSymbols) {
|
|
51923
|
+
seenSymbols.add(target);
|
|
51924
|
+
}
|
|
51925
|
+
else {
|
|
51926
|
+
seenSymbols = new ts.Set([symbol, target]);
|
|
51927
|
+
}
|
|
51928
|
+
}
|
|
51929
|
+
flags |= target.flags;
|
|
51930
|
+
symbol = target;
|
|
51931
|
+
}
|
|
51932
|
+
return flags;
|
|
51933
|
+
}
|
|
51868
51934
|
/**
|
|
51869
51935
|
* Marks a symbol as type-only if its declaration is syntactically type-only.
|
|
51870
51936
|
* If it is not itself marked type-only, but resolves to a type-only alias
|
|
@@ -51910,19 +51976,25 @@ var ts;
|
|
|
51910
51976
|
return !!aliasDeclarationLinks.typeOnlyDeclaration;
|
|
51911
51977
|
}
|
|
51912
51978
|
/** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
|
|
51913
|
-
function getTypeOnlyAliasDeclaration(symbol) {
|
|
51979
|
+
function getTypeOnlyAliasDeclaration(symbol, include) {
|
|
51914
51980
|
if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
|
|
51915
51981
|
return undefined;
|
|
51916
51982
|
}
|
|
51917
51983
|
var links = getSymbolLinks(symbol);
|
|
51918
|
-
|
|
51984
|
+
if (include === undefined) {
|
|
51985
|
+
return links.typeOnlyDeclaration || undefined;
|
|
51986
|
+
}
|
|
51987
|
+
if (links.typeOnlyDeclaration) {
|
|
51988
|
+
return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
|
|
51989
|
+
}
|
|
51990
|
+
return undefined;
|
|
51919
51991
|
}
|
|
51920
51992
|
function markExportAsReferenced(node) {
|
|
51921
51993
|
var symbol = getSymbolOfNode(node);
|
|
51922
51994
|
var target = resolveAlias(symbol);
|
|
51923
51995
|
if (target) {
|
|
51924
51996
|
var markAlias = target === unknownSymbol ||
|
|
51925
|
-
((target
|
|
51997
|
+
((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
|
|
51926
51998
|
if (markAlias) {
|
|
51927
51999
|
markAliasSymbolAsReferenced(symbol);
|
|
51928
52000
|
}
|
|
@@ -51942,8 +52014,7 @@ var ts;
|
|
|
51942
52014
|
// This way a chain of imports can be elided if ultimately the final input is only used in a type
|
|
51943
52015
|
// position.
|
|
51944
52016
|
if (ts.isInternalModuleImportEqualsDeclaration(node)) {
|
|
51945
|
-
|
|
51946
|
-
if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
|
|
52017
|
+
if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
|
|
51947
52018
|
// import foo = <symbol>
|
|
51948
52019
|
checkExpressionCached(node.moduleReference);
|
|
51949
52020
|
}
|
|
@@ -52765,7 +52836,7 @@ var ts;
|
|
|
52765
52836
|
}
|
|
52766
52837
|
function symbolIsValue(symbol, includeTypeOnlyMembers) {
|
|
52767
52838
|
return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
|
|
52768
|
-
symbol.flags & 2097152 /* SymbolFlags.Alias */ &&
|
|
52839
|
+
symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
|
|
52769
52840
|
}
|
|
52770
52841
|
function findConstructorDeclaration(node) {
|
|
52771
52842
|
var members = node.members;
|
|
@@ -53034,8 +53105,10 @@ var ts;
|
|
|
53034
53105
|
return true;
|
|
53035
53106
|
}
|
|
53036
53107
|
// Qualify if the symbol from symbol table has same meaning as expected
|
|
53037
|
-
|
|
53038
|
-
|
|
53108
|
+
var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
|
|
53109
|
+
symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
|
|
53110
|
+
var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
|
|
53111
|
+
if (flags & meaning) {
|
|
53039
53112
|
qualify = true;
|
|
53040
53113
|
return true;
|
|
53041
53114
|
}
|
|
@@ -55692,7 +55765,7 @@ var ts;
|
|
|
55692
55765
|
return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
|
|
55693
55766
|
}
|
|
55694
55767
|
function isTypeOnlyNamespace(symbol) {
|
|
55695
|
-
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m)
|
|
55768
|
+
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
|
|
55696
55769
|
}
|
|
55697
55770
|
function serializeModule(symbol, symbolName, modifierFlags) {
|
|
55698
55771
|
var members = getNamespaceMembersForSerialization(symbol);
|
|
@@ -57912,7 +57985,7 @@ var ts;
|
|
|
57912
57985
|
links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
|
|
57913
57986
|
: isDuplicatedCommonJSExport(symbol.declarations) ? autoType
|
|
57914
57987
|
: declaredType ? declaredType
|
|
57915
|
-
: targetSymbol
|
|
57988
|
+
: getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
|
|
57916
57989
|
: errorType;
|
|
57917
57990
|
}
|
|
57918
57991
|
return links.type;
|
|
@@ -60265,7 +60338,7 @@ var ts;
|
|
|
60265
60338
|
var indexTypes;
|
|
60266
60339
|
var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
|
|
60267
60340
|
// Flags we want to propagate to the result if they exist in all source symbols
|
|
60268
|
-
var optionalFlag
|
|
60341
|
+
var optionalFlag;
|
|
60269
60342
|
var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
|
|
60270
60343
|
var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
|
|
60271
60344
|
var mergedInstantiations = false;
|
|
@@ -60276,11 +60349,14 @@ var ts;
|
|
|
60276
60349
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
60277
60350
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
60278
60351
|
if (prop) {
|
|
60279
|
-
if (
|
|
60280
|
-
optionalFlag
|
|
60281
|
-
|
|
60282
|
-
|
|
60283
|
-
|
|
60352
|
+
if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
|
|
60353
|
+
optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
|
|
60354
|
+
if (isUnion) {
|
|
60355
|
+
optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
|
|
60356
|
+
}
|
|
60357
|
+
else {
|
|
60358
|
+
optionalFlag &= prop.flags;
|
|
60359
|
+
}
|
|
60284
60360
|
}
|
|
60285
60361
|
if (!singleProp) {
|
|
60286
60362
|
singleProp = prop;
|
|
@@ -60399,7 +60475,7 @@ var ts;
|
|
|
60399
60475
|
propTypes.push(type);
|
|
60400
60476
|
}
|
|
60401
60477
|
ts.addRange(propTypes, indexTypes);
|
|
60402
|
-
var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
|
|
60478
|
+
var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
|
|
60403
60479
|
result.containingType = containingType;
|
|
60404
60480
|
if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
|
|
60405
60481
|
result.valueDeclaration = firstValueDeclaration;
|
|
@@ -67010,7 +67086,7 @@ var ts;
|
|
|
67010
67086
|
// with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
|
|
67011
67087
|
var constraint = getConstraintOfTypeParameter(source);
|
|
67012
67088
|
if (constraint && hasNonCircularBaseConstraint(source)) {
|
|
67013
|
-
while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
|
|
67089
|
+
while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
|
|
67014
67090
|
if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
|
|
67015
67091
|
return result;
|
|
67016
67092
|
}
|
|
@@ -67666,7 +67742,7 @@ var ts;
|
|
|
67666
67742
|
return 0 /* Ternary.False */;
|
|
67667
67743
|
}
|
|
67668
67744
|
// When checking for comparability, be more lenient with optional properties.
|
|
67669
|
-
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67745
|
+
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67670
67746
|
// TypeScript 1.0 spec (April 2014): 3.8.3
|
|
67671
67747
|
// S is a subtype of a type T, and T is a supertype of S if ...
|
|
67672
67748
|
// S' and T are object types and, for each member M in T..
|
|
@@ -72938,9 +73014,9 @@ var ts;
|
|
|
72938
73014
|
});
|
|
72939
73015
|
}
|
|
72940
73016
|
function markAliasReferenced(symbol, location) {
|
|
72941
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
73017
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
72942
73018
|
var target = resolveAlias(symbol);
|
|
72943
|
-
if (target
|
|
73019
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
72944
73020
|
// An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
|
|
72945
73021
|
// (because the const enum value will not be inlined), or if (2) the alias is an export
|
|
72946
73022
|
// of a const enum declaration that will be preserved.
|
|
@@ -78832,7 +78908,7 @@ var ts;
|
|
|
78832
78908
|
if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
78833
78909
|
symbol = resolveAlias(symbol);
|
|
78834
78910
|
}
|
|
78835
|
-
return !!(symbol && (symbol
|
|
78911
|
+
return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
|
|
78836
78912
|
}
|
|
78837
78913
|
return false;
|
|
78838
78914
|
}
|
|
@@ -85007,7 +85083,16 @@ var ts;
|
|
|
85007
85083
|
var message = allowAsyncIterables
|
|
85008
85084
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
85009
85085
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
85010
|
-
|
|
85086
|
+
var suggestAwait =
|
|
85087
|
+
// for (const x of Promise<...>) or [...Promise<...>]
|
|
85088
|
+
!!getAwaitedTypeOfPromise(type)
|
|
85089
|
+
// for (const x of AsyncIterable<...>)
|
|
85090
|
+
|| (!allowAsyncIterables &&
|
|
85091
|
+
ts.isForOfStatement(errorNode.parent) &&
|
|
85092
|
+
errorNode.parent.expression === errorNode &&
|
|
85093
|
+
getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
|
|
85094
|
+
isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
|
|
85095
|
+
return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
|
|
85011
85096
|
}
|
|
85012
85097
|
/**
|
|
85013
85098
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -86858,10 +86943,11 @@ var ts;
|
|
|
86858
86943
|
}
|
|
86859
86944
|
return;
|
|
86860
86945
|
}
|
|
86946
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
86861
86947
|
var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
|
|
86862
86948
|
(symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
|
|
86863
86949
|
(symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
|
|
86864
|
-
if (
|
|
86950
|
+
if (targetFlags & excludedMeanings) {
|
|
86865
86951
|
var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
|
|
86866
86952
|
ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
|
|
86867
86953
|
ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
|
@@ -86871,7 +86957,7 @@ var ts;
|
|
|
86871
86957
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
86872
86958
|
&& !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
|
|
86873
86959
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
86874
|
-
var isType = !(
|
|
86960
|
+
var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
|
|
86875
86961
|
if (isType || typeOnlyAlias) {
|
|
86876
86962
|
switch (node.kind) {
|
|
86877
86963
|
case 270 /* SyntaxKind.ImportClause */:
|
|
@@ -87031,14 +87117,15 @@ var ts;
|
|
|
87031
87117
|
if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
|
|
87032
87118
|
var target = resolveAlias(getSymbolOfNode(node));
|
|
87033
87119
|
if (target !== unknownSymbol) {
|
|
87034
|
-
|
|
87120
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
87121
|
+
if (targetFlags & 111551 /* SymbolFlags.Value */) {
|
|
87035
87122
|
// Target is a value symbol, check that it is not hidden by a local declaration with the same name
|
|
87036
87123
|
var moduleName = ts.getFirstIdentifier(node.moduleReference);
|
|
87037
87124
|
if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
|
|
87038
87125
|
error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
|
|
87039
87126
|
}
|
|
87040
87127
|
}
|
|
87041
|
-
if (
|
|
87128
|
+
if (targetFlags & 788968 /* SymbolFlags.Type */) {
|
|
87042
87129
|
checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
|
|
87043
87130
|
}
|
|
87044
87131
|
}
|
|
@@ -87177,7 +87264,7 @@ var ts;
|
|
|
87177
87264
|
markExportAsReferenced(node);
|
|
87178
87265
|
}
|
|
87179
87266
|
var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
|
|
87180
|
-
if (!target || target
|
|
87267
|
+
if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87181
87268
|
checkExpressionCached(node.propertyName || node.name);
|
|
87182
87269
|
}
|
|
87183
87270
|
}
|
|
@@ -87224,7 +87311,7 @@ var ts;
|
|
|
87224
87311
|
markAliasReferenced(sym, id);
|
|
87225
87312
|
// If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
|
|
87226
87313
|
var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
|
|
87227
|
-
if (target
|
|
87314
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87228
87315
|
// However if it is a value, we need to check it's being used correctly
|
|
87229
87316
|
checkExpressionCached(node.expression);
|
|
87230
87317
|
}
|
|
@@ -88546,7 +88633,7 @@ var ts;
|
|
|
88546
88633
|
return symbolLinks.exportsSomeValue;
|
|
88547
88634
|
function isValue(s) {
|
|
88548
88635
|
s = resolveSymbol(s);
|
|
88549
|
-
return s && !!(s
|
|
88636
|
+
return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
|
|
88550
88637
|
}
|
|
88551
88638
|
}
|
|
88552
88639
|
function isNameOfModuleOrEnumDeclaration(node) {
|
|
@@ -88599,7 +88686,7 @@ var ts;
|
|
|
88599
88686
|
var symbol = getReferencedValueOrAliasSymbol(node);
|
|
88600
88687
|
// We should only get the declaration of an alias if there isn't a local value
|
|
88601
88688
|
// declaration for the symbol
|
|
88602
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
88689
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
88603
88690
|
return getDeclarationOfAliasSymbol(symbol);
|
|
88604
88691
|
}
|
|
88605
88692
|
}
|
|
@@ -88687,7 +88774,7 @@ var ts;
|
|
|
88687
88774
|
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88688
88775
|
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88689
88776
|
var symbol = getSymbolOfNode(node);
|
|
88690
|
-
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
|
|
88777
|
+
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
|
|
88691
88778
|
case 275 /* SyntaxKind.ExportDeclaration */:
|
|
88692
88779
|
var exportClause = node.exportClause;
|
|
88693
88780
|
return !!exportClause && (ts.isNamespaceExport(exportClause) ||
|
|
@@ -88709,6 +88796,7 @@ var ts;
|
|
|
88709
88796
|
return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
|
|
88710
88797
|
}
|
|
88711
88798
|
function isAliasResolvedToValue(symbol) {
|
|
88799
|
+
var _a;
|
|
88712
88800
|
if (!symbol) {
|
|
88713
88801
|
return false;
|
|
88714
88802
|
}
|
|
@@ -88718,7 +88806,7 @@ var ts;
|
|
|
88718
88806
|
}
|
|
88719
88807
|
// const enums and modules that contain only const enums are not considered values from the emit perspective
|
|
88720
88808
|
// unless 'preserveConstEnums' option is set to true
|
|
88721
|
-
return !!(target
|
|
88809
|
+
return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
|
|
88722
88810
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
|
|
88723
88811
|
}
|
|
88724
88812
|
function isConstEnumOrConstEnumOnlyModule(s) {
|
|
@@ -88733,7 +88821,7 @@ var ts;
|
|
|
88733
88821
|
}
|
|
88734
88822
|
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
88735
88823
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
|
|
88736
|
-
target
|
|
88824
|
+
getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
|
|
88737
88825
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
88738
88826
|
// An `export import ... =` of a value symbol is always considered referenced
|
|
88739
88827
|
return true;
|
|
@@ -129189,6 +129277,12 @@ var ts;
|
|
|
129189
129277
|
SemanticClassificationFormat["Original"] = "original";
|
|
129190
129278
|
SemanticClassificationFormat["TwentyTwenty"] = "2020";
|
|
129191
129279
|
})(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
|
|
129280
|
+
var OrganizeImportsMode;
|
|
129281
|
+
(function (OrganizeImportsMode) {
|
|
129282
|
+
OrganizeImportsMode["All"] = "All";
|
|
129283
|
+
OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
|
|
129284
|
+
OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
|
|
129285
|
+
})(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
|
|
129192
129286
|
var CompletionTriggerKind;
|
|
129193
129287
|
(function (CompletionTriggerKind) {
|
|
129194
129288
|
/** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
|
|
@@ -144944,23 +145038,39 @@ var ts;
|
|
|
144944
145038
|
* 2) Coalescing imports from the same module
|
|
144945
145039
|
* 3) Sorting imports
|
|
144946
145040
|
*/
|
|
144947
|
-
function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
145041
|
+
function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
|
|
144948
145042
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
144949
|
-
var
|
|
145043
|
+
var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
145044
|
+
var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
|
|
145045
|
+
var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
145046
|
+
var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
|
|
145047
|
+
var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
|
|
145048
|
+
var processImportsOfSameModuleSpecifier = function (importGroup) {
|
|
145049
|
+
var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
|
|
145050
|
+
return shouldSort
|
|
145051
|
+
? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
|
|
145052
|
+
: processedDeclarations;
|
|
145053
|
+
};
|
|
144950
145054
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
144951
145055
|
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
144952
|
-
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144953
|
-
//
|
|
144954
|
-
|
|
144955
|
-
|
|
145056
|
+
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
145057
|
+
// Exports are always used
|
|
145058
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
145059
|
+
// All of the old ExportDeclarations in the file, in syntactic order.
|
|
145060
|
+
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
|
|
145061
|
+
organizeImportsWorker(topLevelExportDecls, coalesceExports);
|
|
145062
|
+
}
|
|
144956
145063
|
for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
|
|
144957
145064
|
var ambientModule = _a[_i];
|
|
144958
145065
|
if (!ambientModule.body)
|
|
144959
145066
|
continue;
|
|
144960
145067
|
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
144961
|
-
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144962
|
-
|
|
144963
|
-
|
|
145068
|
+
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
145069
|
+
// Exports are always used
|
|
145070
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
145071
|
+
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
|
|
145072
|
+
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
|
|
145073
|
+
}
|
|
144964
145074
|
}
|
|
144965
145075
|
return changeTracker.getChanges();
|
|
144966
145076
|
function organizeImportsWorker(oldImportDecls, coalesce) {
|
|
@@ -144973,8 +145083,12 @@ var ts;
|
|
|
144973
145083
|
// Consider: we could do a more careful check that this trivia is actually a header,
|
|
144974
145084
|
// but the consequences of being wrong are very minor.
|
|
144975
145085
|
ts.suppressLeadingTrivia(oldImportDecls[0]);
|
|
144976
|
-
var oldImportGroups =
|
|
144977
|
-
|
|
145086
|
+
var oldImportGroups = shouldCombine
|
|
145087
|
+
? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
|
|
145088
|
+
: [oldImportDecls];
|
|
145089
|
+
var sortedImportGroups = shouldSort
|
|
145090
|
+
? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
|
|
145091
|
+
: oldImportGroups;
|
|
144978
145092
|
var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
|
|
144979
145093
|
return getExternalModuleName(importGroup[0].moduleSpecifier)
|
|
144980
145094
|
? coalesce(importGroup)
|
|
@@ -145038,11 +145152,7 @@ var ts;
|
|
|
145038
145152
|
}
|
|
145039
145153
|
return false;
|
|
145040
145154
|
}
|
|
145041
|
-
function removeUnusedImports(oldImports, sourceFile, program
|
|
145042
|
-
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
145043
|
-
if (skipDestructiveCodeActions) {
|
|
145044
|
-
return oldImports;
|
|
145045
|
-
}
|
|
145155
|
+
function removeUnusedImports(oldImports, sourceFile, program) {
|
|
145046
145156
|
var typeChecker = program.getTypeChecker();
|
|
145047
145157
|
var compilerOptions = program.getCompilerOptions();
|
|
145048
145158
|
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
|
@@ -154075,6 +154185,15 @@ var ts;
|
|
|
154075
154185
|
});
|
|
154076
154186
|
}
|
|
154077
154187
|
function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
|
|
154188
|
+
if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
|
|
154189
|
+
var exprType = checker.getTypeAtLocation(insertionSite);
|
|
154190
|
+
var asyncIter = checker.getAsyncIterableType();
|
|
154191
|
+
if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
|
|
154192
|
+
var forOf = insertionSite.parent;
|
|
154193
|
+
changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
|
|
154194
|
+
return;
|
|
154195
|
+
}
|
|
154196
|
+
}
|
|
154078
154197
|
if (ts.isBinaryExpression(insertionSite)) {
|
|
154079
154198
|
for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
|
|
154080
154199
|
var side = _a[_i];
|
|
@@ -169430,12 +169549,14 @@ var ts;
|
|
|
169430
169549
|
return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
|
|
169431
169550
|
}
|
|
169432
169551
|
function organizeImports(args, formatOptions, preferences) {
|
|
169552
|
+
var _a;
|
|
169433
169553
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
169434
169554
|
synchronizeHostData();
|
|
169435
169555
|
ts.Debug.assert(args.type === "file");
|
|
169436
169556
|
var sourceFile = getValidSourceFile(args.fileName);
|
|
169437
169557
|
var formatContext = ts.formatting.getFormatContext(formatOptions, host);
|
|
169438
|
-
|
|
169558
|
+
var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
|
|
169559
|
+
return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
|
|
169439
169560
|
}
|
|
169440
169561
|
function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
|
|
169441
169562
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
@@ -172015,6 +172136,12 @@ var ts;
|
|
|
172015
172136
|
CommandTypes["ProvideInlayHints"] = "provideInlayHints";
|
|
172016
172137
|
// NOTE: If updating this, be sure to also update `allCommandNames` in `testRunner/unittests/tsserver/session.ts`.
|
|
172017
172138
|
})(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {}));
|
|
172139
|
+
var OrganizeImportsMode;
|
|
172140
|
+
(function (OrganizeImportsMode) {
|
|
172141
|
+
OrganizeImportsMode["All"] = "All";
|
|
172142
|
+
OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
|
|
172143
|
+
OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
|
|
172144
|
+
})(OrganizeImportsMode = protocol.OrganizeImportsMode || (protocol.OrganizeImportsMode = {}));
|
|
172018
172145
|
var WatchFileKind;
|
|
172019
172146
|
(function (WatchFileKind) {
|
|
172020
172147
|
WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval";
|
|
@@ -181178,11 +181305,12 @@ var ts;
|
|
|
181178
181305
|
}
|
|
181179
181306
|
};
|
|
181180
181307
|
Session.prototype.organizeImports = function (args, simplifiedResult) {
|
|
181308
|
+
var _a;
|
|
181181
181309
|
ts.Debug.assert(args.scope.type === "file");
|
|
181182
|
-
var
|
|
181310
|
+
var _b = this.getFileAndProject(args.scope.args), file = _b.file, project = _b.project;
|
|
181183
181311
|
var changes = project.getLanguageService().organizeImports({
|
|
181184
181312
|
fileName: file,
|
|
181185
|
-
|
|
181313
|
+
mode: (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : undefined),
|
|
181186
181314
|
type: "file",
|
|
181187
181315
|
}, this.getFormatOptions(file), this.getPreferences(file));
|
|
181188
181316
|
if (simplifiedResult) {
|