@typescript-deploys/pr-build 4.6.0-pr-47550-2 → 4.6.0-pr-47552-4

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.
@@ -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.20220121";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220122";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -9661,6 +9661,8 @@ 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}\""),
9664
9666
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9665
9667
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9666
9668
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -33560,7 +33562,7 @@ var ts;
33560
33562
  function parseInitializer() {
33561
33563
  return parseOptional(63 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined;
33562
33564
  }
33563
- function parseAssignmentExpressionOrHigher(parsingConditionalTrueSide) {
33565
+ function parseAssignmentExpressionOrHigher() {
33564
33566
  // AssignmentExpression[in,yield]:
33565
33567
  // 1) ConditionalExpression[?in,?yield]
33566
33568
  // 2) LeftHandSideExpression = AssignmentExpression[?in,?yield]
@@ -33586,7 +33588,7 @@ var ts;
33586
33588
  // If we do successfully parse arrow-function, we must *not* recurse for productions 1, 2 or 3. An ArrowFunction is
33587
33589
  // not a LeftHandSideExpression, nor does it start a ConditionalExpression. So we are done
33588
33590
  // with AssignmentExpression if we see one.
33589
- var arrowExpression = tryParseParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) || tryParseAsyncSimpleArrowFunctionExpression();
33591
+ var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
33590
33592
  if (arrowExpression) {
33591
33593
  return arrowExpression;
33592
33594
  }
@@ -33605,7 +33607,7 @@ var ts;
33605
33607
  // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single
33606
33608
  // identifier and the current token is an arrow.
33607
33609
  if (expr.kind === 79 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) {
33608
- return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined, parsingConditionalTrueSide);
33610
+ return parseSimpleArrowFunctionExpression(pos, expr, /*asyncModifier*/ undefined);
33609
33611
  }
33610
33612
  // Now see if we might be in cases '2' or '3'.
33611
33613
  // If the expression was a LHS expression, and we have an assignment operator, then
@@ -33665,7 +33667,7 @@ var ts;
33665
33667
  return finishNode(factory.createYieldExpression(/*asteriskToken*/ undefined, /*expression*/ undefined), pos);
33666
33668
  }
33667
33669
  }
33668
- function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier, parsingConditionalTrueSide) {
33670
+ function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
33669
33671
  ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
33670
33672
  var parameter = factory.createParameterDeclaration(
33671
33673
  /*decorators*/ undefined,
@@ -33677,11 +33679,11 @@ var ts;
33677
33679
  finishNode(parameter, identifier.pos);
33678
33680
  var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
33679
33681
  var equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */);
33680
- var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier, parsingConditionalTrueSide);
33682
+ var body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier);
33681
33683
  var node = factory.createArrowFunction(asyncModifier, /*typeParameters*/ undefined, parameters, /*type*/ undefined, equalsGreaterThanToken, body);
33682
33684
  return addJSDocComment(finishNode(node, pos));
33683
33685
  }
33684
- function tryParseParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) {
33686
+ function tryParseParenthesizedArrowFunctionExpression() {
33685
33687
  var triState = isParenthesizedArrowFunctionExpression();
33686
33688
  if (triState === 0 /* False */) {
33687
33689
  // It's definitely not a parenthesized arrow function expression.
@@ -33692,8 +33694,8 @@ var ts;
33692
33694
  // it out, but don't allow any ambiguity, and return 'undefined' if this could be an
33693
33695
  // expression instead.
33694
33696
  return triState === 1 /* True */ ?
33695
- parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, parsingConditionalTrueSide) :
33696
- tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalTrueSide); });
33697
+ parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true) :
33698
+ tryParse(parsePossibleParenthesizedArrowFunctionExpression);
33697
33699
  }
33698
33700
  // True -> We definitely expect a parenthesized arrow function here.
33699
33701
  // False -> There *cannot* be a parenthesized arrow function here.
@@ -33823,25 +33825,25 @@ var ts;
33823
33825
  return 2 /* Unknown */;
33824
33826
  }
33825
33827
  }
33826
- function parsePossibleParenthesizedArrowFunctionExpression(parsingConditionalTrueSide) {
33828
+ function parsePossibleParenthesizedArrowFunctionExpression() {
33827
33829
  var tokenPos = scanner.getTokenPos();
33828
33830
  if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
33829
33831
  return undefined;
33830
33832
  }
33831
- var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false, parsingConditionalTrueSide);
33833
+ var result = parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ false);
33832
33834
  if (!result) {
33833
33835
  (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
33834
33836
  }
33835
33837
  return result;
33836
33838
  }
