@typescript-deploys/pr-build 4.6.0-pr-47552-4 → 4.6.0-pr-47548-5

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/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220122";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220124";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -9661,8 +9661,6 @@ var ts;
9661
9661
  Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
9662
9662
  Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
9663
9663
  Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
9664
- Remove_type_from_import_declaration_from_0: diag(90055, ts.DiagnosticCategory.Message, "Remove_type_from_import_declaration_from_0_90055", "Remove 'type' from import declaration from \"{0}\""),
9665
- Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
9666
9664
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9667
9665
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9668
9666
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -47703,6 +47701,7 @@ var ts;
47703
47701
  var globalBooleanType;
47704
47702
  var globalRegExpType;
47705
47703
  var globalThisType;
47704
+ var globalYieldType;
47706
47705
  var anyArrayType;
47707
47706
  var autoArrayType;
47708
47707
  var anyReadonlyArrayType;
@@ -70795,6 +70794,14 @@ var ts;
70795
70794
  return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
70796
70795
  });
70797
70796
  }
70797
+ function getYieldTypeArgument(type) {
70798
+ return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalYieldType ? getTypeArguments(type)[0] : undefined;
70799
+ }
70800
+ function getYieldTypeFromContextualType(type) {
70801
+ return mapType(type, function (t) {
70802
+ return t.flags & 2097152 /* Intersection */ ? ts.forEach(t.types, getYieldTypeArgument) : getYieldTypeArgument(t);
70803
+ });
70804
+ }
70798
70805
  function getContextualThisParameterType(func) {
70799
70806
  if (func.kind === 213 /* ArrowFunction */) {
70800
70807
  return undefined;
@@ -77738,6 +77745,10 @@ var ts;
77738
77745
  return getIterationTypeOfIterable(use, 1 /* Return */, yieldExpressionType, node.expression)
77739
77746
  || anyType;
77740
77747
  }
77748
+ var suggestedReturnType = yieldedType && getYieldTypeFromContextualType(yieldedType);
77749
+ if (suggestedReturnType) {
77750
+ return suggestedReturnType;
77751
+ }
77741
77752
  else if (returnType) {
77742
77753
  return getIterationTypeOfGeneratorFunctionReturnType(2 /* Next */, returnType, isAsync)
77743
77754
  || anyType;
@@ -85676,6 +85687,7 @@ var ts;
85676
85687
  globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", /*arity*/ 1) || globalArrayType;
85677
85688
  anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
85678
85689
  globalThisType = getGlobalTypeOrUndefined("ThisType", /*arity*/ 1);
85690
+ globalYieldType = getGlobalTypeOrUndefined("YieldType", /*arity*/ 1);
85679
85691
  if (augmentations) {
85680
85692
  // merge _nonglobal_ module augmentations.
85681
85693
  // this needs to be done after global symbol table is initialized to make sure that all ambient modules are indexed
@@ -129573,8 +129585,6 @@ var ts;
129573
129585
  CompletionSource["ThisProperty"] = "ThisProperty/";
129574
129586
  /** Auto-import that comes attached to a class member snippet */
129575
129587
  CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
129576
- /** A type-only import that needs to be promoted in order to be used at the completion location */
129577
- CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
129578
129588
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
129579
129589
  var SymbolOriginInfoKind;
129580
129590
  (function (SymbolOriginInfoKind) {
@@ -129584,7 +129594,6 @@ var ts;
129584
129594
  SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
129585
129595
  SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
129586
129596
  SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
129587
- SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
129588
129597
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
129589
129598
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
129590
129599
  })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
@@ -129612,9 +129621,6 @@ var ts;
129612
129621
  function originIsNullableMember(origin) {
129613
129622
  return !!(origin.kind & 16 /* Nullable */);
129614
129623
  }
129615
- function originIsTypeOnlyAlias(origin) {
129616
- return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
129617
- }
129618
129624
  var KeywordCompletionFilters;
129619
129625
  (function (KeywordCompletionFilters) {
129620
129626
  KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
@@ -130019,9 +130025,6 @@ var ts;
130019
130025
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
130020
130026
  }
130021
130027
  }
130022
- if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
130023
- hasAction = true;
130024
- }
130025
130028
  if (preferences.includeCompletionsWithClassMemberSnippets &&
130026
130029
  preferences.includeCompletionsWithInsertText &&
130027
130030
  completionKind === 3 /* MemberLike */ &&
@@ -130366,9 +130369,6 @@ var ts;
130366
130369
  if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
130367
130370
  return CompletionSource.ThisProperty;
130368
130371
  }
130369
- if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
130370
- return CompletionSource.TypeOnlyAlias;
130371
- }
130372
130372
  }
