@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/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-insiders.20220929");
112
+ ts.version = "".concat(ts.versionMajorMinor, ".0-insiders.20221003");
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -11378,7 +11378,7 @@ var ts;
11378
11378
  return -1;
11379
11379
  }
11380
11380
  function peekExtendedUnicodeEscape() {
11381
- if (languageVersion >= 2 /* ScriptTarget.ES2015 */ && codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
11381
+ if (codePointAt(text, pos + 1) === 117 /* CharacterCodes.u */ && codePointAt(text, pos + 2) === 123 /* CharacterCodes.openBrace */) {
11382
11382
  var start_2 = pos;
11383
11383
  pos += 3;
11384
11384
  var escapedValueString = scanMinimumNumberOfHexDigits(1, /*canHaveSeparators*/ false);
@@ -23159,7 +23159,7 @@ var ts;
23159
23159
  return node;
23160
23160
  }
23161
23161
  // @api
23162
- function createIdentifier(text, typeArguments, originalKeywordKind) {
23162
+ function createIdentifier(text, typeArguments, originalKeywordKind, hasExtendedUnicodeEscape) {
23163
23163
  var node = createBaseIdentifier(text, originalKeywordKind);
23164
23164
  if (typeArguments) {
23165
23165
  // NOTE: we do not use `setChildren` here because typeArguments in an identifier do not contribute to transformations
@@ -23168,6 +23168,10 @@ var ts;
23168
23168
  if (node.originalKeywordKind === 133 /* SyntaxKind.AwaitKeyword */) {
23169
23169
  node.transformFlags |= 67108864 /* TransformFlags.ContainsPossibleTopLevelAwait */;
23170
23170
  }
23171
+ if (hasExtendedUnicodeEscape) {
23172
+ node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
23173
+ node.transformFlags |= 1024 /* TransformFlags.ContainsES2015 */;
23174
+ }
23171
23175
  return node;
23172
23176
  }
23173
23177
  // @api
@@ -33102,8 +33106,9 @@ var ts;
33102
33106
  // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker
33103
33107
  var originalKeywordKind = token();
33104
33108
  var text = internIdentifier(scanner.getTokenValue());
33109
+ var hasExtendedUnicodeEscape = scanner.hasExtendedUnicodeEscape();
33105
33110
  nextTokenWithoutCheck();
33106
- return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind), pos);
33111
+ return finishNode(factory.createIdentifier(text, /*typeArguments*/ undefined, originalKeywordKind, hasExtendedUnicodeEscape), pos);
33107
33112
  }
33108
33113
  if (token() === 80 /* SyntaxKind.PrivateIdentifier */) {
33109
33114
  parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
@@ -49498,6 +49503,12 @@ var ts;
49498
49503
  getOptionalType: function () { return optionalType; },
49499
49504
  getPromiseType: function () { return getGlobalPromiseType(/*reportErrors*/ false); },
49500
49505
  getPromiseLikeType: function () { return getGlobalPromiseLikeType(/*reportErrors*/ false); },
49506
+ getAsyncIterableType: function () {
49507
+ var type = getGlobalAsyncIterableType(/*reportErrors*/ false);
49508
+ if (type === emptyGenericType)
49509
+ return undefined;
49510
+ return type;
49511
+ },
49501
49512
  isSymbolAccessible: isSymbolAccessible,
49502
49513
  isArrayType: isArrayType,
49503
49514
  isTupleType: isTupleType,
@@ -50335,9 +50346,9 @@ var ts;
50335
50346
  return symbol;
50336
50347
  }
50337
50348
  if (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
50338
- var target = resolveAlias(symbol);
50339
- // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors
50340
- if (target === unknownSymbol || target.flags & meaning) {
50349
+ var targetFlags = getAllSymbolFlags(symbol);
50350
+ // `targetFlags` will be `SymbolFlags.All` if an error occurred in alias resolution; this avoids cascading errors
50351
+ if (targetFlags & meaning) {
50341
50352
  return symbol;
50342
50353
  }
50343
50354
  }
@@ -50970,8 +50981,8 @@ var ts;
50970
50981
  !checkAndReportErrorForExtendingInterface(errorLocation) &&
50971
50982
  !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
50972
50983
  !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
50984
+ !checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) &&
50973
50985
  !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
50974
- !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
50975
50986
  !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
50976
50987
  var suggestion = void 0;
50977
50988
  var suggestedLib = void 0;
@@ -51058,7 +51069,7 @@ var ts;
51058
51069
  }
51059
51070
  }