33837
- function tryParseAsyncSimpleArrowFunctionExpression(parsingConditionalTrueSide) {
33839
+ function tryParseAsyncSimpleArrowFunctionExpression() {
33838
33840
  // We do a check here so that we won't be doing unnecessarily call to "lookAhead"
33839
33841
  if (token() === 131 /* AsyncKeyword */) {
33840
33842
  if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) {
33841
33843
  var pos = getNodePos();
33842
33844
  var asyncModifier = parseModifiersForArrowFunction();
33843
33845
  var expr = parseBinaryExpressionOrHigher(0 /* Lowest */);
33844
- return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier, parsingConditionalTrueSide);
33846
+ return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
33845
33847
  }
33846
33848
  }
33847
33849
  return undefined;
@@ -33865,7 +33867,7 @@ var ts;
33865
33867
  }
33866
33868
  return 0 /* False */;
33867
33869
  }
33868
- function parseParenthesizedArrowFunctionExpression(allowAmbiguity, parsingConditionalTrueSide) {
33870
+ function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
33869
33871
  var pos = getNodePos();
33870
33872
  var hasJSDoc = hasPrecedingJSDocComment();
33871
33873
  var modifiers = parseModifiersForArrowFunction();
@@ -33891,18 +33893,6 @@ var ts;
33891
33893
  return undefined;
33892
33894
  }
33893
33895
  }
33894
- // Given:
33895
- // x ? y => ({ y }) : z => ({ z })
33896
- // We try to parse the body of the first arrow function by looking at:
33897
- // ({ y }) : z => ({ z })
33898
- // This is a valid arrow function with "z" as the return type.
33899
- //
33900
- // But, if we're in the true side of a conditional expression, this colon
33901
- // terminates the true side, so cannot be the return type.
33902
- if (parsingConditionalTrueSide && token() === 58 /* ColonToken */) {
33903
- ts.Debug.assert(!allowAmbiguity);
33904
- return undefined;
33905
- }
33906
33896
  var type = parseReturnType(58 /* ColonToken */, /*isType*/ false);
33907
33897
  if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
33908
33898
  return undefined;
@@ -33936,7 +33926,7 @@ var ts;
33936
33926
  var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
33937
33927
  return withJSDoc(finishNode(node, pos), hasJSDoc);
33938
33928
  }
33939
- function parseArrowFunctionExpressionBody(isAsync, parsingConditionalTrueSide) {
33929
+ function parseArrowFunctionExpressionBody(isAsync) {
33940
33930
  if (token() === 18 /* OpenBraceToken */) {
33941
33931
  return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */);
33942
33932
  }
@@ -33964,8 +33954,8 @@ var ts;
33964
33954
  var savedTopLevel = topLevel;
33965
33955
  topLevel = false;
33966
33956
  var node = isAsync
33967
- ? doInAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalTrueSide); })
33968
- : doOutsideOfAwaitContext(function () { return parseAssignmentExpressionOrHigher(parsingConditionalTrueSide); });
33957
+ ? doInAwaitContext(parseAssignmentExpressionOrHigher)
33958
+ : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
33969
33959
  topLevel = savedTopLevel;
33970
33960
  return node;
33971
33961
  }
@@ -33978,8 +33968,8 @@ var ts;
33978
33968
  // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
33979
33969
  // we do not that for the 'whenFalse' part.
33980
33970
  var colonToken;
33981
- return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*parsingConditionalTrueSide*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
33982
- ? parseAssignmentExpressionOrHigher(/*parsingConditionalTrueSide*/ false)
33971
+ return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
33972
+ ? parseAssignmentExpressionOrHigher()
33983
33973
  : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
33984
33974
  }
33985
33975
  function parseBinaryExpressionOrHigher(precedence) {
@@ -129583,6 +129573,8 @@ var ts;
129583
129573
  CompletionSource["ThisProperty"] = "ThisProperty/";
129584
129574
  /** Auto-import that comes attached to a class member snippet */
129585
129575
  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/";
129586
129578
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
129587
129579
  var SymbolOriginInfoKind;
129588
129580
  (function (SymbolOriginInfoKind) {
@@ -129592,6 +129584,7 @@ var ts;
129592
129584
  SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
129593
129585
  SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
129594
129586
  SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
129587
+ SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
129595
129588
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
129596
129589
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
129597
129590
  })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
@@ -129619,6 +129612,9 @@ var ts;
129619
129612
  function originIsNullableMember(origin) {
129620
129613
  return !!(origin.kind & 16 /* Nullable */);
129621
129614
  }
129615
+ function originIsTypeOnlyAlias(origin) {
129616
+ return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
129617
+ }
129622
129618
  var KeywordCompletionFilters;
129623
129619
  (function (KeywordCompletionFilters) {
129624
129620
  KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
@@ -130023,6 +130019,9 @@ var ts;
130023
130019
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
130024
130020
  }
130025
130021
  }
130022
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
130023
+ hasAction = true;
130024
+ }
130026
130025
  if (preferences.includeCompletionsWithClassMemberSnippets &&
130027
130026
  preferences.includeCompletionsWithInsertText &&
130028
130027
  completionKind === 3 /* MemberLike */ &&
@@ -130367,6 +130366,9 @@ var ts;
130367
130366
  if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
130368
130367
  return CompletionSource.ThisProperty;
130369
130368
  }