130373
130373
  function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
130374
130374
  var _a;
@@ -130396,7 +130396,7 @@ var ts;
130396
130396
  continue;
130397
130397
  }
130398
130398
  /** True for locals; false for globals, module exports from other files, `this.` completions. */
130399
- var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
130399
+ var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
130400
130400
  uniques.set(name, shouldShadowLaterSymbols);
130401
130401
  ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
130402
130402
  }
@@ -130409,7 +130409,6 @@ var ts;
130409
130409
  add: function (name) { return uniques.set(name, true); },
130410
130410
  };
130411
130411
  function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
130412
- var allFlags = symbol.flags;
130413
130412
  if (!ts.isSourceFile(location)) {
130414
130413
  // export = /**/ here we want to get all meanings, so any symbol is ok
130415
130414
  if (ts.isExportAssignment(location.parent)) {
@@ -130435,10 +130434,11 @@ var ts;
130435
130434
  || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
130436
130435
  return false;
130437
130436
  }
130438
- allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
130437
+ // Continue with origin symbol
130438
+ symbol = symbolOrigin;
130439
130439
  // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
130440
130440
  if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
130441
- return !!(allFlags & 1920 /* Namespace */);
130441
+ return !!(symbol.flags & 1920 /* Namespace */);
130442
130442
  }
130443
130443
  if (isTypeOnlyLocation) {
130444
130444
  // It's a type, but you can reach it by namespace.type as well
@@ -130446,7 +130446,7 @@ var ts;
130446
130446
  }
130447
130447
  }
130448
130448
  // expressions are value space (which includes the value namespaces)
130449
- return !!(allFlags & 111551 /* Value */);
130449
+ return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */);
130450
130450
  }
130451
130451
  }
130452
130452
  Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
@@ -130599,11 +130599,6 @@ var ts;
130599
130599
  };
130600
130600
  }
130601
130601
  }
130602
- if (originIsTypeOnlyAlias(origin)) {
130603
- var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
130604
- ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
130605
- return { codeActions: [codeAction_1], sourceDisplay: undefined };
130606
- }
130607
130602
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
130608
130603
  return { codeActions: undefined, sourceDisplay: undefined };
130609
130604
  }
@@ -131280,29 +131275,21 @@ var ts;
131280
131275
  var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
131281
131276
  isInSnippetScope = isSnippetScope(scopeNode);
131282
131277
  var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
131283
- var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
131284
131278
  symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
131285
131279
  ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
131286
- for (var i = 0; i < symbols.length; i++) {
131287
- var symbol = symbols[i];
131280
+ for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
131281
+ var symbol = symbols_1[_i];
131288
131282
  if (!typeChecker.isArgumentsSymbol(symbol) &&
131289
131283
  !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
131290
131284
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
131291
131285
  }
131292
- if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
131293
- var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
131294
- if (typeOnlyAliasDeclaration) {
131295
- var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
131296
- symbolToOriginInfoMap[i] = origin;
131297
- }
131298
- }
131299
131286
  }
131300
131287
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
131301
131288
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
131302
131289
  var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
131303
131290
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
131304
- for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
131305
- var symbol = _a[_i];
131291
+ for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
131292
+ var symbol = _b[_a];
131306
131293
  symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
131307
131294
  symbols.push(symbol);
131308
131295
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
@@ -132701,14 +132688,10 @@ var ts;
132701
132688
  /** True if symbol is a type or a module containing at least one type. */
132702
132689
  function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
132703
132690
  if (seenModules === void 0) { seenModules = new ts.Map(); }
132704
- // Since an alias can be merged with a local declaration, we need to test both the alias and its target.
132705
- // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
132706
- return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
132707
- function nonAliasCanBeReferencedAtTypeLocation(symbol) {
132708
- return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
132709
- !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
132710
- checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132711
- }
132691
+ var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker);
132692
+ return !!(sym.flags & 788968 /* Type */) || checker.isUnknownSymbol(sym) ||
132693
+ !!(sym.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(sym)) &&
132694
+ checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132712
132695
  }
132713
132696
  function isDeprecated(symbol, checker) {
132714
132697
  var declarations = ts.skipAlias(symbol, checker).declarations;
@@ -134962,8 +134945,8 @@ var ts;
134962
134945
  var sourceId = ts.getNodeId(sourceFile);
134963
134946
  var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
134964
134947
  var anyNewSymbols = false;
134965
- for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
134966
- var sym = symbols_1[_i];
134948
+ for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
134949
+ var sym = symbols_2[_i];
134967
134950
  anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
134968
134951
  }