51060
51071
  if (result && errorLocation && meaning & 111551 /* SymbolFlags.Value */ && result.flags & 2097152 /* SymbolFlags.Alias */ && !(result.flags & 111551 /* SymbolFlags.Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
51061
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
51072
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result, 111551 /* SymbolFlags.Value */);
51062
51073
  if (typeOnlyDeclaration) {
51063
51074
  var message = typeOnlyDeclaration.kind === 278 /* SyntaxKind.ExportSpecifier */
51064
51075
  ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
@@ -51221,7 +51232,7 @@ var ts;
51221
51232
  return false;
51222
51233
  }
51223
51234
  function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
51224
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */)) {
51235
+ if (meaning & 111551 /* SymbolFlags.Value */) {
51225
51236
  if (isPrimitiveTypeName(name)) {
51226
51237
  if (isExtendedByInterface(errorLocation)) {
51227
51238
  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));
@@ -51232,7 +51243,8 @@ var ts;
51232
51243
  return true;
51233
51244
  }
51234
51245
  var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51235
- if (symbol && !(symbol.flags & 1024 /* SymbolFlags.NamespaceModule */)) {
51246
+ var allFlags = symbol && getAllSymbolFlags(symbol);
51247
+ if (symbol && allFlags !== undefined && !(allFlags & 111551 /* SymbolFlags.Value */)) {
51236
51248
  var rawName = ts.unescapeLeadingUnderscores(name);
51237
51249
  if (isES2015OrLaterConstructorName(name)) {
51238
51250
  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);
@@ -51280,16 +51292,16 @@ var ts;
51280
51292
  }
51281
51293
  return false;
51282
51294
  }
51283
- function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
51284
- if (meaning & (111551 /* SymbolFlags.Value */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~788968 /* SymbolFlags.Type */)) {
51285
- var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51295
+ function checkAndReportErrorForUsingNamespaceAsTypeOrValue(errorLocation, name, meaning) {
51296
+ if (meaning & (111551 /* SymbolFlags.Value */ & ~788968 /* SymbolFlags.Type */)) {
51297
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* SymbolFlags.NamespaceModule */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51286
51298
  if (symbol) {
51287
51299
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
51288
51300
  return true;
51289
51301
  }
51290
51302
  }
51291
- else if (meaning & (788968 /* SymbolFlags.Type */ & ~1024 /* SymbolFlags.NamespaceModule */ & ~111551 /* SymbolFlags.Value */)) {
51292
- var symbol = resolveSymbol(resolveName(errorLocation, name, (512 /* SymbolFlags.ValueModule */ | 1024 /* SymbolFlags.NamespaceModule */) & ~788968 /* SymbolFlags.Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51303
+ else if (meaning & (788968 /* SymbolFlags.Type */ & ~111551 /* SymbolFlags.Value */)) {
51304
+ var symbol = resolveSymbol(resolveName(errorLocation, name, 1536 /* SymbolFlags.Module */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false));
51293
51305
  if (symbol) {
51294
51306
  error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
51295
51307
  return true;
@@ -51879,6 +51891,52 @@ var ts;
51879
51891
  }
51880
51892
  return undefined;
51881
51893
  }
51894
+ /**
51895
+ * Gets combined flags of a `symbol` and all alias targets it resolves to. `resolveAlias`
51896
+ * is typically recursive over chains of aliases, but stops mid-chain if an alias is merged
51897
+ * with another exported symbol, e.g.
51898
+ * ```ts
51899
+ * // a.ts
51900
+ * export const a = 0;
51901
+ * // b.ts
51902
+ * export { a } from "./a";
51903
+ * export type a = number;
51904
+ * // c.ts
51905
+ * import { a } from "./b";
51906
+ * ```
51907
+ * Calling `resolveAlias` on the `a` in c.ts would stop at the merged symbol exported
51908
+ * from b.ts, even though there is still more alias to resolve. Consequently, if we were
51909
+ * trying to determine if the `a` in c.ts has a value meaning, looking at the flags on
51910
+ * the local symbol and on the symbol returned by `resolveAlias` is not enough.
51911
+ * @returns SymbolFlags.All if `symbol` is an alias that ultimately resolves to `unknown`;
51912
+ * combined flags of all alias targets otherwise.
51913
+ */
51914
+ function getAllSymbolFlags(symbol) {
51915
+ var flags = symbol.flags;
51916
+ var seenSymbols;
51917
+ while (symbol.flags & 2097152 /* SymbolFlags.Alias */) {
51918
+ var target = resolveAlias(symbol);
51919
+ if (target === unknownSymbol) {
51920
+ return 67108863 /* SymbolFlags.All */;
51921
+ }
51922
+ // Optimizations - try to avoid creating or adding to
51923
+ // `seenSymbols` if possible
51924
+ if (target === symbol || (seenSymbols === null || seenSymbols === void 0 ? void 0 : seenSymbols.has(target))) {
51925
+ break;
51926
+ }
51927
+ if (target.flags & 2097152 /* SymbolFlags.Alias */) {
51928
+ if (seenSymbols) {
51929
+ seenSymbols.add(target);
51930
+ }
51931
+ else {
51932
+ seenSymbols = new ts.Set([symbol, target]);
51933
+ }
51934
+ }
51935
+ flags |= target.flags;
51936
+ symbol = target;
51937
+ }
51938
+ return flags;
51939
+ }
51882
51940
  /**
51883
51941
  * Marks a symbol as type-only if its declaration is syntactically type-only.
51884
51942
  * If it is not itself marked type-only, but resolves to a type-only alias
@@ -51924,19 +51982,25 @@ var ts;
51924
51982
  return !!aliasDeclarationLinks.typeOnlyDeclaration;
51925
51983
  }
51926
51984
  /** Indicates that a symbol directly or indirectly resolves to a type-only import or export. */
51927
- function getTypeOnlyAliasDeclaration(symbol) {
51985
+ function getTypeOnlyAliasDeclaration(symbol, include) {
51928
51986
  if (!(symbol.flags & 2097152 /* SymbolFlags.Alias */)) {
51929
51987
  return undefined;
51930
51988
  }
51931
51989
  var links = getSymbolLinks(symbol);
51932
- return links.typeOnlyDeclaration || undefined;
51990
+ if (include === undefined) {
51991
+ return links.typeOnlyDeclaration || undefined;
51992
+ }
51993
+ if (links.typeOnlyDeclaration) {
51994
+ return getAllSymbolFlags(resolveAlias(links.typeOnlyDeclaration.symbol)) & include ? links.typeOnlyDeclaration : undefined;
51995
+ }
51996
+ return undefined;
51933
51997
  }
51934
51998
  function markExportAsReferenced(node) {
51935
51999
  var symbol = getSymbolOfNode(node);
51936
52000
  var target = resolveAlias(symbol);
51937
52001
  if (target) {
51938
52002
  var markAlias = target === unknownSymbol ||
51939
- ((target.flags & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
52003
+ ((getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */));
51940
52004
  if (markAlias) {
51941
52005
  markAliasSymbolAsReferenced(symbol);
51942
52006
  }
@@ -51956,8 +52020,7 @@ var ts;
51956
52020
  // This way a chain of imports can be elided if ultimately the final input is only used in a type
51957
52021
  // position.
51958
52022
  if (ts.isInternalModuleImportEqualsDeclaration(node)) {
51959
- var target = resolveSymbol(symbol);
51960
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
52023
+ if (getAllSymbolFlags(resolveSymbol(symbol)) & 111551 /* SymbolFlags.Value */) {
51961
52024
  // import foo = <symbol>
51962
52025
  checkExpressionCached(node.moduleReference);
51963
52026
  }
@@ -52779,7 +52842,7 @@ var ts;
52779
52842
  }
52780
52843
  function symbolIsValue(symbol, includeTypeOnlyMembers) {
52781
52844
  return !!(symbol.flags & 111551 /* SymbolFlags.Value */ ||
52782
- symbol.flags & 2097152 /* SymbolFlags.Alias */ && resolveAlias(symbol).flags & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52845
+ symbol.flags & 2097152 /* SymbolFlags.Alias */ && getAllSymbolFlags(symbol) & 111551 /* SymbolFlags.Value */ && (includeTypeOnlyMembers || !getTypeOnlyAliasDeclaration(symbol)));
52783
52846
  }
52784
52847
  function findConstructorDeclaration(node) {
52785
52848
  var members = node.members;
@@ -53048,8 +53111,10 @@ var ts;
53048
53111
  return true;
53049
53112
  }
53050
53113
  // Qualify if the symbol from symbol table has same meaning as expected
53051
- symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53052
- if (symbolFromSymbolTable.flags & meaning) {
53114
+ var shouldResolveAlias = (symbolFromSymbolTable.flags & 2097152 /* SymbolFlags.Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 278 /* SyntaxKind.ExportSpecifier */));
53115
+ symbolFromSymbolTable = shouldResolveAlias ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
53116
+ var flags = shouldResolveAlias ? getAllSymbolFlags(symbolFromSymbolTable) : symbolFromSymbolTable.flags;
53117
+ if (flags & meaning) {
53053
53118
  qualify = true;
53054
53119
  return true;
53055
53120
  }
@@ -55706,7 +55771,7 @@ var ts;
55706
55771
  return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
55707
55772
  }
55708
55773
  function isTypeOnlyNamespace(symbol) {
55709
- return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* SymbolFlags.Value */); });
55774
+ return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(getAllSymbolFlags(resolveSymbol(m)) & 111551 /* SymbolFlags.Value */); });
55710
55775
  }
55711
55776
  function serializeModule(symbol, symbolName, modifierFlags) {
55712
55777
  var members = getNamespaceMembersForSerialization(symbol);
@@ -57620,32 +57685,16 @@ var ts;
57620
57685
  return getTypeFromTypeNode(typeNode);
57621
57686
  }
57622
57687
  }
57623
- function isParameterOfContextSensitiveSignature(symbol) {
57624
- var decl = symbol.valueDeclaration;
57625
- if (!decl) {
57626
- return false;
57627
- }
57628
- if (ts.isBindingElement(decl)) {
57629
- decl = ts.walkUpBindingElementsAndPatterns(decl);
57630
- }
57631
- if (ts.isParameter(decl)) {
57632
- return isContextSensitiveFunctionOrObjectLiteralMethod(decl.parent);
57633
- }
57634
- return false;
57635
- }
57636
57688
  function getTypeOfVariableOrParameterOrProperty(symbol) {
57637
57689
  var links = getSymbolLinks(symbol);
57638
57690
  if (!links.type) {
57639
57691
  var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
57640
57692
  // For a contextually typed parameter it is possible that a type has already
57641
57693
  // been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
57642
- // to preserve this type. In fact, we need to _prefer_ that type, but it won't
57643
- // be assigned until contextual typing is complete, so we need to defer in
57644
- // cases where contextual typing may take place.
57645
- if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
57694
+ // to preserve this type.
57695
+ if (!links.type) {
57646
57696
  links.type = type;
57647
57697
  }
57648
- return type;
57649
57698
  }
57650
57699
  return links.type;
57651
57700
  }
@@ -57942,7 +57991,7 @@ var ts;
57942
57991
  links.type = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.declarations) && isDuplicatedCommonJSExport(exportSymbol.declarations) && symbol.declarations.length ? getFlowTypeFromCommonJSExport(exportSymbol)
57943
57992
  : isDuplicatedCommonJSExport(symbol.declarations) ? autoType
57944
57993
  : declaredType ? declaredType
57945
- : targetSymbol.flags & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
57994
+ : getAllSymbolFlags(targetSymbol) & 111551 /* SymbolFlags.Value */ ? getTypeOfSymbol(targetSymbol)
57946
57995
  : errorType;
57947
57996
  }