130369
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
130370
+ return CompletionSource.TypeOnlyAlias;
130371
+ }
130370
130372
  }
130371
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) {
130372
130374
  var _a;
@@ -130394,7 +130396,7 @@ var ts;
130394
130396
  continue;
130395
130397
  }
130396
130398
  /** True for locals; false for globals, module exports from other files, `this.` completions. */
130397
- var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
130399
+ var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
130398
130400
  uniques.set(name, shouldShadowLaterSymbols);
130399
130401
  ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
130400
130402
  }
@@ -130407,6 +130409,7 @@ var ts;
130407
130409
  add: function (name) { return uniques.set(name, true); },
130408
130410
  };
130409
130411
  function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
130412
+ var allFlags = symbol.flags;
130410
130413
  if (!ts.isSourceFile(location)) {
130411
130414
  // export = /**/ here we want to get all meanings, so any symbol is ok
130412
130415
  if (ts.isExportAssignment(location.parent)) {
@@ -130432,11 +130435,10 @@ var ts;
130432
130435
  || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
130433
130436
  return false;
130434
130437
  }
130435
- // Continue with origin symbol
130436
- symbol = symbolOrigin;
130438
+ allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
130437
130439
  // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
130438
130440
  if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
130439
- return !!(symbol.flags & 1920 /* Namespace */);
130441
+ return !!(allFlags & 1920 /* Namespace */);
130440
130442
  }
130441
130443
  if (isTypeOnlyLocation) {
130442
130444
  // It's a type, but you can reach it by namespace.type as well
@@ -130444,7 +130446,7 @@ var ts;
130444
130446
  }
130445
130447
  }
130446
130448
  // expressions are value space (which includes the value namespaces)
130447
- return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */);
130449
+ return !!(allFlags & 111551 /* Value */);
130448
130450
  }
130449
130451
  }
130450
130452
  Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
@@ -130597,6 +130599,11 @@ var ts;
130597
130599
  };
130598
130600
  }
130599
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
+ }
130600
130607
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
130601
130608
  return { codeActions: undefined, sourceDisplay: undefined };
130602
130609
  }
@@ -131273,21 +131280,29 @@ var ts;
131273
131280
  var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
131274
131281
  isInSnippetScope = isSnippetScope(scopeNode);
131275
131282
  var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
131283
+ var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
131276
131284
  symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
131277
131285
  ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
131278
- for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
131279
- var symbol = symbols_1[_i];
131286
+ for (var i = 0; i < symbols.length; i++) {
131287
+ var symbol = symbols[i];
131280
131288
  if (!typeChecker.isArgumentsSymbol(symbol) &&
131281
131289
  !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
131282
131290
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
131283
131291
  }
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
+ }
131284
131299
  }
131285
131300
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
131286
131301
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
131287
131302
  var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
131288
131303
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
131289
- for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
131290
- var symbol = _b[_a];
131304
+ for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
131305
+ var symbol = _a[_i];
131291
131306
  symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
131292
131307
  symbols.push(symbol);
131293
131308
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
@@ -132686,10 +132701,14 @@ var ts;
132686
132701
  /** True if symbol is a type or a module containing at least one type. */
132687
132702
  function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
132688
132703
  if (seenModules === void 0) { seenModules = new ts.Map(); }
132689
- var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker);
132690
- return !!(sym.flags & 788968 /* Type */) || checker.isUnknownSymbol(sym) ||
132691
- !!(sym.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(sym)) &&
132692
- checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
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
+ }
132693
132712
  }
132694
132713
  function isDeprecated(symbol, checker) {
132695
132714
  var declarations = ts.skipAlias(symbol, checker).declarations;
@@ -134943,8 +134962,8 @@ var ts;
134943
134962
  var sourceId = ts.getNodeId(sourceFile);
134944
134963
  var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
134945
134964
  var anyNewSymbols = false;
134946
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
134947
- var sym = symbols_2[_i];
134965
+ for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
134966
+ var sym = symbols_1[_i];
134948
134967
  anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
134949
134968
  }
134950
134969
  return anyNewSymbols;
@@ -145796,6 +145815,7 @@ var ts;
145796
145815
  ChangeTracker.prototype.delete = function (sourceFile, node) {
145797
145816
  this.deletedNodes.push({ sourceFile: sourceFile, node: node });
145798
145817
  };
