@typescript-deploys/pr-build 4.9.0-pr-50976-13 → 4.9.0-pr-51026-2
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 +0 -2
- package/lib/tsc.js +114 -68
- package/lib/tsserver.js +203 -93
- package/lib/tsserverlibrary.d.ts +14 -0
- package/lib/tsserverlibrary.js +203 -93
- package/lib/typescript.d.ts +7 -0
- package/lib/typescript.js +194 -92
- package/lib/typescriptServices.d.ts +258 -285
- package/lib/typescriptServices.js +9520 -10726
- package/lib/typingsInstaller.js +144 -74
- 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-insiders.
|
|
111
|
+
ts.version = "".concat(ts.versionMajorMinor, ".0-insiders.20221003");
|
|
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);
|
|
@@ -57619,32 +57684,16 @@ var ts;
|
|
|
57619
57684
|
return getTypeFromTypeNode(typeNode);
|
|
57620
57685
|
}
|
|
57621
57686
|
}
|
|
57622
|
-
function isParameterOfContextSensitiveSignature(symbol) {
|
|
57623
|
-
var decl = symbol.valueDeclaration;
|
|
57624
|
-
if (!decl) {
|
|
57625
|
-
return false;
|
|
57626
|
-
}
|
|
57627
|
-
if (ts.isBindingElement(decl)) {
|
|
57628
|
-
decl = ts.walkUpBindingElementsAndPatterns(decl);
|
|
57629
|
-
}
|
|
57630
|
-
if (ts.isParameter(decl)) {
|
|
57631
|
-
return isContextSensitiveFunctionOrObjectLiteralMethod(decl.parent);
|
|
57632
|
-
}
|
|
57633
|
-
return false;
|
|
57634
|
-
}
|
|
57635
57687
|
function getTypeOfVariableOrParameterOrProperty(symbol) {
|
|
57636
57688
|
var links = getSymbolLinks(symbol);
|
|
57637
57689
|
if (!links.type) {
|
|
57638
57690
|
var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
|
|
57639
57691
|
// For a contextually typed parameter it is possible that a type has already
|
|
57640
57692
|
// been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
|
|
57641
|
-
// to preserve this type.
|
|
57642
|
-
|
|
57643
|
-
// cases where contextual typing may take place.
|
|
57644
|
-
if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
|
|
57693
|
+
// to preserve this type.
|
|
57694
|
+
if (!links.type) {
|
|
57645
57695
|
links.type = type;
|
|
57646
57696
|
}
|
|
57647
|
-
return type;
|
|
57648
57697
|
}
|
|
57649
57698
|
return links.type;
|
|
57650
57699
|
}
|
|
@@ -57941,7 +57990,7 @@ var ts;
|
|
|
57941
57990
|
links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
|
|
57942
57991
|
: isDuplicatedCommonJSExport(symbol.declarations) ? autoType
|
|
57943
57992
|
: declaredType ? declaredType
|
|
57944
|
-
: targetSymbol
|
|
57993
|
+
: getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
|
|
57945
57994
|
: errorType;
|
|
57946
57995
|
}
|
|
57947
57996
|
return links.type;
|
|
@@ -60294,7 +60343,7 @@ var ts;
|
|
|
60294
60343
|
var indexTypes;
|
|
60295
60344
|
var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
|
|
60296
60345
|
// Flags we want to propagate to the result if they exist in all source symbols
|
|
60297
|
-
var optionalFlag
|
|
60346
|
+
var optionalFlag;
|
|
60298
60347
|
var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
|
|
60299
60348
|
var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
|
|
60300
60349
|
var mergedInstantiations = false;
|
|
@@ -60305,11 +60354,14 @@ var ts;
|
|
|
60305
60354
|
var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
|
|
60306
60355
|
var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
|
|
60307
60356
|
if (prop) {
|
|
60308
|
-
if (
|
|
60309
|
-
optionalFlag
|
|
60310
|
-
|
|
60311
|
-
|
|
60312
|
-
|
|
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
|
+
}
|
|
60313
60365
|
}
|
|
60314
60366
|
if (!singleProp) {
|
|
60315
60367
|
singleProp = prop;
|
|
@@ -60428,7 +60480,7 @@ var ts;
|
|
|
60428
60480
|
propTypes.push(type);
|
|
60429
60481
|
}
|
|
60430
60482
|
ts.addRange(propTypes, indexTypes);
|
|
60431
|
-
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);
|
|
60432
60484
|
result.containingType = containingType;
|
|
60433
60485
|
if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
|
|
60434
60486
|
result.valueDeclaration = firstValueDeclaration;
|
|
@@ -67695,7 +67747,7 @@ var ts;
|
|
|
67695
67747
|
return 0 /* Ternary.False */;
|
|
67696
67748
|
}
|
|
67697
67749
|
// When checking for comparability, be more lenient with optional properties.
|
|
67698
|
-
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 */)) {
|
|
67699
67751
|
// TypeScript 1.0 spec (April 2014): 3.8.3
|
|
67700
67752
|
// S is a subtype of a type T, and T is a supertype of S if ...
|
|
67701
67753
|
// S' and T are object types and, for each member M in T..
|
|
@@ -72967,9 +73019,9 @@ var ts;
|
|
|
72967
73019
|
});
|
|
72968
73020
|
}
|
|
72969
73021
|
function markAliasReferenced(symbol, location) {
|
|
72970
|
-
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 */)) {
|
|
72971
73023
|
var target = resolveAlias(symbol);
|
|
72972
|
-
if (target
|
|
73024
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
72973
73025
|
// An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
|
|
72974
73026
|
// (because the const enum value will not be inlined), or if (2) the alias is an export
|
|
72975
73027
|
// of a const enum declaration that will be preserved.
|
|
@@ -74385,9 +74437,10 @@ var ts;
|
|
|
74385
74437
|
function instantiateContextualType(contextualType, node, contextFlags) {
|
|
74386
74438
|
if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) {
|
|
74387
74439
|
var inferenceContext = getInferenceContext(node);
|
|
74388
|
-
// If no inferences have been made,
|
|
74389
|
-
//
|
|
74390
|
-
|
|
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)) {
|
|
74391
74444
|
// For contextual signatures we incorporate all inferences made so far, e.g. from return
|
|
74392
74445
|
// types as well as arguments to the left in a function call.
|
|
74393
74446
|
return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
|
|
@@ -78861,7 +78914,7 @@ var ts;
|
|
|
78861
78914
|
if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
|
|
78862
78915
|
symbol = resolveAlias(symbol);
|
|
78863
78916
|
}
|
|
78864
|
-
return !!(symbol && (symbol
|
|
78917
|
+
return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
|
|
78865
78918
|
}
|
|
78866
78919
|
return false;
|
|
78867
78920
|
}
|
|
@@ -81235,6 +81288,9 @@ var ts;
|
|
|
81235
81288
|
function hasInferenceCandidates(info) {
|
|
81236
81289
|
return !!(info.candidates || info.contraCandidates);
|
|
81237
81290
|
}
|
|
81291
|
+
function hasInferenceCandidatesOrDefault(info) {
|
|
81292
|
+
return !!(info.candidates || info.contraCandidates || hasTypeParameterDefault(info.typeParameter));
|
|
81293
|
+
}
|
|
81238
81294
|
function hasOverlappingInferences(a, b) {
|
|
81239
81295
|
for (var i = 0; i < a.length; i++) {
|
|
81240
81296
|
if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
|
|
@@ -85036,7 +85092,16 @@ var ts;
|
|
|
85036
85092
|
var message = allowAsyncIterables
|
|
85037
85093
|
? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
|
|
85038
85094
|
: ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
|
|
85039
|
-
|
|
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));
|
|
85040
85105
|
}
|
|
85041
85106
|
/**
|
|
85042
85107
|
* Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
|
|
@@ -86887,10 +86952,11 @@ var ts;
|
|
|
86887
86952
|
}
|
|
86888
86953
|
return;
|
|
86889
86954
|
}
|
|
86955
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
86890
86956
|
var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
|
|
86891
86957
|
(symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
|
|
86892
86958
|
(symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
|
|
86893
|
-
if (
|
|
86959
|
+
if (targetFlags & excludedMeanings) {
|
|
86894
86960
|
var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
|
|
86895
86961
|
ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
|
|
86896
86962
|
ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
|
|
@@ -86900,7 +86966,7 @@ var ts;
|
|
|
86900
86966
|
&& !ts.isTypeOnlyImportOrExportDeclaration(node)
|
|
86901
86967
|
&& !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
|
|
86902
86968
|
var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
|
|
86903
|
-
var isType = !(
|
|
86969
|
+
var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
|
|
86904
86970
|
if (isType || typeOnlyAlias) {
|
|
86905
86971
|
switch (node.kind) {
|
|
86906
86972
|
case 270 /* SyntaxKind.ImportClause */:
|
|
@@ -87060,14 +87126,15 @@ var ts;
|
|
|
87060
87126
|
if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
|
|
87061
87127
|
var target = resolveAlias(getSymbolOfNode(node));
|
|
87062
87128
|
if (target !== unknownSymbol) {
|
|
87063
|
-
|
|
87129
|
+
var targetFlags = getAllSymbolFlags(target);
|
|
87130
|
+
if (targetFlags & 111551 /* SymbolFlags.Value */) {
|
|
87064
87131
|
// Target is a value symbol, check that it is not hidden by a local declaration with the same name
|
|
87065
87132
|
var moduleName = ts.getFirstIdentifier(node.moduleReference);
|
|
87066
87133
|
if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
|
|
87067
87134
|
error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
|
|
87068
87135
|
}
|
|
87069
87136
|
}
|
|
87070
|
-
if (
|
|
87137
|
+
if (targetFlags & 788968 /* SymbolFlags.Type */) {
|
|
87071
87138
|
checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
|
|
87072
87139
|
}
|
|
87073
87140
|
}
|
|
@@ -87206,7 +87273,7 @@ var ts;
|
|
|
87206
87273
|
markExportAsReferenced(node);
|
|
87207
87274
|
}
|
|
87208
87275
|
var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
|
|
87209
|
-
if (!target || target
|
|
87276
|
+
if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87210
87277
|
checkExpressionCached(node.propertyName || node.name);
|
|
87211
87278
|
}
|
|
87212
87279
|
}
|
|
@@ -87253,7 +87320,7 @@ var ts;
|
|
|
87253
87320
|
markAliasReferenced(sym, id);
|
|
87254
87321
|
// If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
|
|
87255
87322
|
var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
|
|
87256
|
-
if (target
|
|
87323
|
+
if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
|
|
87257
87324
|
// However if it is a value, we need to check it's being used correctly
|
|
87258
87325
|
checkExpressionCached(node.expression);
|
|
87259
87326
|
}
|
|
@@ -88575,7 +88642,7 @@ var ts;
|
|
|
88575
88642
|
return symbolLinks.exportsSomeValue;
|
|
88576
88643
|
function isValue(s) {
|
|
88577
88644
|
s = resolveSymbol(s);
|
|
88578
|
-
return s && !!(s
|
|
88645
|
+
return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
|
|
88579
88646
|
}
|
|
88580
88647
|
}
|
|
88581
88648
|
function isNameOfModuleOrEnumDeclaration(node) {
|
|
@@ -88628,7 +88695,7 @@ var ts;
|
|
|
88628
88695
|
var symbol = getReferencedValueOrAliasSymbol(node);
|
|
88629
88696
|
// We should only get the declaration of an alias if there isn't a local value
|
|
88630
88697
|
// declaration for the symbol
|
|
88631
|
-
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
|
|
88698
|
+
if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
|
|
88632
88699
|
return getDeclarationOfAliasSymbol(symbol);
|
|
88633
88700
|
}
|
|
88634
88701
|
}
|
|
@@ -88716,7 +88783,7 @@ var ts;
|
|
|
88716
88783
|
case 273 /* SyntaxKind.ImportSpecifier */:
|
|
88717
88784
|
case 278 /* SyntaxKind.ExportSpecifier */:
|
|
88718
88785
|
var symbol = getSymbolOfNode(node);
|
|
88719
|
-
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
|
|
88786
|
+
return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
|
|
88720
88787
|
case 275 /* SyntaxKind.ExportDeclaration */:
|
|
88721
88788
|
var exportClause = node.exportClause;
|
|
88722
88789
|
return !!exportClause && (ts.isNamespaceExport(exportClause) ||
|
|
@@ -88738,6 +88805,7 @@ var ts;
|
|
|
88738
88805
|
return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
|
|
88739
88806
|
}
|
|
88740
88807
|
function isAliasResolvedToValue(symbol) {
|
|
88808
|
+
var _a;
|
|
88741
88809
|
if (!symbol) {
|
|
88742
88810
|
return false;
|
|
88743
88811
|
}
|
|
@@ -88747,7 +88815,7 @@ var ts;
|
|
|
88747
88815
|
}
|
|
88748
88816
|
// const enums and modules that contain only const enums are not considered values from the emit perspective
|
|
88749
88817
|
// unless 'preserveConstEnums' option is set to true
|
|
88750
|
-
return !!(target
|
|
88818
|
+
return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
|
|
88751
88819
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
|
|
88752
88820
|
}
|
|
88753
88821
|
function isConstEnumOrConstEnumOnlyModule(s) {
|
|
@@ -88762,7 +88830,7 @@ var ts;
|
|
|
88762
88830
|
}
|
|
88763
88831
|
var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
|
|
88764
88832
|
if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
|
|
88765
|
-
target
|
|
88833
|
+
getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
|
|
88766
88834
|
(ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
|
|
88767
88835
|
// An `export import ... =` of a value symbol is always considered referenced
|
|
88768
88836
|
return true;
|
|
@@ -101255,11 +101323,13 @@ var ts;
|
|
|
101255
101323
|
return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
|
|
101256
101324
|
}
|
|
101257
101325
|
function visitIdentifier(node) {
|
|
101258
|
-
if (
|
|
101259
|
-
|
|
101326
|
+
if (convertedLoopState) {
|
|
101327
|
+
if (resolver.isArgumentsLocalBinding(node)) {
|
|
101328
|
+
return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
|
|
101329
|
+
}
|
|
101260
101330
|
}
|
|
101261
|
-
if (
|
|
101262
|
-
return
|
|
101331
|
+
if (node.hasExtendedUnicodeEscape) {
|
|
101332
|
+
return ts.setOriginalNode(ts.setTextRange(factory.createIdentifier(ts.unescapeLeadingUnderscores(node.escapedText)), node), node);
|
|
101263
101333
|
}
|
|
101264
101334
|
return node;
|
|
101265
101335
|
}
|
|
@@ -129218,6 +129288,12 @@ var ts;
|
|
|
129218
129288
|
SemanticClassificationFormat["Original"] = "original";
|
|
129219
129289
|
SemanticClassificationFormat["TwentyTwenty"] = "2020";
|
|
129220
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 = {}));
|
|
129221
129297
|
var CompletionTriggerKind;
|
|
129222
129298
|
(function (CompletionTriggerKind) {
|
|
129223
129299
|
/** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
|
|
@@ -144973,23 +145049,39 @@ var ts;
|
|
|
144973
145049
|
* 2) Coalescing imports from the same module
|
|
144974
145050
|
* 3) Sorting imports
|
|
144975
145051
|
*/
|
|
144976
|
-
function organizeImports(sourceFile, formatContext, host, program, preferences,
|
|
145052
|
+
function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
|
|
144977
145053
|
var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
|
|
144978
|
-
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
|
+
};
|
|
144979
145065
|
// All of the old ImportDeclarations in the file, in syntactic order.
|
|
144980
145066
|
var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
|
|
144981
|
-
topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144982
|
-
//
|
|
144983
|
-
|
|
144984
|
-
|
|
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
|
+
}
|
|
144985
145074
|
for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
|
|
144986
145075
|
var ambientModule = _a[_i];
|
|
144987
145076
|
if (!ambientModule.body)
|
|
144988
145077
|
continue;
|
|
144989
145078
|
var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
|
|
144990
|
-
ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl,
|
|
144991
|
-
|
|
144992
|
-
|
|
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
|
+
}
|
|
144993
145085
|
}
|
|
144994
145086
|
return changeTracker.getChanges();
|
|
144995
145087
|
function organizeImportsWorker(oldImportDecls, coalesce) {
|
|
@@ -145002,8 +145094,12 @@ var ts;
|
|
|
145002
145094
|
// Consider: we could do a more careful check that this trivia is actually a header,
|
|
145003
145095
|
// but the consequences of being wrong are very minor.
|
|
145004
145096
|
ts.suppressLeadingTrivia(oldImportDecls[0]);
|
|
145005
|
-
var oldImportGroups =
|
|
145006
|
-
|
|
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;
|
|
145007
145103
|
var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
|
|
145008
145104
|
return getExternalModuleName(importGroup[0].moduleSpecifier)
|
|
145009
145105
|
? coalesce(importGroup)
|
|
@@ -145067,11 +145163,7 @@ var ts;
|
|
|
145067
145163
|
}
|
|
145068
145164
|
return false;
|
|
145069
145165
|
}
|
|
145070
|
-
function removeUnusedImports(oldImports, sourceFile, program
|
|
145071
|
-
// As a precaution, consider unused import detection to be destructive (GH #43051)
|
|
145072
|
-
if (skipDestructiveCodeActions) {
|
|
145073
|
-
return oldImports;
|
|
145074
|
-
}
|
|
145166
|
+
function removeUnusedImports(oldImports, sourceFile, program) {
|
|
145075
145167
|
var typeChecker = program.getTypeChecker();
|
|
145076
145168
|
var compilerOptions = program.getCompilerOptions();
|
|
145077
145169
|
var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
|
|
@@ -154104,6 +154196,15 @@ var ts;
|
|
|
154104
154196
|
});
|
|
154105
154197
|
}
|
|
154106
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
|
+
}
|
|
154107
154208
|
if (ts.isBinaryExpression(insertionSite)) {
|
|
154108
154209
|
for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
|
|
154109
154210
|
var side = _a[_i];
|
|
@@ -169459,12 +169560,14 @@ var ts;
|
|
|
169459
169560
|
return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
|
|
169460
169561
|
}
|
|
169461
169562
|
function organizeImports(args, formatOptions, preferences) {
|
|
169563
|
+
var _a;
|
|
169462
169564
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
169463
169565
|
synchronizeHostData();
|
|
169464
169566
|
ts.Debug.assert(args.type === "file");
|
|
169465
169567
|
var sourceFile = getValidSourceFile(args.fileName);
|
|
169466
169568
|
var formatContext = ts.formatting.getFormatContext(formatOptions, host);
|
|
169467
|
-
|
|
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);
|
|
169468
169571
|
}
|
|
169469
169572
|
function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
|
|
169470
169573
|
if (preferences === void 0) { preferences = ts.emptyOptions; }
|
|
@@ -172044,6 +172147,12 @@ var ts;
|
|
|
172044
172147
|
CommandTypes["ProvideInlayHints"] = "provideInlayHints";
|
|
172045
172148
|
// NOTE: If updating this, be sure to also update `allCommandNames` in `testRunner/unittests/tsserver/session.ts`.
|
|
172046
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 = {}));
|
|
172047
172156
|
var WatchFileKind;
|
|
172048
172157
|
(function (WatchFileKind) {
|
|
172049
172158
|
WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval";
|
|
@@ -181207,11 +181316,12 @@ var ts;
|
|
|
181207
181316
|
}
|
|
181208
181317
|
};
|
|
181209
181318
|
Session.prototype.organizeImports = function (args, simplifiedResult) {
|
|
181319
|
+
var _a;
|
|
181210
181320
|
ts.Debug.assert(args.scope.type === "file");
|
|
181211
|
-
var
|
|
181321
|
+
var _b = this.getFileAndProject(args.scope.args), file = _b.file, project = _b.project;
|
|
181212
181322
|
var changes = project.getLanguageService().organizeImports({
|
|
181213
181323
|
fileName: file,
|
|
181214
|
-
|
|
181324
|
+
mode: (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : undefined),
|
|
181215
181325
|
type: "file",
|
|
181216
181326
|
}, this.getFormatOptions(file), this.getPreferences(file));
|
|
181217
181327
|
if (simplifiedResult) {
|