57948
57997
  return links.type;
@@ -60295,7 +60344,7 @@ var ts;
60295
60344
  var indexTypes;
60296
60345
  var isUnion = containingType.flags & 1048576 /* TypeFlags.Union */;
60297
60346
  // Flags we want to propagate to the result if they exist in all source symbols
60298
- var optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */;
60347
+ var optionalFlag;
60299
60348
  var syntheticFlag = 4 /* CheckFlags.SyntheticMethod */;
60300
60349
  var checkFlags = isUnion ? 0 : 8 /* CheckFlags.Readonly */;
60301
60350
  var mergedInstantiations = false;
@@ -60306,11 +60355,14 @@ var ts;
60306
60355
  var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
60307
60356
  var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
60308
60357
  if (prop) {
60309
- if (isUnion) {
60310
- optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60311
- }
60312
- else {
60313
- optionalFlag &= prop.flags;
60358
+ if (prop.flags & 106500 /* SymbolFlags.ClassMember */) {
60359
+ optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : (optionalFlag = isUnion ? 0 /* SymbolFlags.None */ : 16777216 /* SymbolFlags.Optional */);
60360
+ if (isUnion) {
60361
+ optionalFlag |= (prop.flags & 16777216 /* SymbolFlags.Optional */);
60362
+ }
60363
+ else {
60364
+ optionalFlag &= prop.flags;
60365
+ }
60314
60366
  }
60315
60367
  if (!singleProp) {
60316
60368
  singleProp = prop;
@@ -60429,7 +60481,7 @@ var ts;
60429
60481
  propTypes.push(type);
60430
60482
  }
60431
60483
  ts.addRange(propTypes, indexTypes);
60432
- var result = createSymbol(4 /* SymbolFlags.Property */ | optionalFlag, name, syntheticFlag | checkFlags);
60484
+ var result = createSymbol(4 /* SymbolFlags.Property */ | (optionalFlag !== null && optionalFlag !== void 0 ? optionalFlag : 0), name, syntheticFlag | checkFlags);
60433
60485
  result.containingType = containingType;
60434
60486
  if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
60435
60487
  result.valueDeclaration = firstValueDeclaration;
@@ -67696,7 +67748,7 @@ var ts;
67696
67748
  return 0 /* Ternary.False */;
67697
67749
  }
67698
67750
  // When checking for comparability, be more lenient with optional properties.
67699
- if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67751
+ if (!skipOptional && sourceProp.flags & 16777216 /* SymbolFlags.Optional */ && targetProp.flags & 106500 /* SymbolFlags.ClassMember */ && !(targetProp.flags & 16777216 /* SymbolFlags.Optional */)) {
67700
67752
  // TypeScript 1.0 spec (April 2014): 3.8.3
67701
67753
  // S is a subtype of a type T, and T is a supertype of S if ...
67702
67754
  // S' and T are object types and, for each member M in T..
@@ -72968,9 +73020,9 @@ var ts;
72968
73020
  });