134969
134952
  return anyNewSymbols;
@@ -145815,7 +145798,6 @@ var ts;
145815
145798
  ChangeTracker.prototype.delete = function (sourceFile, node) {
145816
145799
  this.deletedNodes.push({ sourceFile: sourceFile, node: node });
145817
145800
  };
145818
- /** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
145819
145801
  ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
145820
145802
  if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
145821
145803
  this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
@@ -146219,15 +146201,6 @@ var ts;
146219
146201
  ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
146220
146202
  this.insertText(sourceFile, node.getStart(sourceFile), "export ");
146221
146203
  };
146222
- ChangeTracker.prototype.insertImportSpecifierAtIndex = function (sourceFile, importSpecifier, namedImports, index) {
146223
- var prevSpecifier = namedImports.elements[index - 1];
146224
- if (prevSpecifier) {
146225
- this.insertNodeInListAfter(sourceFile, prevSpecifier, importSpecifier);
146226
- }
146227
- else {
146228
- this.insertNodeBefore(sourceFile, namedImports.elements[0], importSpecifier, !ts.positionsAreOnSameLine(namedImports.elements[0].getStart(), namedImports.parent.parent.getStart(), sourceFile));
146229
- }
146230
- };
146231
146204
  /**
146232
146205
  * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
146233
146206
  * i.e. arguments in arguments lists, parameters in parameter lists etc.
@@ -149730,8 +149703,7 @@ var ts;
149730
149703
  ts.Diagnostics.Cannot_find_namespace_0.code,
149731
149704
  ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
149732
149705
  ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
149733
- ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
149734
- ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
149706
+ ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
149735
149707
  ];
149736
149708
  codefix.registerCodeFix({
149737
149709
  errorCodes: errorCodes,
@@ -149836,9 +149808,6 @@ var ts;
149836
149808
  }
149837
149809
  break;
149838
149810
  }
149839
- case 4 /* PromoteTypeOnly */:
149840
- // Excluding from fix-all
149841
- break;
149842
149811
  default:
149843
149812
  ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
149844
149813
  }
@@ -149930,7 +149899,6 @@ var ts;
149930
149899
  ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
149931
149900
  ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
149932
149901
  ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
149933
- ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
149934
149902
  })(ImportFixKind || (ImportFixKind = {}));
149935
149903
  // These should not be combined as bitflags, but are given powers of 2 values to
149936
149904
  // easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
@@ -149956,13 +149924,6 @@ var ts;
149956
149924
  };
149957
149925
  }
149958
149926
  codefix.getImportCompletionAction = getImportCompletionAction;
149959
- function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
149960
- var compilerOptions = program.getCompilerOptions();
149961
- var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
149962
- var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
149963
- return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
149964
- }
149965
- codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
149966
149927
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
149967
149928
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
149968
149929
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
@@ -150243,18 +150204,9 @@ var ts;
150243
150204
  }
150244
150205
  function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
150245
150206
  var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
150246
- if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
150247
- return getFixesInfoForUMDImport(context, symbolToken);
150248
- }
150249
- if (!ts.isIdentifier(symbolToken)) {
150250
- return undefined;
150251
- }
150252
- if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
150253
- var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
150254
- var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
150255
- return fix && { fixes: [fix], symbolName: symbolName_1 };
150256
- }
150257
- var info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
150207
+ var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
150208
+ ? getFixesInfoForUMDImport(context, symbolToken)
150209
+ : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined;
150258
150210
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
150259
150211
  return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
150260
150212
  }
@@ -150378,16 +150330,6 @@ var ts;
150378
150330
  }));
150379
150331
  return { fixes: fixes, symbolName: symbolName };
150380
150332
  }
150381
- function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
150382
- var checker = program.getTypeChecker();
150383
- var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
150384
- if (!symbol)
150385
- return undefined;
150386
- var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
150387
- if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
150388
- return undefined;
150389
- return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
150390
- }
150391
150333
  function jsxModeNeedsExplicitImport(jsx) {
150392
150334
  return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
150393
150335
  }
@@ -150395,18 +150337,12 @@ var ts;
150395
150337
  var parent = symbolToken.parent;
150396
150338
  if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
150397
150339
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
150398
- if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
150340
+ if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
150399
150341
  return jsxNamespace;
150400
150342
  }
150401
150343
  }
150402
150344
  return symbolToken.text;
150403
150345
  }
150404
- function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
150405
- if (ts.isIntrinsicJsxName(symbolToken.text))
150406
- return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
150407
- var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
150408
- return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
150409
- }
150410
150346
  // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
