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/tsserver.js
CHANGED
|
@@ -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, ".0-dev.
|
|
112
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-dev.20220930");
|
|
113
113
|
/* @internal */
|
|
114
114
|
var Comparison;
|
|
115
115
|
(function (Comparison) {
|
|
@@ -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));
|
|
@@ -49485,6 +49498,12 @@ var ts;
|
|
|
49485
49498
|
getOptionalType: function () { return optionalType; },
|
|
49486
49499
|
getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
|
|
49487
49500
|
getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
|
|
49501
|
+
getAsyncIterableType: function () {
|
|
49502
|
+
var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
|
|
49503
|
+
if (type === emptyGenericType)
|
|
49504
|
+
return undefined;
|
|
49505
|
+
return type;
|
|
49506
|
+
},
|
|
49488
49507
|
isSymbolAccessible: isSymbolAccessible,
|
|
49489
49508
|
isArrayType: isArrayType,
|
|
49490
49509
|
isTupleType: isTupleType,
|
|
@@ -50322,9 +50341,9 @@ var ts;
|
|
|
50322
50341
|
return symbol;
|
|
50323
50342
|
}
|
|
50324
50343
|
if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
50325
|
-
var
|
|
50326
|
-
//
|
|
50327
|
-
if (
|
|
50344
|
+
var targetFlags = getAllSymbolFlags(symbol);
|
|
50345
|
+
// `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
|
|
50346
|
+
if (targetFlags & meaning) {
|
|
50328
50347
|
return symbol;
|
|
50329
50348
|
}
|
|
50330
50349
|
}
|
|
@@ -50957,8 +50976,8 @@ var ts;
|
|
|
50957
50976
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
50958
50977
|
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
50959
50978
|
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
50979
|
+
!checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
|
|
50960
50980
|
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
|
|
50961
|
-
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
50962
50981
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
50963
50982
|
var suggestion = void 0;
|
|
50964
50983
|
var suggestedLib = void 0;
|
|
@@ -51045,7 +51064,7 @@ var ts;
|
|
|
51045
51064
|
}
|
|
51046
51065
|
}
|
|
51047
51066
|
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);
|
|
51067
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
|
|
51049
51068
|
if (typeOnlyDeclaration) {
|
|
51050
51069
|
var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
|
|
51051
51070
|
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
@@ -51208,7 +51227,7 @@ var ts;
|
|
|
51208
51227
|
return false;
|
|
51209
51228
|
}
|
|
51210
51229
|
function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
|
|
51211
|
-
if (meaning &
|
|
51230
|
+
if (meaning & 111551 /* SymbolFlags.Value */) {
|
|
51212
51231
|
if (isPrimitiveTypeName(name)) {
|
|
51213
51232
|
if (isExtendedByInterface(errorLocation)) {
|
|
51214
51233
|
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 +51238,8 @@ var ts;
|
|
|
51219
51238
|
return true;
|
|
51220
51239
|
}
|
|
51221
51240
|
var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51222
|
-
|
|
51241
|
+
var allFlags = symbol && getAllSymbolFlags(symbol);
|
|
51242
|
+
if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
|
|
51223
51243
|
var rawName = ts.unescapeLeadingUnderscores(name);
|
|
51224
51244
|
if (isES2015OrLaterConstructorName(name)) {
|
|
51225
51245
|
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 +51287,16 @@ var ts;
|
|
|
51267
51287
|
}
|
|
51268
51288
|
return false;
|
|
51269
51289
|
}
|
|
51270
|
-
function
|
|
51271
|
-
if (meaning & (111551 /* SymbolFlags.Value */ & ~
|
|
51272
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule
|
|
51290
|
+
function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
|
|
51291
|
+
if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
|
|
51292
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51273
51293
|
if (symbol) {
|
|
51274
51294
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
|
|
51275
51295
|
return true;
|
|
51276
51296
|
}
|
|
51277
51297
|
}
|
|
51278
|
-
else if (meaning & (788968 /* SymbolFlags.Type */ & ~
|
|
51279
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name,
|
|
51298
|
+
else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
|
|
51299
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51280
51300
|
if (symbol) {
|
|
51281
51301
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
|
|
51282
51302
|
return true;
|
|
@@ -51866,6 +51886,52 @@ var ts;
|
|
|
51866
51886
|
}
|
|
51867
51887
|
return undefined;
|
|
51868
51888
|
}
|
|
51889
|
+
/**
|
|
51890
|
+
* Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
|
|
51891
|
+
* is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
|
|
51892
|
+
* with another exported symbol, e.g.
|
|
51893
|
+
* ```ts
|
|
51894
|
+
* // a.ts
|
|
51895
|
+
* export const a = 0;
|
|
51896
|
+
* // b.ts
|
|
51897
|
+
* export { a } from "./a";
|
|
51898
|
+
* export type a = number;
|
|
51899
|
+
* // c.ts
|
|
51900
|
+
* import { a } from "./b";
|
|
51901
|
+
* ```
|
|
51902
|
+
* Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
|
|
51903
|
+
* from b.ts, even though there is still more alias to resolve. Consequently, if we were
|
|
51904
|
+
* trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
|
|
51905
|
+
* the local symbol and on the symbol returned by `resolveAlias` is not enough.
|
|
51906
|
+
* @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
|
|
51907
|
+
* combined flags of all alias targets otherwise.
|
|
51908
|
+
*/
|
|
51909
|
+
function getAllSymbolFlags(symbol) {
|
|
51910
|
+
var flags = symbol.flags;
|
|
51911
|
+
var seenSymbols;
|
|
51912
|
+
while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51913
|
+
var target = resolveAlias(symbol);
|
|
51914
|
+
if (target === unknownSymbol) {
|
|
51915
|
+
return 67108863 /* SymbolFlags.All */;
|
|
51916
|
+
}
|
|
51917
|
+
// Optimizations - try to avoid creating or adding to
|
|
51918
|
+
// `seenSymbols` if possible
|
|
51919
|
+
if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
|
|
51920
|
+
break;
|
|
51921
|
+
}
|
|
51922
|
+
if (target.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51923
|
+
if (seenSymbols) {
|
|
51924
|
+
seenSymbols.add(target);
|
|
51925
|
+
}
|
|
51926
|
+
else {
|
|
51927
|
+
seenSymbols = new ts.Set([symbol, target]);
|
|
51928
|
+
}
|
|
51929
|
+
}
|
|
51930
|
+
flags |= target.flags;
|
|
51931
|
+
symbol = target;
|
|
51932
|
+
}
|
|
51933
|
+
return flags;
|
|
51934
|
+
}
|
|
51869
51935
|
/**
|
|
51870
51936
|
* Marks a symbol as type-only if its declaration is syntactically type-only.
|
|
51871
51937
|
* If it is not itself marked type-only, but resolves to a type-only alias
|
|
@@ -51911,19 +51977,25 @@ var ts;
|
|
|
51911
51977
|
return !!aliasDeclarationLinks.typeOnlyDeclaration;
|
|
51912
51978
|
}
|
|
51913
51979
|
/** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
|
|
51914
|
-
function getTypeOnlyAliasDeclaration(symbol) {
|
|
51980
|
+
function getTypeOnlyAliasDeclaration(symbol, include) {
|
|
51915
51981
|
if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
|
|
51916
51982
|
return undefined;
|
|
51917
51983
|
}
|
|
51918
51984
|
var links = getSymbolLinks(symbol);
|
|
51919
|
-
|
|
51985
|
+
if (include === undefined) {
|
|
51986
|
+
return links.typeOnlyDeclaration || undefined;
|
|
51987
|
+
}
|
|
51988
|
+
if (links.typeOnlyDeclaration) {
|
|
51989
|
+
return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
|
|
51990
|
+
}
|
|
51991
|
+
return undefined;
|
|
51920
51992
|
}
|
|
51921
51993
|
function markExportAsReferenced(node) {
|
|
51922
51994
|
var symbol = getSymbolOfNode(node);
|
|
51923
51995
|
var target = resolveAlias(symbol);
|
|
51924
51996
|
if (target) {
|
|
51925
51997
|
var markAlias = target === unknownSymbol ||
|
|
51926
|
-
((target
|
|
51998
|
+
((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
|
|
51927
51999
|
if (markAlias) {
|
|
51928
52000
|
markAliasSymbolAsReferenced(symbol);
|
|
51929
52001
|
}
|
|
@@ -51943,8 +52015,7 @@ var ts;
|
|
|
51943
52015
|
// This way a chain of imports can be elided if ultimately the final input is only used in a type
|
|
51944
52016
|
// position.
|
|
51945
52017
|
if (ts.isInternalModuleImportEqualsDeclaration(node)) {
|
|
51946
|
-
|
|
51947
|
-
if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
|
|
52018
|
+
if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
|
|
51948
52019
|
// import foo = <symbol>
|
|
51949
52020
|
checkExpressionCached(node.moduleReference);
|
|
51950
52021
|
}
|
|
@@ -52766,7 +52837,7 @@ var ts;
|
|
|
52766
52837
|
}
|
|
52767
52838
|
function symbolIsValue(symbol, includeTypeOnlyMembers) {
|
|
52768
52839
|
return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
|
|
52769
|
-
symbol.flags & 2097152 /* SymbolFlags.Alias */ &&
|
|
52840
|
+
symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
|
|
52770
52841
|
}
|
|
52771
52842
|
function findConstructorDeclaration(node) {
|
|
52772
52843
|
var members = node.members;
|
|
@@ -53035,8 +53106,10 @@ var ts;
|
|
|
53035
53106
|
return true;
|
|
53036
53107
|
}
|
|
53037
53108
|
// Qualify if the symbol from symbol table has same meaning as expected
|
|
53038
|
-
|
|
53039
|
-
|
|
53109
|
+
var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
|
|
53110
|
+
symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
|
|
53111
|
+
var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
|
|
53112
|
+
if (flags & meaning) {
|
|
53040
53113
|
qualify = true;
|
|
53041
53114
|
return true;
|
|
53042
53115
|
}
|
|
@@ -55693,7 +55766,7 @@ var ts;
|
|
|
55693
55766
|
return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
|
|
55694
55767
|
}
|
|
55695
55768
|
function isTypeOnlyNamespace(symbol) {
|
|
55696
|
-
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m)
|
|
55769
|
+
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
|
|
55697
55770
|
}
|
|
55698
55771
|
function serializeModule(symbol, symbolName, modifierFlags) {
|
|
55699
55772
|
var members = getNamespaceMembersForSerialization(symbol);
|
|
@@ -57913,7 +57986,7 @@ var ts;
|
|
|
57913
57986
|
links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
|
|
57914
57987
|
: isDuplicatedCommonJSExport(symbol.declarations) ? autoType
|
|
57915
57988
|
: declaredType ? declaredType
|
|
57916
|
-
: targetSymbol
|
|
57989
|
+
: getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
|
|
57917
57990
|
: errorType;
|
|
57918
57991
|
}
|
|
57919
57992
|
return links.type;
|
|
@@ -60266,7 +60339,7 @@ var ts;
|
|
|
60266
60339
|
var indexTypes;
|
|
60267
60340
|
var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
|
|
60268
60341
|
// Flags we want to propagate to the result if they exist in all source symbols
|
|
60269
|
-
var optionalFlag
|
|
60342
|
+
var optionalFlag;
|
|
60270
60343
|
var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
|
|
60271
60344
|
var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
|
|
60272
60345
|
var mergedInstantiations = false;
|
|
@@ -60277,11 +60350,14 @@ var ts;
|
|
|
60277
60350
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
60278
60351
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
60279
60352
|
if (prop) {
|
|
60280
|
-
if (
|
|
60281
|
-
optionalFlag
|
|
60282
|
-
|
|
60283
|
-
|
|
60284
|
-
|
|
60353
|
+
if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
|
|
60354
|
+
optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
|
|
60355
|
+
if (isUnion) {
|
|
60356
|
+
optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
|
|
60357
|
+
}
|
|
60358
|
+
else {
|
|
60359
|
+
optionalFlag &= prop.flags;
|
|
60360
|
+
}
|
|
60285
60361
|
}
|
|
60286
60362
|
if (!singleProp) {
|
|
60287
60363
|
singleProp = prop;
|
|
@@ -60400,7 +60476,7 @@ var ts;
|
|
|
60400
60476
|
propTypes.push(type);
|
|
60401
60477
|
}
|
|
60402
60478
|
ts.addRange(propTypes, indexTypes);
|
|
60403
|
-
var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
|
|
60479
|
+
var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
|
|
60404
60480
|
result.containingType = containingType;
|
|
60405
60481
|
if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
|
|
60406
60482
|
result.valueDeclaration = firstValueDeclaration;
|
|
@@ -67011,7 +67087,7 @@ var ts;
|
|
|
67011
67087
|
// with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
|
|
67012
67088
|
var constraint = getConstraintOfTypeParameter(source);
|
|
67013
67089
|
if (constraint && hasNonCircularBaseConstraint(source)) {
|
|
67014
|
-
while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
|
|
67090
|
+
while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
|
|
67015
67091
|
if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
|
|
67016
67092
|
return result;
|
|
67017
67093
|
}
|
|
@@ -67667,7 +67743,7 @@ var ts;
|
|
|
67667
67743
|
return 0 /* Ternary.False */;
|
|
67668
67744
|
}
|
|
67669
67745
|
// When checking for comparability, be more lenient with optional properties.
|
|
67670
|
-
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67746
|
+
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67671
67747
|
// TypeScript 1.0 spec (April 2014): 3.8.3
|
|
67672
67748
|
// S is a subtype of a type T, and T is a supertype of S if ...
|
|
67673
67749
|
// S' and T are object types and, for each member M in T..
|
|
@@ -72939,9 +73015,9 @@ var ts;
|
|
|
72939
73015
|
});
|
|
72940
73016
|
}
|
|
72941
73017
|
function markAliasReferenced(symbol, location) {
|
|
72942
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
73018
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
72943
73019
|
var target = resolveAlias(symbol);
|
|
72944
|
-
if (target
|
|
73020
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
72945
73021
|
// An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
|
|
72946
73022
|
// (because the const enum value will not be inlined), or if (2) the alias is an export
|
|
72947
73023
|
// of a const enum declaration that will be preserved.
|
|
@@ -78833,7 +78909,7 @@ var ts;
|
|
|
78833
78909
|
if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
78834
78910
|
symbol = resolveAlias(symbol);
|
|
78835
78911
|
}
|
|
78836
|
-
return !!(symbol && (symbol
|
|
78912
|
+
return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
|
|
78837
78913
|
}
|
|
78838
78914
|
return false;
|
|
78839
78915
|
}
|
|
@@ -85008,7 +85084,16 @@ var ts;
|
|
|
85008
85084
|
var message = allowAsyncIterables
|
|
85009
85085
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
85010
85086
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
85011
|
-
|
|
85087
|
+
var suggestAwait =
|
|
85088
|
+
// for (const x of Promise<...>) or [...Promise<...>]
|
|
85089
|
+
!!getAwaitedTypeOfPromise(type)
|
|
85090
|
+
// for (const x of AsyncIterable<...>)
|
|
85091
|
+
|| (!allowAsyncIterables &&
|
|
85092
|
+
ts.isForOfStatement(errorNode.parent) &&
|
|
85093
|
+
errorNode.parent.expression === errorNode &&
|
|
85094
|
+
getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
|
|
85095
|
+
isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
|
|
85096
|
+
return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
|
|
85012
85097
|
}
|
|
85013
85098
|
/**
|
|
85014
85099
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -86859,10 +86944,11 @@ var ts;
|
|
|
86859
86944
|
}
|
|
86860
86945
|
return;
|
|
86861
86946
|
}
|
|
86947
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
86862
86948
|
var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
|
|
86863
86949
|
(symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
|
|
86864
86950
|
(symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
|
|
86865
|
-
if (
|
|
86951
|
+
if (targetFlags & excludedMeanings) {
|
|
86866
86952
|
var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
|
|
86867
86953
|
ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
|
|
86868
86954
|
ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
|
@@ -86872,7 +86958,7 @@ var ts;
|
|
|
86872
86958
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
86873
86959
|
&& !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
|
|
86874
86960
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
86875
|
-
var isType = !(
|
|
86961
|
+
var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
|
|
86876
86962
|
if (isType || typeOnlyAlias) {
|
|
86877
86963
|
switch (node.kind) {
|
|
86878
86964
|
case 270 /* SyntaxKind.ImportClause */:
|
|
@@ -87032,14 +87118,15 @@ var ts;
|
|
|
87032
87118
|
if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
|
|
87033
87119
|
var target = resolveAlias(getSymbolOfNode(node));
|
|
87034
87120
|
if (target !== unknownSymbol) {
|
|
87035
|
-
|
|
87121
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
87122
|
+
if (targetFlags & 111551 /* SymbolFlags.Value */) {
|
|
87036
87123
|
// Target is a value symbol, check that it is not hidden by a local declaration with the same name
|
|
87037
87124
|
var moduleName = ts.getFirstIdentifier(node.moduleReference);
|
|
87038
87125
|
if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
|
|
87039
87126
|
error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
|
|
87040
87127
|
}
|
|
87041
87128
|
}
|
|
87042
|
-
if (
|
|
87129
|
+
if (targetFlags & 788968 /* SymbolFlags.Type */) {
|
|
87043
87130
|
checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
|
|
87044
87131
|
}
|
|
87045
87132
|
}
|
|
@@ -87178,7 +87265,7 @@ var ts;
|
|
|
87178
87265
|
markExportAsReferenced(node);
|
|
87179
87266
|
}
|
|
87180
87267
|
var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
|
|
87181
|
-
if (!target || target
|
|
87268
|
+
if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87182
87269
|
checkExpressionCached(node.propertyName || node.name);
|
|
87183
87270
|
}
|
|
87184
87271
|
}
|
|
@@ -87225,7 +87312,7 @@ var ts;
|
|
|
87225
87312
|
markAliasReferenced(sym, id);
|
|
87226
87313
|
// If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
|
|
87227
87314
|
var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
|
|
87228
|
-
if (target
|
|
87315
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87229
87316
|
// However if it is a value, we need to check it's being used correctly
|
|
87230
87317
|
checkExpressionCached(node.expression);
|
|
87231
87318
|
}
|
|
@@ -88547,7 +88634,7 @@ var ts;
|
|
|
88547
88634
|
return symbolLinks.exportsSomeValue;
|
|
88548
88635
|
function isValue(s) {
|
|
88549
88636
|
s = resolveSymbol(s);
|
|
88550
|
-
return s && !!(s
|
|
88637
|
+
return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
|
|
88551
88638
|
}
|
|
88552
88639
|
}
|
|
88553
88640
|
function isNameOfModuleOrEnumDeclaration(node) {
|
|
@@ -88600,7 +88687,7 @@ var ts;
|
|
|
88600
88687
|
var symbol = getReferencedValueOrAliasSymbol(node);
|
|
88601
88688
|
// We should only get the declaration of an alias if there isn't a local value
|
|
88602
88689
|
// declaration for the symbol
|
|
88603
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
88690
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
88604
88691
|
return getDeclarationOfAliasSymbol(symbol);
|
|
88605
88692
|
}
|
|
88606
88693
|
}
|
|
@@ -88688,7 +88775,7 @@ var ts;
|
|
|
88688
88775
|
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88689
88776
|
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88690
88777
|
var symbol = getSymbolOfNode(node);
|
|
88691
|
-
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
|
|
88778
|
+
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
|
|
88692
88779
|
case 275 /* SyntaxKind.ExportDeclaration */:
|
|
88693
88780
|
var exportClause = node.exportClause;
|
|
88694
88781
|
return !!exportClause && (ts.isNamespaceExport(exportClause) ||
|
|
@@ -88710,6 +88797,7 @@ var ts;
|
|
|
88710
88797
|
return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
|
|
88711
88798
|
}
|
|
88712
88799
|
function isAliasResolvedToValue(symbol) {
|
|
88800
|
+
var _a;
|
|
88713
88801
|
if (!symbol) {
|
|
88714
88802
|
return false;
|
|
88715
88803
|
}
|
|
@@ -88719,7 +88807,7 @@ var ts;
|
|
|
88719
88807
|
}
|
|
88720
88808
|
// const enums and modules that contain only const enums are not considered values from the emit perspective
|
|
88721
88809
|
// unless 'preserveConstEnums' option is set to true
|
|
88722
|
-
return !!(target
|
|
88810
|
+
return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
|
|
88723
88811
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
|
|
88724
88812
|
}
|
|
88725
88813
|
function isConstEnumOrConstEnumOnlyModule(s) {
|
|
@@ -88734,7 +88822,7 @@ var ts;
|
|
|
88734
88822
|
}
|
|
88735
88823
|
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
88736
88824
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
|
|
88737
|
-
target
|
|
88825
|
+
getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
|
|
88738
88826
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
88739
88827
|
// An `export import ... =` of a value symbol is always considered referenced
|
|
88740
88828
|
return true;
|
|
@@ -128771,6 +128859,12 @@ var ts;
|
|
|
128771
128859
|
SemanticClassificationFormat["Original"] = "original";
|
|
128772
128860
|
SemanticClassificationFormat["TwentyTwenty"] = "2020";
|
|
128773
128861
|
})(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
|
|
128862
|
+
var OrganizeImportsMode;
|
|
128863
|
+
(function (OrganizeImportsMode) {
|
|
128864
|
+
OrganizeImportsMode["All"] = "All";
|
|
128865
|
+
OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
|
|
128866
|
+
OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
|
|
128867
|
+
})(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
|
|
128774
128868
|
var CompletionTriggerKind;
|
|
128775
128869
|
(function (CompletionTriggerKind) {
|
|
128776
128870
|
/** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
|
|
@@ -144526,23 +144620,39 @@ var ts;
|
|
|
144526
144620
|
* 2) Coalescing imports from the same module
|
|
144527
144621
|
* 3) Sorting imports
|
|
144528
144622
|
*/
|
|
144529
|
-
function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
144623
|
+
function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
|
|
144530
144624
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
144531
|
-
var
|
|
144625
|
+
var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
144626
|
+
var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
|
|
144627
|
+
var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
144628
|
+
var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
|
|
144629
|
+
var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
|
|
144630
|
+
var processImportsOfSameModuleSpecifier = function (importGroup) {
|
|
144631
|
+
var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
|
|
144632
|
+
return shouldSort
|
|
144633
|
+
? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
|
|
144634
|
+
: processedDeclarations;
|
|
144635
|
+
};
|
|
144532
144636
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
144533
144637
|
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
144534
|
-
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144535
|
-
//
|
|
144536
|
-
|
|
144537
|
-
|
|
144638
|
+
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
144639
|
+
// Exports are always used
|
|
144640
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
144641
|
+
// All of the old ExportDeclarations in the file, in syntactic order.
|
|
144642
|
+
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
|
|
144643
|
+
organizeImportsWorker(topLevelExportDecls, coalesceExports);
|
|
144644
|
+
}
|
|
144538
144645
|
for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
|
|
144539
144646
|
var ambientModule = _a[_i];
|
|
144540
144647
|
if (!ambientModule.body)
|
|
144541
144648
|
continue;
|
|
144542
144649
|
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
144543
|
-
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144544
|
-
|
|
144545
|
-
|
|
144650
|
+
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
144651
|
+
// Exports are always used
|
|
144652
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
144653
|
+
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
|
|
144654
|
+
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
|
|
144655
|
+
}
|
|
144546
144656
|
}
|
|
144547
144657
|
return changeTracker.getChanges();
|
|
144548
144658
|
function organizeImportsWorker(oldImportDecls, coalesce) {
|
|
@@ -144555,8 +144665,12 @@ var ts;
|
|
|
144555
144665
|
// Consider: we could do a more careful check that this trivia is actually a header,
|
|
144556
144666
|
// but the consequences of being wrong are very minor.
|
|
144557
144667
|
ts.suppressLeadingTrivia(oldImportDecls[0]);
|
|
144558
|
-
var oldImportGroups =
|
|
144559
|
-
|
|
144668
|
+
var oldImportGroups = shouldCombine
|
|
144669
|
+
? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
|
|
144670
|
+
: [oldImportDecls];
|
|
144671
|
+
var sortedImportGroups = shouldSort
|
|
144672
|
+
? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
|
|
144673
|
+
: oldImportGroups;
|
|
144560
144674
|
var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
|
|
144561
144675
|
return getExternalModuleName(importGroup[0].moduleSpecifier)
|
|
144562
144676
|
? coalesce(importGroup)
|
|
@@ -144620,11 +144734,7 @@ var ts;
|
|
|
144620
144734
|
}
|
|
144621
144735
|
return false;
|
|
144622
144736
|
}
|
|
144623
|
-
function removeUnusedImports(oldImports, sourceFile, program
|
|
144624
|
-
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
144625
|
-
if (skipDestructiveCodeActions) {
|
|
144626
|
-
return oldImports;
|
|
144627
|
-
}
|
|
144737
|
+
function removeUnusedImports(oldImports, sourceFile, program) {
|
|
144628
144738
|
var typeChecker = program.getTypeChecker();
|
|
144629
144739
|
var compilerOptions = program.getCompilerOptions();
|
|
144630
144740
|
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
|
@@ -153657,6 +153767,15 @@ var ts;
|
|
|
153657
153767
|
});
|
|
153658
153768
|
}
|
|
153659
153769
|
function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
|
|
153770
|
+
if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
|
|
153771
|
+
var exprType = checker.getTypeAtLocation(insertionSite);
|
|
153772
|
+
var asyncIter = checker.getAsyncIterableType();
|
|
153773
|
+
if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
|
|
153774
|
+
var forOf = insertionSite.parent;
|
|
153775
|
+
changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
|
|
153776
|
+
return;
|
|
153777
|
+
}
|
|
153778
|
+
}
|
|
153660
153779
|
if (ts.isBinaryExpression(insertionSite)) {
|
|
153661
153780
|
for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
|
|
153662
153781
|
var side = _a[_i];
|
|
@@ -169012,12 +169131,14 @@ var ts;
|
|
|
169012
169131
|
return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
|
|
169013
169132
|
}
|
|
169014
169133
|
function organizeImports(args, formatOptions, preferences) {
|
|
169134
|
+
var _a;
|
|
169015
169135
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
169016
169136
|
synchronizeHostData();
|
|
169017
169137
|
ts.Debug.assert(args.type === "file");
|
|
169018
169138
|
var sourceFile = getValidSourceFile(args.fileName);
|
|
169019
169139
|
var formatContext = ts.formatting.getFormatContext(formatOptions, host);
|
|
169020
|
-
|
|
169140
|
+
var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
|
|
169141
|
+
return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
|
|
169021
169142
|
}
|
|
169022
169143
|
function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
|
|
169023
169144
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
@@ -172016,6 +172137,12 @@ var ts;
|
|
|
172016
172137
|
CommandTypes["ProvideInlayHints"] = "provideInlayHints";
|
|
172017
172138
|
// NOTE: If updating this, be sure to also update `allCommandNames` in `testRunner/unittests/tsserver/session.ts`.
|
|
172018
172139
|
})(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {}));
|
|
172140
|
+
var OrganizeImportsMode;
|
|
172141
|
+
(function (OrganizeImportsMode) {
|
|
172142
|
+
OrganizeImportsMode["All"] = "All";
|
|
172143
|
+
OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
|
|
172144
|
+
OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
|
|
172145
|
+
})(OrganizeImportsMode = protocol.OrganizeImportsMode || (protocol.OrganizeImportsMode = {}));
|
|
172019
172146
|
var WatchFileKind;
|
|
172020
172147
|
(function (WatchFileKind) {
|
|
172021
172148
|
WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval";
|
|
@@ -181179,11 +181306,12 @@ var ts;
|
|
|
181179
181306
|
}
|
|
181180
181307
|
};
|
|
181181
181308
|
Session.prototype.organizeImports = function (args, simplifiedResult) {
|
|
181309
|
+
var _a;
|
|
181182
181310
|
ts.Debug.assert(args.scope.type === "file");
|
|
181183
|
-
var
|
|
181311
|
+
var _b = this.getFileAndProject(args.scope.args), file = _b.file, project = _b.project;
|
|
181184
181312
|
var changes = project.getLanguageService().organizeImports({
|
|
181185
181313
|
fileName: file,
|
|
181186
|
-
|
|
181314
|
+
mode: (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : undefined),
|
|
181187
181315
|
type: "file",
|
|
181188
181316
|
}, this.getFormatOptions(file), this.getPreferences(file));
|
|
181189
181317
|
if (simplifiedResult) {
|