145818
+ /** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
145799
145819
  ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
145800
145820
  if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
145801
145821
  this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
@@ -146199,6 +146219,15 @@ var ts;
146199
146219
  ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
146200
146220
  this.insertText(sourceFile, node.getStart(sourceFile), "export ");
146201
146221
  };
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
+ };
146202
146231
  /**
146203
146232
  * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
146204
146233
  * i.e. arguments in arguments lists, parameters in parameter lists etc.
@@ -149701,7 +149730,8 @@ var ts;
149701
149730
  ts.Diagnostics.Cannot_find_namespace_0.code,
149702
149731
  ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
149703
149732
  ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
149704
- ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.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,
149705
149735
  ];
149706
149736
  codefix.registerCodeFix({
149707
149737
  errorCodes: errorCodes,
@@ -149806,6 +149836,9 @@ var ts;
149806
149836
  }
149807
149837
  break;
149808
149838
  }
149839
+ case 4 /* PromoteTypeOnly */:
149840
+ // Excluding from fix-all
149841
+ break;
149809
149842
  default:
149810
149843
  ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
149811
149844
  }
@@ -149897,6 +149930,7 @@ var ts;
149897
149930
  ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
149898
149931
  ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
149899
149932
  ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
149933
+ ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
149900
149934
  })(ImportFixKind || (ImportFixKind = {}));
149901
149935
  // These should not be combined as bitflags, but are given powers of 2 values to
149902
149936
  // easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
@@ -149922,6 +149956,13 @@ var ts;
149922
149956
  };
149923
149957
  }
149924
149958
  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;
149925
149966
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
149926
149967
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
149927
149968
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
@@ -150202,9 +150243,18 @@ var ts;
150202
150243
  }
150203
150244
  function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
150204
150245
  var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
150205
- var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
150206
- ? getFixesInfoForUMDImport(context, symbolToken)
150207
- : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined;
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);
150208
150258
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
150209
150259
  return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
150210
150260
  }
@@ -150328,6 +150378,16 @@ var ts;
150328
150378
  }));
150329
150379
  return { fixes: fixes, symbolName: symbolName };
150330
150380
  }
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
+ }
150331
150391
  function jsxModeNeedsExplicitImport(jsx) {
150332
150392
  return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
150333
150393
  }
@@ -150335,12 +150395,18 @@ var ts;
150335
150395
  var parent = symbolToken.parent;
150336
150396
  if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
150337
150397
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
150338
- if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
150398
+ if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
150339
150399
  return jsxNamespace;
150340
150400
  }
150341
150401
  }
150342
150402
  return symbolToken.text;
150343
150403
  }
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
+ }
150344
150410
  // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
150345
150411
  function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
150346
150412
  var _a;
@@ -150439,10 +150505,80 @@ var ts;
150439
150505
  ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
150440
150506
  return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
150441
150507
  }
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
+ }
150442
150515
  default:
150443
150516
  return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
150444
150517
  }
150445
150518
  }
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
+ }
150446
150582
  function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
150447
150583
  var _a;
150448
150584
  if (clause.kind === 200 /* ObjectBindingPattern */) {
@@ -150480,13 +150616,7 @@ var ts;
150480
150616
  var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
150481
150617
  ? 0
150482
150618
  : ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
150483
- var prevSpecifier = clause.namedBindings.elements[insertionIndex - 1];
150484
- if (prevSpecifier) {
150485
- changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
150486
- }
150487
- else {
150488
- changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
150489
- }
150619
+ changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
150490
150620
  }
150491
150621
  }
150492
150622
  else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
@@ -1720,19 +1720,23 @@ declare namespace ts {
1720
1720
  readonly parent: ImportClause & {
1721
1721
  readonly isTypeOnly: true;
1722
1722
  };
1723
- } | ImportSpecifier & {
1723
+ } | ImportSpecifier & ({
1724
+ readonly isTypeOnly: true;
1725
+ } | {
1724
1726
  readonly parent: NamedImports & {
1725
1727
  readonly parent: ImportClause & {
1726
1728
  readonly isTypeOnly: true;
1727
1729
  };
1728
1730
  };
1729
- } | ExportSpecifier & {
1731
+ }) | ExportSpecifier & ({
1732
+ readonly isTypeOnly: true;
1733
+ } | {
1730
1734
  readonly parent: NamedExports & {
1731
1735
  readonly parent: ExportDeclaration & {
1732
1736
  readonly isTypeOnly: true;
1733
1737
  };
1734
1738
  };
1735
- };
1739
+ });
1736
1740
  /**
1737
1741
  * This is either an `export =` or an `export default` declaration.
1738
1742
  * Unless `isExportEquals` is set, this node was parsed as an `export default`.