72969
73021
  }
72970
73022
  function markAliasReferenced(symbol, location) {
72971
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
73023
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
72972
73024
  var target = resolveAlias(symbol);
72973
- if (target.flags & 111551 /* SymbolFlags.Value */) {
73025
+ if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
72974
73026
  // An alias resolving to a const enum cannot be elided if (1) 'isolatedModules' is enabled
72975
73027
  // (because the const enum value will not be inlined), or if (2) the alias is an export
72976
73028
  // of a const enum declaration that will be preserved.
@@ -74386,9 +74438,10 @@ var ts;
74386
74438
  function instantiateContextualType(contextualType, node, contextFlags) {
74387
74439
  if (contextualType && maybeTypeOfKind(contextualType, 465829888 /* TypeFlags.Instantiable */)) {
74388
74440
  var inferenceContext = getInferenceContext(node);
74389
- // If no inferences have been made, nothing is gained from instantiating as type parameters
74390
- // would just be replaced with their defaults similar to the apparent type.
74391
- if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
74441
+ // If no inferences have been made, and none of the type parameters for which we are inferring
74442
+ // specify default types, nothing is gained from instantiating as type parameters would just be
74443
+ // replaced with their constraints similar to the apparent type.
74444
+ if (inferenceContext && contextFlags & 1 /* ContextFlags.Signature */ && ts.some(inferenceContext.inferences, hasInferenceCandidatesOrDefault)) {
74392
74445
  // For contextual signatures we incorporate all inferences made so far, e.g. from return
74393
74446
  // types as well as arguments to the left in a function call.
74394
74447
  return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
@@ -78862,7 +78915,7 @@ var ts;
78862
78915
  if (symbol && symbol.flags & 2097152 /* SymbolFlags.Alias */) {
78863
78916
  symbol = resolveAlias(symbol);
78864
78917
  }
78865
- return !!(symbol && (symbol.flags & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
78918
+ return !!(symbol && (getAllSymbolFlags(symbol) & 384 /* SymbolFlags.Enum */) && getEnumKind(symbol) === 1 /* EnumKind.Literal */);
78866
78919
  }
78867
78920
  return false;
78868
78921
  }
@@ -81236,6 +81289,9 @@ var ts;
81236
81289
  function hasInferenceCandidates(info) {
81237
81290
  return !!(info.candidates || info.contraCandidates);
81238
81291
  }
81292
+ function hasInferenceCandidatesOrDefault(info) {
81293
+ return !!(info.candidates || info.contraCandidates || hasTypeParameterDefault(info.typeParameter));
81294
+ }
81239
81295
  function hasOverlappingInferences(a, b) {
81240
81296
  for (var i = 0; i < a.length; i++) {
81241
81297
  if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
@@ -85037,7 +85093,16 @@ var ts;
85037
85093
  var message = allowAsyncIterables
85038
85094
  ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
85039
85095
  : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
85040
- return errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
85096
+ var suggestAwait =
85097
+ // for (const x of Promise<...>) or [...Promise<...>]
85098
+ !!getAwaitedTypeOfPromise(type)
85099
+ // for (const x of AsyncIterable<...>)
85100
+ || (!allowAsyncIterables &&
85101
+ ts.isForOfStatement(errorNode.parent) &&
85102
+ errorNode.parent.expression === errorNode &&
85103
+ getGlobalAsyncIterableType(/** reportErrors */ false) !== emptyGenericType &&
85104
+ isTypeAssignableTo(type, getGlobalAsyncIterableType(/** reportErrors */ false)));
85105
+ return errorAndMaybeSuggestAwait(errorNode, suggestAwait, message, typeToString(type));
85041
85106
  }
85042
85107
  /**
85043
85108
  * Gets the *yield*, *return*, and *next* types from an `Iterator`-like or `AsyncIterator`-like type.
@@ -86888,10 +86953,11 @@ var ts;
86888
86953
  }
86889
86954
  return;
86890
86955
  }
86956
+ var targetFlags = getAllSymbolFlags(target);
86891
86957
  var excludedMeanings = (symbol.flags & (111551 /* SymbolFlags.Value */ | 1048576 /* SymbolFlags.ExportValue */) ? 111551 /* SymbolFlags.Value */ : 0) |
86892
86958
  (symbol.flags & 788968 /* SymbolFlags.Type */ ? 788968 /* SymbolFlags.Type */ : 0) |
86893
86959
  (symbol.flags & 1920 /* SymbolFlags.Namespace */ ? 1920 /* SymbolFlags.Namespace */ : 0);
86894
- if (target.flags & excludedMeanings) {
86960
+ if (targetFlags & excludedMeanings) {
86895
86961
  var message = node.kind === 278 /* SyntaxKind.ExportSpecifier */ ?
86896
86962
  ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
86897
86963
  ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
@@ -86901,7 +86967,7 @@ var ts;
86901
86967
  && !ts.isTypeOnlyImportOrExportDeclaration(node)
86902
86968
  && !(node.flags & 16777216 /* NodeFlags.Ambient */)) {
86903
86969
  var typeOnlyAlias = getTypeOnlyAliasDeclaration(symbol);
86904
- var isType = !(target.flags & 111551 /* SymbolFlags.Value */);
86970
+ var isType = !(targetFlags & 111551 /* SymbolFlags.Value */);
86905
86971
  if (isType || typeOnlyAlias) {
86906
86972
  switch (node.kind) {
86907
86973
  case 270 /* SyntaxKind.ImportClause */:
@@ -87061,14 +87127,15 @@ var ts;
87061
87127
  if (node.moduleReference.kind !== 280 /* SyntaxKind.ExternalModuleReference */) {
87062
87128
  var target = resolveAlias(getSymbolOfNode(node));
87063
87129
  if (target !== unknownSymbol) {
87064
- if (target.flags & 111551 /* SymbolFlags.Value */) {
87130
+ var targetFlags = getAllSymbolFlags(target);
87131
+ if (targetFlags & 111551 /* SymbolFlags.Value */) {
87065
87132
  // Target is a value symbol, check that it is not hidden by a local declaration with the same name
87066
87133
  var moduleName = ts.getFirstIdentifier(node.moduleReference);
87067
87134
  if (!(resolveEntityName(moduleName, 111551 /* SymbolFlags.Value */ | 1920 /* SymbolFlags.Namespace */).flags & 1920 /* SymbolFlags.Namespace */)) {
87068
87135
  error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
87069
87136
  }
87070
87137
  }
87071
- if (target.flags & 788968 /* SymbolFlags.Type */) {
87138
+ if (targetFlags & 788968 /* SymbolFlags.Type */) {
87072
87139
  checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
87073
87140
  }
87074
87141
  }
@@ -87207,7 +87274,7 @@ var ts;
87207
87274
  markExportAsReferenced(node);
87208
87275
  }
87209
87276
  var target = symbol && (symbol.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(symbol) : symbol);
87210
- if (!target || target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87277
+ if (!target || getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87211
87278
  checkExpressionCached(node.propertyName || node.name);
87212
87279
  }
87213
87280
  }
@@ -87254,7 +87321,7 @@ var ts;
87254
87321
  markAliasReferenced(sym, id);
87255
87322
  // If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
87256
87323
  var target = sym.flags & 2097152 /* SymbolFlags.Alias */ ? resolveAlias(sym) : sym;
87257
- if (target === unknownSymbol || target.flags & 111551 /* SymbolFlags.Value */) {
87324
+ if (getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */) {
87258
87325
  // However if it is a value, we need to check it's being used correctly
87259
87326
  checkExpressionCached(node.expression);
87260
87327
  }
@@ -88576,7 +88643,7 @@ var ts;
88576
88643
  return symbolLinks.exportsSomeValue;
88577
88644
  function isValue(s) {
88578
88645
  s = resolveSymbol(s);
88579
- return s && !!(s.flags & 111551 /* SymbolFlags.Value */);
88646
+ return s && !!(getAllSymbolFlags(s) & 111551 /* SymbolFlags.Value */);
88580
88647
  }
88581
88648
  }
88582
88649
  function isNameOfModuleOrEnumDeclaration(node) {
@@ -88629,7 +88696,7 @@ var ts;
88629
88696
  var symbol = getReferencedValueOrAliasSymbol(node);
88630
88697
  // We should only get the declaration of an alias if there isn't a local value
88631
88698
  // declaration for the symbol
88632
- if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol)) {
88699
+ if (isNonLocalAlias(symbol, /*excludes*/ 111551 /* SymbolFlags.Value */) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */)) {
88633
88700
  return getDeclarationOfAliasSymbol(symbol);
88634
88701
  }
88635
88702
  }
@@ -88717,7 +88784,7 @@ var ts;
88717
88784
  case 273 /* SyntaxKind.ImportSpecifier */:
88718
88785
  case 278 /* SyntaxKind.ExportSpecifier */:
88719
88786
  var symbol = getSymbolOfNode(node);
88720
- return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
88787
+ return !!symbol && isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol, 111551 /* SymbolFlags.Value */);
88721
88788
  case 275 /* SyntaxKind.ExportDeclaration */:
88722
88789
  var exportClause = node.exportClause;
88723
88790
  return !!exportClause && (ts.isNamespaceExport(exportClause) ||
@@ -88739,6 +88806,7 @@ var ts;
88739
88806
  return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
88740
88807
  }
88741
88808
  function isAliasResolvedToValue(symbol) {
88809
+ var _a;
88742
88810
  if (!symbol) {
88743
88811
  return false;
88744
88812
  }
@@ -88748,7 +88816,7 @@ var ts;
88748
88816
  }
88749
88817
  // const enums and modules that contain only const enums are not considered values from the emit perspective
88750
88818
  // unless 'preserveConstEnums' option is set to true
88751
- return !!(target.flags & 111551 /* SymbolFlags.Value */) &&
88819
+ return !!(((_a = getAllSymbolFlags(target)) !== null && _a !== void 0 ? _a : -1) & 111551 /* SymbolFlags.Value */) &&
88752
88820
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
88753
88821
  }
88754
88822
  function isConstEnumOrConstEnumOnlyModule(s) {
@@ -88763,7 +88831,7 @@ var ts;
88763
88831
  }
88764
88832
  var target = getSymbolLinks(symbol).aliasTarget; // TODO: GH#18217
88765
88833
  if (target && ts.getEffectiveModifierFlags(node) & 1 /* ModifierFlags.Export */ &&
88766
- target.flags & 111551 /* SymbolFlags.Value */ &&
88834
+ getAllSymbolFlags(target) & 111551 /* SymbolFlags.Value */ &&
88767
88835
  (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
88768
88836
  // An `export import ... =` of a value symbol is always considered referenced
88769
88837
  return true;
@@ -101256,11 +101324,13 @@ var ts;
101256
101324
  return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
101257
101325
  }
101258
101326
  function visitIdentifier(node) {
101259
- if (!convertedLoopState) {
101260
- return node;
101327
+ if (convertedLoopState) {
101328
+ if (resolver.isArgumentsLocalBinding(node)) {
101329
+ return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
101330
+ }
101261
101331
  }
101262
- if (resolver.isArgumentsLocalBinding(node)) {
101263
- return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
101332
+ if (node.hasExtendedUnicodeEscape) {
101333
+ return ts.setOriginalNode(ts.setTextRange(factory.createIdentifier(ts.unescapeLeadingUnderscores(node.escapedText)), node), node);
101264
101334
  }
101265
101335
  return node;
101266
101336
  }
@@ -128800,6 +128870,12 @@ var ts;
128800
128870
  SemanticClassificationFormat["Original"] = "original";
128801
128871
  SemanticClassificationFormat["TwentyTwenty"] = "2020";
128802
128872
  })(SemanticClassificationFormat = ts.SemanticClassificationFormat || (ts.SemanticClassificationFormat = {}));
128873
+ var OrganizeImportsMode;
128874
+ (function (OrganizeImportsMode) {
128875
+ OrganizeImportsMode["All"] = "All";
128876
+ OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
128877
+ OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
128878
+ })(OrganizeImportsMode = ts.OrganizeImportsMode || (ts.OrganizeImportsMode = {}));
128803
128879
  var CompletionTriggerKind;
128804
128880
  (function (CompletionTriggerKind) {
128805
128881
  /** Completion was triggered by typing an identifier, manual invocation (e.g Ctrl+Space) or via API. */
@@ -144555,23 +144631,39 @@ var ts;
144555
144631
  * 2) Coalescing imports from the same module
144556
144632
  * 3) Sorting imports
144557
144633
  */
144558
- function organizeImports(sourceFile, formatContext, host, program, preferences, skipDestructiveCodeActions) {
144634
+ function organizeImports(sourceFile, formatContext, host, program, preferences, mode) {
144559
144635
  var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences });
144560
- var coalesceAndOrganizeImports = function (importGroup) { return ts.stableSort(coalesceImports(removeUnusedImports(importGroup, sourceFile, program, skipDestructiveCodeActions)), function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); }); };
144636
+ var shouldSort = mode === "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ || mode === "All" /* OrganizeImportsMode.All */;
144637
+ var shouldCombine = shouldSort; // These are currently inseparable, but I draw a distinction for clarity and in case we add modes in the future.
144638
+ var shouldRemove = mode === "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */ || mode === "All" /* OrganizeImportsMode.All */;
144639
+ var maybeRemove = shouldRemove ? removeUnusedImports : ts.identity;
144640
+ var maybeCoalesce = shouldCombine ? coalesceImports : ts.identity;
144641
+ var processImportsOfSameModuleSpecifier = function (importGroup) {
144642
+ var processedDeclarations = maybeCoalesce(maybeRemove(importGroup, sourceFile, program));
144643
+ return shouldSort
144644
+ ? ts.stableSort(processedDeclarations, function (s1, s2) { return compareImportsOrRequireStatements(s1, s2); })
144645
+ : processedDeclarations;
144646
+ };
144561
144647
  // All of the old ImportDeclarations in the file, in syntactic order.
144562
144648
  var topLevelImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, sourceFile.statements.filter(ts.isImportDeclaration));
144563
- topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
144564
- // All of the old ExportDeclarations in the file, in syntactic order.
144565
- var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
144566
- organizeImportsWorker(topLevelExportDecls, coalesceExports);
144649
+ topLevelImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
144650
+ // Exports are always used
144651
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
144652
+ // All of the old ExportDeclarations in the file, in syntactic order.
144653
+ var topLevelExportDecls = sourceFile.statements.filter(ts.isExportDeclaration);
144654
+ organizeImportsWorker(topLevelExportDecls, coalesceExports);
144655
+ }
144567
144656
  for (var _i = 0, _a = sourceFile.statements.filter(ts.isAmbientModule); _i < _a.length; _i++) {
144568
144657
  var ambientModule = _a[_i];
144569
144658
  if (!ambientModule.body)
144570
144659
  continue;
144571
144660
  var ambientModuleImportGroupDecls = groupImportsByNewlineContiguous(sourceFile, ambientModule.body.statements.filter(ts.isImportDeclaration));
144572
- ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, coalesceAndOrganizeImports); });
144573
- var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
144574
- organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
144661
+ ambientModuleImportGroupDecls.forEach(function (importGroupDecl) { return organizeImportsWorker(importGroupDecl, processImportsOfSameModuleSpecifier); });
144662
+ // Exports are always used
144663
+ if (mode !== "RemoveUnused" /* OrganizeImportsMode.RemoveUnused */) {
144664
+ var ambientModuleExportDecls = ambientModule.body.statements.filter(ts.isExportDeclaration);
144665
+ organizeImportsWorker(ambientModuleExportDecls, coalesceExports);
144666
+ }
144575
144667
  }