150411
150347
  function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
150412
150348
  var _a;
@@ -150505,80 +150441,10 @@ var ts;
150505
150441
  ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
150506
150442
  return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
150507
150443
  }
150508
- case 4 /* PromoteTypeOnly */: {
150509
- var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
150510
- var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
150511
- return promotedDeclaration.kind === 269 /* ImportSpecifier */
150512
- ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
150513
- : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
150514
- }
150515
150444
  default:
150516
150445
  return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
150517
150446
  }
150518
150447
  }
150519
- function getModuleSpecifierText(promotedDeclaration) {
150520
- var _a, _b;
150521
- return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
150522
- ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText()
150523
- : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
150524
- }
150525
- function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceFile) {
150526
- // See comment in `doAddExistingFix` on constant with the same name.
150527
- var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
150528
- switch (aliasDeclaration.kind) {
150529
- case 269 /* ImportSpecifier */:
150530
- if (aliasDeclaration.isTypeOnly) {
150531
- if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
150532
- changes.delete(sourceFile, aliasDeclaration);
150533
- var newSpecifier = ts.factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name);
150534
- var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier);
150535
- changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
150536
- }
150537
- else {
150538
- changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
150539
- }
150540
- return aliasDeclaration;
150541
- }
150542
- else {
150543
- ts.Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
150544
- promoteImportClause(aliasDeclaration.parent.parent);
150545
- return aliasDeclaration.parent.parent;
150546
- }
150547
- case 266 /* ImportClause */:
150548
- promoteImportClause(aliasDeclaration);
150549
- return aliasDeclaration;
150550
- case 267 /* NamespaceImport */:
150551
- promoteImportClause(aliasDeclaration.parent);
150552
- return aliasDeclaration.parent;
150553
- case 264 /* ImportEqualsDeclaration */:
150554
- changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
150555
- return aliasDeclaration;
150556
- default:
150557
- ts.Debug.failBadSyntaxKind(aliasDeclaration);
150558
- }
150559
- function promoteImportClause(importClause) {
150560
- changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
150561
- if (convertExistingToTypeOnly) {
150562
- var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
150563
- if (namedImports && namedImports.elements.length > 1) {
150564
- if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
150565
- aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
150566
- namedImports.elements.indexOf(aliasDeclaration) !== 0) {
150567
- // The import specifier being promoted will be the only non-type-only,
150568
- // import in the NamedImports, so it should be moved to the front.
150569
- changes.delete(sourceFile, aliasDeclaration);
150570
- changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
150571
- }
150572
- for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
150573
- var element = _a[_i];
150574
- if (element !== aliasDeclaration && !element.isTypeOnly) {
150575
- changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
150576
- }
150577
- }
150578
- }
150579
- }
150580
- }
150581
- }
150582
150448
  function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
150583
150449
  var _a;
150584
150450
  if (clause.kind === 200 /* ObjectBindingPattern */) {
@@ -150616,7 +150482,13 @@ var ts;
150616
150482
  var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
150617
150483
  ? 0
150618
150484
  : ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
150619
- changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
150485
+ var prevSpecifier = clause.namedBindings.elements[insertionIndex - 1];
150486
+ if (prevSpecifier) {
150487
+ changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
150488
+ }
150489
+ else {
150490
+ changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
150491
+ }
150620
150492
  }
150621
150493
  }
150622
150494
  else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
@@ -1720,23 +1720,19 @@ declare namespace ts {
1720
1720
  readonly parent: ImportClause & {
1721
1721
  readonly isTypeOnly: true;
1722
1722
  };
1723
- } | ImportSpecifier & ({
1724
- readonly isTypeOnly: true;
1725
- } | {
1723
+ } | ImportSpecifier & {
1726
1724
  readonly parent: NamedImports & {
1727
1725
  readonly parent: ImportClause & {
1728
1726
  readonly isTypeOnly: true;
1729
1727
  };
1730
1728
  };
1731
- }) | ExportSpecifier & ({
1732
- readonly isTypeOnly: true;
1733
- } | {
1729
+ } | ExportSpecifier & {
1734
1730
  readonly parent: NamedExports & {
1735
1731
  readonly parent: ExportDeclaration & {
1736
1732
  readonly isTypeOnly: true;
1737
1733
  };
1738
1734
  };
1739
- });
1735
+ };
1740
1736
  /**
1741
1737
  * This is either an `export =` or an `export default` declaration.
1742
1738
  * Unless `isExportEquals` is set, this node was parsed as an `export default`.