typescript 4.9.0-dev.20220929 → 4.9.0-dev.20221001
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/protocol.d.ts +7 -0
- package/lib/tsc.js +113 -53
- package/lib/tsserver.js +201 -75
- package/lib/tsserverlibrary.d.ts +14 -0
- package/lib/tsserverlibrary.js +201 -75
- package/lib/typescript.d.ts +7 -0
- package/lib/typescript.js +192 -73
- package/lib/typescriptServices.d.ts +7 -0
- package/lib/typescriptServices.js +192 -73
- package/lib/typingsInstaller.js +142 -56
- 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.20221001");
|
|
112
112
|
/* @internal */
|
|
113
113
|
var Comparison;
|
|
114
114
|
(function (Comparison) {
|
|
@@ -11377,7 +11377,7 @@ var ts;
|
|
|
11377
11377
|
return -1;
|
|
11378
11378
|
}
|
|
11379
11379
|
function peekExtendedUnicodeEscape() {
|
|
11380
|
-
if (
|
|
11380
|
+
if (codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
|
|
11381
11381
|
var start_2 = pos;
|
|
11382
11382
|
pos += 3;
|
|
11383
11383
|
var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
|
|
@@ -23158,7 +23158,7 @@ var ts;
|
|
|
23158
23158
|
return node;
|
|
23159
23159
|
}
|
|
23160
23160
|
// @api
|
|
23161
|
-
function createIdentifier(text, typeArguments, originalKeywordKind) {
|
|
23161
|
+
function createIdentifier(text, typeArguments, originalKeywordKind, hasExtendedUnicodeEscape) {
|
|
23162
23162
|
var node = createBaseIdentifier(text, originalKeywordKind);
|
|
23163
23163
|
if (typeArguments) {
|
|
23164
23164
|
// NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
|
|
@@ -23167,6 +23167,10 @@ var ts;
|
|
|
23167
23167
|
if (node.originalKeywordKind === 133 /* SyntaxKind.AwaitKeyword */) {
|
|
23168
23168
|
node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */;
|
|
23169
23169
|
}
|
|
23170
|
+
if (hasExtendedUnicodeEscape) {
|
|
23171
|
+
node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
|
|
23172
|
+
node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
|
|
23173
|
+
}
|
|
23170
23174
|
return node;
|
|
23171
23175
|
}
|
|
23172
23176
|
// @api
|
|
@@ -33101,8 +33105,9 @@ var ts;
|
|
|
33101
33105
|
// Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
|
|
33102
33106
|
var originalKeywordKind = token();
|
|
33103
33107
|
var text = internIdentifier(scanner.getTokenValue());
|
|
33108
|
+
var hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
|
|
33104
33109
|
nextTokenWithoutCheck();
|
|
33105
|
-
return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos);
|
|
33110
|
+
return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind, hasExtendedUnicodeEscape), pos);
|
|
33106
33111
|
}
|
|
33107
33112
|
if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
|
|
33108
33113
|
parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
|
|
@@ -49497,6 +49502,12 @@ var ts;
|
|
|
49497
49502
|
getOptionalType: function () { return optionalType; },
|
|
49498
49503
|
getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
|
|
49499
49504
|
getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
|
|
49505
|
+
getAsyncIterableType: function () {
|
|
49506
|
+
var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
|
|
49507
|
+
if (type === emptyGenericType)
|
|
49508
|
+
return undefined;
|
|
49509
|
+
return type;
|
|
49510
|
+
},
|
|
49500
49511
|
isSymbolAccessible: isSymbolAccessible,
|
|
49501
49512
|
isArrayType: isArrayType,
|
|
49502
49513
|
isTupleType: isTupleType,
|
|
@@ -50334,9 +50345,9 @@ var ts;
|
|
|
50334
50345
|
return symbol;
|
|
50335
50346
|
}
|
|
50336
50347
|
if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
50337
|
-
var
|
|
50338
|
-
//
|
|
50339
|
-
if (
|
|
50348
|
+
var targetFlags = getAllSymbolFlags(symbol);
|
|
50349
|
+
// `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
|
|
50350
|
+
if (targetFlags & meaning) {
|
|
50340
50351
|
return symbol;
|
|
50341
50352
|
}
|
|
50342
50353
|
}
|
|
@@ -50969,8 +50980,8 @@ var ts;
|
|
|
50969
50980
|
!checkAndReportErrorForExtendingInterface(errorLocation) &&
|
|
50970
50981
|
!checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
|
|
50971
50982
|
!checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
|
|
50983
|
+
!checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
|
|
50972
50984
|
!checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
|
|
50973
|
-
!checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
|
|
50974
50985
|
!checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
|
|
50975
50986
|
var suggestion = void 0;
|
|
50976
50987
|
var suggestedLib = void 0;
|
|
@@ -51057,7 +51068,7 @@ var ts;
|
|
|
51057
51068
|
}
|
|
51058
51069
|
}
|
|
51059
51070
|
if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
51060
|
-
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
|
|
51071
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
|
|
51061
51072
|
if (typeOnlyDeclaration) {
|
|
51062
51073
|
var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
|
|
51063
51074
|
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
@@ -51220,7 +51231,7 @@ var ts;
|
|
|
51220
51231
|
return false;
|
|
51221
51232
|
}
|
|
51222
51233
|
function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
|
|
51223
|
-
if (meaning &
|
|
51234
|
+
if (meaning & 111551 /* SymbolFlags.Value */) {
|
|
51224
51235
|
if (isPrimitiveTypeName(name)) {
|
|
51225
51236
|
if (isExtendedByInterface(errorLocation)) {
|
|
51226
51237
|
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));
|
|
@@ -51231,7 +51242,8 @@ var ts;
|
|
|
51231
51242
|
return true;
|
|
51232
51243
|
}
|
|
51233
51244
|
var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51234
|
-
|
|
51245
|
+
var allFlags = symbol && getAllSymbolFlags(symbol);
|
|
51246
|
+
if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
|
|
51235
51247
|
var rawName = ts.unescapeLeadingUnderscores(name);
|
|
51236
51248
|
if (isES2015OrLaterConstructorName(name)) {
|
|
51237
51249
|
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);
|
|
@@ -51279,16 +51291,16 @@ var ts;
|
|
|
51279
51291
|
}
|
|
51280
51292
|
return false;
|
|
51281
51293
|
}
|
|
51282
|
-
function
|
|
51283
|
-
if (meaning & (111551 /* SymbolFlags.Value */ & ~
|
|
51284
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule
|
|
51294
|
+
function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
|
|
51295
|
+
if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
|
|
51296
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51285
51297
|
if (symbol) {
|
|
51286
51298
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
|
|
51287
51299
|
return true;
|
|
51288
51300
|
}
|
|
51289
51301
|
}
|
|
51290
|
-
else if (meaning & (788968 /* SymbolFlags.Type */ & ~
|
|
51291
|
-
var symbol = resolveSymbol(resolveName(errorLocation, name,
|
|
51302
|
+
else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
|
|
51303
|
+
var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
|
|
51292
51304
|
if (symbol) {
|
|
51293
51305
|
error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
|
|
51294
51306
|
return true;
|
|
@@ -51878,6 +51890,52 @@ var ts;
|
|
|
51878
51890
|
}
|
|
51879
51891
|
return undefined;
|
|
51880
51892
|
}
|
|
51893
|
+
/**
|
|
51894
|
+
* Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
|
|
51895
|
+
* is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
|
|
51896
|
+
* with another exported symbol, e.g.
|
|
51897
|
+
* ```ts
|
|
51898
|
+
* // a.ts
|
|
51899
|
+
* export const a = 0;
|
|
51900
|
+
* // b.ts
|
|
51901
|
+
* export { a } from "./a";
|
|
51902
|
+
* export type a = number;
|
|
51903
|
+
* // c.ts
|
|
51904
|
+
* import { a } from "./b";
|
|
51905
|
+
* ```
|
|
51906
|
+
* Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
|
|
51907
|
+
* from b.ts, even though there is still more alias to resolve. Consequently, if we were
|
|
51908
|
+
* trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
|
|
51909
|
+
* the local symbol and on the symbol returned by `resolveAlias` is not enough.
|
|
51910
|
+
* @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
|
|
51911
|
+
* combined flags of all alias targets otherwise.
|
|
51912
|
+
*/
|
|
51913
|
+
function getAllSymbolFlags(symbol) {
|
|
51914
|
+
var flags = symbol.flags;
|
|
51915
|
+
var seenSymbols;
|
|
51916
|
+
while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51917
|
+
var target = resolveAlias(symbol);
|
|
51918
|
+
if (target === unknownSymbol) {
|
|
51919
|
+
return 67108863 /* SymbolFlags.All */;
|
|
51920
|
+
}
|
|
51921
|
+
// Optimizations - try to avoid creating or adding to
|
|
51922
|
+
// `seenSymbols` if possible
|
|
51923
|
+
if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
|
|
51924
|
+
break;
|
|
51925
|
+
}
|
|
51926
|
+
if (target.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
51927
|
+
if (seenSymbols) {
|
|
51928
|
+
seenSymbols.add(target);
|
|
51929
|
+
}
|
|
51930
|
+
else {
|
|
51931
|
+
seenSymbols = new ts.Set([symbol, target]);
|
|
51932
|
+
}
|
|
51933
|
+
}
|
|
51934
|
+
flags |= target.flags;
|
|
51935
|
+
symbol = target;
|
|
51936
|
+
}
|
|
51937
|
+
return flags;
|
|
51938
|
+
}
|
|
51881
51939
|
/**
|
|
51882
51940
|
* Marks a symbol as type-only if its declaration is syntactically type-only.
|
|
51883
51941
|
* If it is not itself marked type-only, but resolves to a type-only alias
|
|
@@ -51923,19 +51981,25 @@ var ts;
|
|
|
51923
51981
|
return !!aliasDeclarationLinks.typeOnlyDeclaration;
|
|
51924
51982
|
}
|
|
51925
51983
|
/** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
|
|
51926
|
-
function getTypeOnlyAliasDeclaration(symbol) {
|
|
51984
|
+
function getTypeOnlyAliasDeclaration(symbol, include) {
|
|
51927
51985
|
if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
|
|
51928
51986
|
return undefined;
|
|
51929
51987
|
}
|
|
51930
51988
|
var links = getSymbolLinks(symbol);
|
|
51931
|
-
|
|
51989
|
+
if (include === undefined) {
|
|
51990
|
+
return links.typeOnlyDeclaration || undefined;
|
|
51991
|
+
}
|
|
51992
|
+
if (links.typeOnlyDeclaration) {
|
|
51993
|
+
return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
|
|
51994
|
+
}
|
|
51995
|
+
return undefined;
|
|
51932
51996
|
}
|
|
51933
51997
|
function markExportAsReferenced(node) {
|
|
51934
51998
|
var symbol = getSymbolOfNode(node);
|
|
51935
51999
|
var target = resolveAlias(symbol);
|
|
51936
52000
|
if (target) {
|
|
51937
52001
|
var markAlias = target === unknownSymbol ||
|
|
51938
|
-
((target
|
|
52002
|
+
((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
|
|
51939
52003
|
if (markAlias) {
|
|
51940
52004
|
markAliasSymbolAsReferenced(symbol);
|
|
51941
52005
|
}
|
|
@@ -51955,8 +52019,7 @@ var ts;
|
|
|
51955
52019
|
// This way a chain of imports can be elided if ultimately the final input is only used in a type
|
|
51956
52020
|
// position.
|
|
51957
52021
|
if (ts.isInternalModuleImportEqualsDeclaration(node)) {
|
|
51958
|
-
|
|
51959
|
-
if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
|
|
52022
|
+
if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
|
|
51960
52023
|
// import foo = <symbol>
|
|
51961
52024
|
checkExpressionCached(node.moduleReference);
|
|
51962
52025
|
}
|
|
@@ -52778,7 +52841,7 @@ var ts;
|
|
|
52778
52841
|
}
|
|
52779
52842
|
function symbolIsValue(symbol, includeTypeOnlyMembers) {
|
|
52780
52843
|
return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
|
|
52781
|
-
symbol.flags & 2097152 /* SymbolFlags.Alias */ &&
|
|
52844
|
+
symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
|
|
52782
52845
|
}
|
|
52783
52846
|
function findConstructorDeclaration(node) {
|
|
52784
52847
|
var members = node.members;
|
|
@@ -53047,8 +53110,10 @@ var ts;
|
|
|
53047
53110
|
return true;
|
|
53048
53111
|
}
|
|
53049
53112
|
// Qualify if the symbol from symbol table has same meaning as expected
|
|
53050
|
-
|
|
53051
|
-
|
|
53113
|
+
var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
|
|
53114
|
+
symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
|
|
53115
|
+
var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
|
|
53116
|
+
if (flags & meaning) {
|
|
53052
53117
|
qualify = true;
|
|
53053
53118
|
return true;
|
|
53054
53119
|
}
|
|
@@ -55705,7 +55770,7 @@ var ts;
|
|
|
55705
55770
|
return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
|
|
55706
55771
|
}
|
|
55707
55772
|
function isTypeOnlyNamespace(symbol) {
|
|
55708
|
-
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m)
|
|
55773
|
+
return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
|
|
55709
55774
|
}
|
|
55710
55775
|
function serializeModule(symbol, symbolName, modifierFlags) {
|
|
55711
55776
|
var members = getNamespaceMembersForSerialization(symbol);
|
|
@@ -57925,7 +57990,7 @@ var ts;
|
|
|
57925
57990
|
links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
|
|
57926
57991
|
: isDuplicatedCommonJSExport(symbol.declarations) ? autoType
|
|
57927
57992
|
: declaredType ? declaredType
|
|
57928
|
-
: targetSymbol
|
|
57993
|
+
: getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
|
|
57929
57994
|
: errorType;
|
|
57930
57995
|
}
|
|
57931
57996
|
return links.type;
|
|
@@ -60278,7 +60343,7 @@ var ts;
|
|
|
60278
60343
|
var indexTypes;
|
|
60279
60344
|
var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
|
|
60280
60345
|
// Flags we want to propagate to the result if they exist in all source symbols
|
|
60281
|
-
var optionalFlag
|
|
60346
|
+
var optionalFlag;
|
|
60282
60347
|
var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
|
|
60283
60348
|
var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
|
|
60284
60349
|
var mergedInstantiations = false;
|
|
@@ -60289,11 +60354,14 @@ var ts;
|
|
|
60289
60354
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
60290
60355
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
60291
60356
|
if (prop) {
|
|
60292
|
-
if (
|
|
60293
|
-
optionalFlag
|
|
60294
|
-
|
|
60295
|
-
|
|
60296
|
-
|
|
60357
|
+
if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
|
|
60358
|
+
optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
|
|
60359
|
+
if (isUnion) {
|
|
60360
|
+
optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
|
|
60361
|
+
}
|
|
60362
|
+
else {
|
|
60363
|
+
optionalFlag &= prop.flags;
|
|
60364
|
+
}
|
|
60297
60365
|
}
|
|
60298
60366
|
if (!singleProp) {
|
|
60299
60367
|
singleProp = prop;
|
|
@@ -60412,7 +60480,7 @@ var ts;
|
|
|
60412
60480
|
propTypes.push(type);
|
|
60413
60481
|
}
|
|
60414
60482
|
ts.addRange(propTypes, indexTypes);
|
|
60415
|
-
var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
|
|
60483
|
+
var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
|
|
60416
60484
|
result.containingType = containingType;
|
|
60417
60485
|
if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
|
|
60418
60486
|
result.valueDeclaration = firstValueDeclaration;
|
|
@@ -67679,7 +67747,7 @@ var ts;
|
|
|
67679
67747
|
return 0 /* Ternary.False */;
|
|
67680
67748
|
}
|
|
67681
67749
|
// When checking for comparability, be more lenient with optional properties.
|
|
67682
|
-
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67750
|
+
if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
|
|
67683
67751
|
// TypeScript 1.0 spec (April 2014): 3.8.3
|
|
67684
67752
|
// S is a subtype of a type T, and T is a supertype of S if ...
|
|
67685
67753
|
// S' and T are object types and, for each member M in T..
|
|
@@ -72951,9 +73019,9 @@ var ts;
|
|
|
72951
73019
|
});
|
|
72952
73020
|
}
|
|
72953
73021
|
function markAliasReferenced(symbol, location) {
|
|
72954
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
73022
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
72955
73023
|
var target = resolveAlias(symbol);
|
|
72956
|
-
if (target
|
|
73024
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
72957
73025
|
// An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
|
|
72958
73026
|
// (because the const enum value will not be inlined), or if (2) the alias is an export
|
|
72959
73027
|
// of a const enum declaration that will be preserved.
|
|
@@ -74369,9 +74437,10 @@ var ts;
|
|
|
74369
74437
|
function instantiateContextualType(contextualType, node, contextFlags) {
|
|
74370
74438
|
if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) {
|
|
74371
74439
|
var inferenceContext = getInferenceContext(node);
|
|
74372
|
-
// If no inferences have been made,
|
|
74373
|
-
//
|
|
74374
|
-
|
|
74440
|
+
// If no inferences have been made, and none of the type parameters for which we are inferring
|
|
74441
|
+
// specify default types, nothing is gained from instantiating as type parameters would just be
|
|
74442
|
+
// replaced with their constraints similar to the apparent type.
|
|
74443
|
+
if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
|
|
74375
74444
|
// For contextual signatures we incorporate all inferences made so far, e.g. from return
|
|
74376
74445
|
// types as well as arguments to the left in a function call.
|
|
74377
74446
|
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
@@ -78845,7 +78914,7 @@ var ts;
|
|
|
78845
78914
|
if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
78846
78915
|
symbol = resolveAlias(symbol);
|
|
78847
78916
|
}
|
|
78848
|
-
return !!(symbol && (symbol
|
|
78917
|
+
return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
|
|
78849
78918
|
}
|
|
78850
78919
|
return false;
|
|
78851
78920
|
}
|
|
@@ -81219,6 +81288,9 @@ var ts;
|
|
|
81219
81288
|
function hasInferenceCandidates(info) {
|
|
81220
81289
|
return !!(info.candidates || info.contraCandidates);
|
|
81221
81290
|
}
|
|
81291
|
+
function hasInferenceCandidatesOrDefault(info) {
|
|
81292
|
+
return !!(info.candidates || info.contraCandidates || hasTypeParameterDefault(info.typeParameter));
|
|
81293
|
+
}
|
|
81222
81294
|
function hasOverlappingInferences(a, b) {
|
|
81223
81295
|
for (var i = 0; i < a.length; i++) {
|
|
81224
81296
|
if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
|
|
@@ -85020,7 +85092,16 @@ var ts;
|
|
|
85020
85092
|
var message = allowAsyncIterables
|
|
85021
85093
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
85022
85094
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
85023
|
-
|
|
85095
|
+
var suggestAwait =
|
|
85096
|
+
// for (const x of Promise<...>) or [...Promise<...>]
|
|
85097
|
+
!!getAwaitedTypeOfPromise(type)
|
|
85098
|
+
// for (const x of AsyncIterable<...>)
|
|
85099
|
+
|| (!allowAsyncIterables &&
|
|
85100
|
+
ts.isForOfStatement(errorNode.parent) &&
|
|
85101
|
+
errorNode.parent.expression === errorNode &&
|
|
85102
|
+
getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
|
|
85103
|
+
isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
|
|
85104
|
+
return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
|
|
85024
85105
|
}
|
|
85025
85106
|
/**
|
|
85026
85107
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -86871,10 +86952,11 @@ var ts;
|
|
|
86871
86952
|
}
|
|
86872
86953
|
return;
|
|
86873
86954
|
}
|
|
86955
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
86874
86956
|
var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
|
|
86875
86957
|
(symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
|
|
86876
86958
|
(symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
|
|
86877
|
-
if (
|
|
86959
|
+
if (targetFlags & excludedMeanings) {
|
|
86878
86960
|
var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
|
|
86879
86961
|
ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
|
|
86880
86962
|
ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
|
@@ -86884,7 +86966,7 @@ var ts;
|
|
|
86884
86966
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
86885
86967
|
&& !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
|
|
86886
86968
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
86887
|
-
var isType = !(
|
|
86969
|
+
var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
|
|
86888
86970
|
if (isType || typeOnlyAlias) {
|
|
86889
86971
|
switch (node.kind) {
|
|
86890
86972
|
case 270 /* SyntaxKind.ImportClause */:
|
|
@@ -87044,14 +87126,15 @@ var ts;
|
|
|
87044
87126
|
if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
|
|
87045
87127
|
var target = resolveAlias(getSymbolOfNode(node));
|
|
87046
87128
|
if (target !== unknownSymbol) {
|
|
87047
|
-
|
|
87129
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
87130
|
+
if (targetFlags & 111551 /* SymbolFlags.Value */) {
|
|
87048
87131
|
// Target is a value symbol, check that it is not hidden by a local declaration with the same name
|
|
87049
87132
|
var moduleName = ts.getFirstIdentifier(node.moduleReference);
|
|
87050
87133
|
if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
|
|
87051
87134
|
error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
|
|
87052
87135
|
}
|
|
87053
87136
|
}
|
|
87054
|
-
if (
|
|
87137
|
+
if (targetFlags & 788968 /* SymbolFlags.Type */) {
|
|
87055
87138
|
checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
|
|
87056
87139
|
}
|
|
87057
87140
|
}
|
|
@@ -87190,7 +87273,7 @@ var ts;
|
|
|
87190
87273
|
markExportAsReferenced(node);
|
|
87191
87274
|
}
|
|
87192
87275
|
var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
|
|
87193
|
-
if (!target || target
|
|
87276
|
+
if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87194
87277
|
checkExpressionCached(node.propertyName || node.name);
|
|
87195
87278
|
}
|
|
87196
87279
|
}
|
|
@@ -87237,7 +87320,7 @@ var ts;
|
|
|
87237
87320
|
markAliasReferenced(sym, id);
|
|
87238
87321
|
// If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
|
|
87239
87322
|
var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
|
|
87240
|
-
if (target
|
|
87323
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87241
87324
|
// However if it is a value, we need to check it's being used correctly
|
|
87242
87325
|
checkExpressionCached(node.expression);
|
|
87243
87326
|
}
|
|
@@ -88559,7 +88642,7 @@ var ts;
|
|
|
88559
88642
|
return symbolLinks.exportsSomeValue;
|
|
88560
88643
|
function isValue(s) {
|
|
88561
88644
|
s = resolveSymbol(s);
|
|
88562
|
-
return s && !!(s
|
|
88645
|
+
return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
|
|
88563
88646
|
}
|
|
88564
88647
|
}
|
|
88565
88648
|
function isNameOfModuleOrEnumDeclaration(node) {
|
|
@@ -88612,7 +88695,7 @@ var ts;
|
|
|
88612
88695
|
var symbol = getReferencedValueOrAliasSymbol(node);
|
|
88613
88696
|
// We should only get the declaration of an alias if there isn't a local value
|
|
88614
88697
|
// declaration for the symbol
|
|
88615
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
88698
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
88616
88699
|
return getDeclarationOfAliasSymbol(symbol);
|
|
88617
88700
|
}
|
|
88618
88701
|
}
|
|
@@ -88700,7 +88783,7 @@ var ts;
|
|
|
88700
88783
|
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88701
88784
|
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88702
88785
|
var symbol = getSymbolOfNode(node);
|
|
88703
|
-
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
|
|
88786
|
+
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
|
|
88704
88787
|
case 275 /* SyntaxKind.ExportDeclaration */:
|
|
88705
88788
|
var exportClause = node.exportClause;
|
|
88706
88789
|
return !!exportClause && (ts.isNamespaceExport(exportClause) ||
|
|
@@ -88722,6 +88805,7 @@ var ts;
|
|
|
88722
88805
|
return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
|
|
88723
88806
|
}
|
|
88724
88807
|
function isAliasResolvedToValue(symbol) {
|
|
88808
|
+
var _a;
|
|
88725
88809
|
if (!symbol) {
|
|
88726
88810
|
return false;
|
|
88727
88811
|
}
|
|
@@ -88731,7 +88815,7 @@ var ts;
|
|
|
88731
88815
|
}
|
|
88732
88816
|
// const enums and modules that contain only const enums are not considered values from the emit perspective
|
|
88733
88817
|
// unless 'preserveConstEnums' option is set to true
|
|
88734
|
-
return !!(target
|
|
88818
|
+
return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
|
|
88735
88819
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
|
|
88736
88820
|
}
|
|
88737
88821
|
function isConstEnumOrConstEnumOnlyModule(s) {
|
|
@@ -88746,7 +88830,7 @@ var ts;
|
|
|
88746
88830
|
}
|
|
88747
88831
|
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
88748
88832
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
|
|
88749
|
-
target
|
|
88833
|
+
getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
|
|
88750
88834
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
88751
88835
|
// An `export import ... =` of a value symbol is always considered referenced
|
|
88752
88836
|
return true;
|
|
@@ -101239,11 +101323,13 @@ var ts;
|
|
|
101239
101323
|
return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
|
|
101240
101324
|
}
|
|
101241
101325
|
function visitIdentifier(node) {
|
|
101242
|
-
if (
|
|
101243
|
-
|
|
101326
|
+
if (convertedLoopState) {
|
|
101327
|
+
if (resolver.isArgumentsLocalBinding(node)) {
|
|
101328
|
+
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
|
|
101329
|
+
}
|
|
101244
101330
|
}
|
|
101245
|
-
if (
|
|
101246
|
-
return
|
|
101331
|
+
if (node.hasExtendedUnicodeEscape) {
|
|
101332
|
+
return ts.setOriginalNode(ts.setTextRange(factory.createIdentifier(ts.unescapeLeadingUnderscores(node.escapedText)), node), node);
|
|
101247
101333
|
}
|
|
101248
101334
|
return node;
|
|
101249
101335
|
}
|
|
@@ -129202,6 +129288,12 @@ var ts;
|
|
|
129202
129288
|
SemanticClassificationFormat["Original"] = "original";
|
|
129203
129289
|
SemanticClassificationFormat["TwentyTwenty"] = "2020";
|
|
129204
129290
|
})(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
|
|
129291
|
+
var OrganizeImportsMode;
|
|
129292
|
+
(function (OrganizeImportsMode) {
|
|
129293
|
+
OrganizeImportsMode["All"] = "All";
|
|
129294
|
+
OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
|
|
129295
|
+
OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
|
|
129296
|
+
})(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
|
|
129205
129297
|
var CompletionTriggerKind;
|
|
129206
129298
|
(function (CompletionTriggerKind) {
|
|
129207
129299
|
/** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
|
|
@@ -144957,23 +145049,39 @@ var ts;
|
|
|
144957
145049
|
* 2) Coalescing imports from the same module
|
|
144958
145050
|
* 3) Sorting imports
|
|
144959
145051
|
*/
|
|
144960
|
-
function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
145052
|
+
function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
|
|
144961
145053
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
144962
|
-
var
|
|
145054
|
+
var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
145055
|
+
var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
|
|
145056
|
+
var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
|
|
145057
|
+
var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
|
|
145058
|
+
var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
|
|
145059
|
+
var processImportsOfSameModuleSpecifier = function (importGroup) {
|
|
145060
|
+
var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
|
|
145061
|
+
return shouldSort
|
|
145062
|
+
? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
|
|
145063
|
+
: processedDeclarations;
|
|
145064
|
+
};
|
|
144963
145065
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
144964
145066
|
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
144965
|
-
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144966
|
-
//
|
|
144967
|
-
|
|
144968
|
-
|
|
145067
|
+
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
145068
|
+
// Exports are always used
|
|
145069
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
145070
|
+
// All of the old ExportDeclarations in the file, in syntactic order.
|
|
145071
|
+
var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
|
|
145072
|
+
organizeImportsWorker(topLevelExportDecls, coalesceExports);
|
|
145073
|
+
}
|
|
144969
145074
|
for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
|
|
144970
145075
|
var ambientModule = _a[_i];
|
|
144971
145076
|
if (!ambientModule.body)
|
|
144972
145077
|
continue;
|
|
144973
145078
|
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
144974
|
-
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144975
|
-
|
|
144976
|
-
|
|
145079
|
+
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
|
|
145080
|
+
// Exports are always used
|
|
145081
|
+
if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
|
|
145082
|
+
var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
|
|
145083
|
+
organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
|
|
145084
|
+
}
|
|
144977
145085
|
}
|
|
144978
145086
|
return changeTracker.getChanges();
|
|
144979
145087
|
function organizeImportsWorker(oldImportDecls, coalesce) {
|
|
@@ -144986,8 +145094,12 @@ var ts;
|
|
|
144986
145094
|
// Consider: we could do a more careful check that this trivia is actually a header,
|
|
144987
145095
|
// but the consequences of being wrong are very minor.
|
|
144988
145096
|
ts.suppressLeadingTrivia(oldImportDecls[0]);
|
|
144989
|
-
var oldImportGroups =
|
|
144990
|
-
|
|
145097
|
+
var oldImportGroups = shouldCombine
|
|
145098
|
+
? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
|
|
145099
|
+
: [oldImportDecls];
|
|
145100
|
+
var sortedImportGroups = shouldSort
|
|
145101
|
+
? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
|
|
145102
|
+
: oldImportGroups;
|
|
144991
145103
|
var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
|
|
144992
145104
|
return getExternalModuleName(importGroup[0].moduleSpecifier)
|
|
144993
145105
|
? coalesce(importGroup)
|
|
@@ -145051,11 +145163,7 @@ var ts;
|
|
|
145051
145163
|
}
|
|
145052
145164
|
return false;
|
|
145053
145165
|
}
|
|
145054
|
-
function removeUnusedImports(oldImports, sourceFile, program
|
|
145055
|
-
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
145056
|
-
if (skipDestructiveCodeActions) {
|
|
145057
|
-
return oldImports;
|
|
145058
|
-
}
|
|
145166
|
+
function removeUnusedImports(oldImports, sourceFile, program) {
|
|
145059
145167
|
var typeChecker = program.getTypeChecker();
|
|
145060
145168
|
var compilerOptions = program.getCompilerOptions();
|
|
145061
145169
|
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
|
@@ -154088,6 +154196,15 @@ var ts;
|
|
|
154088
154196
|
});
|
|
154089
154197
|
}
|
|
154090
154198
|
function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
|
|
154199
|
+
if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
|
|
154200
|
+
var exprType = checker.getTypeAtLocation(insertionSite);
|
|
154201
|
+
var asyncIter = checker.getAsyncIterableType();
|
|
154202
|
+
if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
|
|
154203
|
+
var forOf = insertionSite.parent;
|
|
154204
|
+
changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
|
|
154205
|
+
return;
|
|
154206
|
+
}
|
|
154207
|
+
}
|
|
154091
154208
|
if (ts.isBinaryExpression(insertionSite)) {
|
|
154092
154209
|
for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
|
|
154093
154210
|
var side = _a[_i];
|
|
@@ -169443,12 +169560,14 @@ var ts;
|
|
|
169443
169560
|
return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
|
|
169444
169561
|
}
|
|
169445
169562
|
function organizeImports(args, formatOptions, preferences) {
|
|
169563
|
+
var _a;
|
|
169446
169564
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
169447
169565
|
synchronizeHostData();
|
|
169448
169566
|
ts.Debug.assert(args.type === "file");
|
|
169449
169567
|
var sourceFile = getValidSourceFile(args.fileName);
|
|
169450
169568
|
var formatContext = ts.formatting.getFormatContext(formatOptions, host);
|
|
169451
|
-
|
|
169569
|
+
var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
|
|
169570
|
+
return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
|
|
169452
169571
|
}
|
|
169453
169572
|
function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
|
|
169454
169573
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
@@ -172028,6 +172147,12 @@ var ts;
|
|
|
172028
172147
|
CommandTypes["ProvideInlayHints"] = "provideInlayHints";
|
|
172029
172148
|
// NOTE: If updating this, be sure to also update `allCommandNames` in `testRunner/unittests/tsserver/session.ts`.
|
|
172030
172149
|
})(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {}));
|
|
172150
|
+
var OrganizeImportsMode;
|
|
172151
|
+
(function (OrganizeImportsMode) {
|
|
172152
|
+
OrganizeImportsMode["All"] = "All";
|
|
172153
|
+
OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
|
|
172154
|
+
OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
|
|
172155
|
+
})(OrganizeImportsMode = protocol.OrganizeImportsMode || (protocol.OrganizeImportsMode = {}));
|
|
172031
172156
|
var WatchFileKind;
|
|
172032
172157
|
(function (WatchFileKind) {
|
|
172033
172158
|
WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval";
|
|
@@ -181191,11 +181316,12 @@ var ts;
|
|
|
181191
181316
|
}
|
|
181192
181317
|
};
|
|
181193
181318
|
Session.prototype.organizeImports = function (args, simplifiedResult) {
|
|
181319
|
+
var _a;
|
|
181194
181320
|
ts.Debug.assert(args.scope.type === "file");
|
|
181195
|
-
var
|
|
181321
|
+
var _b = this.getFileAndProject(args.scope.args), file = _b.file, project = _b.project;
|
|
181196
181322
|
var changes = project.getLanguageService().organizeImports({
|
|
181197
181323
|
fileName: file,
|
|
181198
|
-
|
|
181324
|
+
mode: (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : undefined),
|
|
181199
181325
|
type: "file",
|
|
181200
181326
|
}, this.getFormatOptions(file), this.getPreferences(file));
|
|
181201
181327
|
if (simplifiedResult) {
|