144576
144668
  return changeTracker.getChanges();
144577
144669
  function organizeImportsWorker(oldImportDecls, coalesce) {
@@ -144584,8 +144676,12 @@ var ts;
144584
144676
  // Consider: we could do a more careful check that this trivia is actually a header,
144585
144677
  // but the consequences of being wrong are very minor.
144586
144678
  ts.suppressLeadingTrivia(oldImportDecls[0]);
144587
- var oldImportGroups = ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); });
144588
- var sortedImportGroups = ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); });
144679
+ var oldImportGroups = shouldCombine
144680
+ ? ts.group(oldImportDecls, function (importDecl) { return getExternalModuleName(importDecl.moduleSpecifier); })
144681
+ : [oldImportDecls];
144682
+ var sortedImportGroups = shouldSort
144683
+ ? ts.stableSort(oldImportGroups, function (group1, group2) { return compareModuleSpecifiers(group1[0].moduleSpecifier, group2[0].moduleSpecifier); })
144684
+ : oldImportGroups;
144589
144685
  var newImportDecls = ts.flatMap(sortedImportGroups, function (importGroup) {
144590
144686
  return getExternalModuleName(importGroup[0].moduleSpecifier)
144591
144687
  ? coalesce(importGroup)
@@ -144649,11 +144745,7 @@ var ts;
144649
144745
  }
144650
144746
  return false;
144651
144747
  }
144652
- function removeUnusedImports(oldImports, sourceFile, program, skipDestructiveCodeActions) {
144653
- // As a precaution, consider unused import detection to be destructive (GH #43051)
144654
- if (skipDestructiveCodeActions) {
144655
- return oldImports;
144656
- }
144748
+ function removeUnusedImports(oldImports, sourceFile, program) {
144657
144749
  var typeChecker = program.getTypeChecker();
144658
144750
  var compilerOptions = program.getCompilerOptions();
144659
144751
  var jsxNamespace = typeChecker.getJsxNamespace(sourceFile);
@@ -153686,6 +153778,15 @@ var ts;
153686
153778
  });
153687
153779
  }
153688
153780
  function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) {
153781
+ if (ts.isForOfStatement(insertionSite.parent) && !insertionSite.parent.awaitModifier) {
153782
+ var exprType = checker.getTypeAtLocation(insertionSite);
153783
+ var asyncIter = checker.getAsyncIterableType();
153784
+ if (asyncIter && checker.isTypeAssignableTo(exprType, asyncIter)) {
153785
+ var forOf = insertionSite.parent;
153786
+ changeTracker.replaceNode(sourceFile, forOf, ts.factory.updateForOfStatement(forOf, ts.factory.createToken(133 /* SyntaxKind.AwaitKeyword */), forOf.initializer, forOf.expression, forOf.statement));
153787
+ return;
153788
+ }
153789
+ }
153689
153790
  if (ts.isBinaryExpression(insertionSite)) {
153690
153791
  for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) {
153691
153792
  var side = _a[_i];
@@ -169041,12 +169142,14 @@ var ts;
169041
169142
  return ts.codefix.getAllFixes({ fixId: fixId, sourceFile: sourceFile, program: program, host: host, cancellationToken: cancellationToken, formatContext: formatContext, preferences: preferences });
169042
169143
  }
169043
169144
  function organizeImports(args, formatOptions, preferences) {
169145
+ var _a;
169044
169146
  if (preferences === void 0) { preferences = ts.emptyOptions; }
169045
169147
  synchronizeHostData();
169046
169148
  ts.Debug.assert(args.type === "file");
169047
169149
  var sourceFile = getValidSourceFile(args.fileName);
169048
169150
  var formatContext = ts.formatting.getFormatContext(formatOptions, host);
169049
- return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, args.skipDestructiveCodeActions);
169151
+ var mode = (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : "All" /* OrganizeImportsMode.All */);
169152
+ return ts.OrganizeImports.organizeImports(sourceFile, formatContext, host, program, preferences, mode);
169050
169153
  }
169051
169154
  function getEditsForFileRename(oldFilePath, newFilePath, formatOptions, preferences) {
169052
169155
  if (preferences === void 0) { preferences = ts.emptyOptions; }
@@ -172045,6 +172148,12 @@ var ts;
172045
172148
  CommandTypes["ProvideInlayHints"] = "provideInlayHints";
172046
172149
  // NOTE: If updating this, be sure to also update `allCommandNames` in `testRunner/unittests/tsserver/session.ts`.
172047
172150
  })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {}));
172151
+ var OrganizeImportsMode;
172152
+ (function (OrganizeImportsMode) {
172153
+ OrganizeImportsMode["All"] = "All";
172154
+ OrganizeImportsMode["SortAndCombine"] = "SortAndCombine";
172155
+ OrganizeImportsMode["RemoveUnused"] = "RemoveUnused";
172156
+ })(OrganizeImportsMode = protocol.OrganizeImportsMode || (protocol.OrganizeImportsMode = {}));
172048
172157
  var WatchFileKind;
172049
172158
  (function (WatchFileKind) {
172050
172159
  WatchFileKind["FixedPollingInterval"] = "FixedPollingInterval";
@@ -181208,11 +181317,12 @@ var ts;
181208
181317
  }
181209
181318
  };
181210
181319
  Session.prototype.organizeImports = function (args, simplifiedResult) {
181320
+ var _a;
181211
181321
  ts.Debug.assert(args.scope.type === "file");
181212
- var _a = this.getFileAndProject(args.scope.args), file = _a.file, project = _a.project;
181322
+ var _b = this.getFileAndProject(args.scope.args), file = _b.file, project = _b.project;
181213
181323
  var changes = project.getLanguageService().organizeImports({
181214
181324
  fileName: file,
181215
- skipDestructiveCodeActions: args.skipDestructiveCodeActions,
181325
+ mode: (_a = args.mode) !== null && _a !== void 0 ? _a : (args.skipDestructiveCodeActions ? "SortAndCombine" /* OrganizeImportsMode.SortAndCombine */ : undefined),
181216
181326
  type: "file",
181217
181327
  }, this.getFormatOptions(file), this.getPreferences(file));
181218
181328
  if (simplifiedResult) {