mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Type-only auto imports (#36412)
* WIP * Promote existing type-only imports to regular if needed * Add completions test adding to type-only import * Update tests, revert whole-import-clause replacement codefix strategy to preserve import specifier formatting * Revert unnecessary changes * Delete unused function * }
This commit is contained in:
@@ -1879,12 +1879,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkSymbolUsageInExpressionContext(symbol: Symbol, name: __String, useSite: Node) {
|
||||
if (
|
||||
!(useSite.flags & NodeFlags.Ambient) &&
|
||||
!isPartOfTypeQuery(useSite) &&
|
||||
!isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite) &&
|
||||
isExpressionNode(useSite)
|
||||
) {
|
||||
if (!isValidTypeOnlyAliasUseSite(useSite)) {
|
||||
const typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
|
||||
if (typeOnlyDeclaration) {
|
||||
const message = typeOnlyDeclaration.kind === SyntaxKind.ExportSpecifier
|
||||
|
||||
@@ -6134,4 +6134,11 @@ namespace ts {
|
||||
export function pseudoBigIntToString({negative, base10Value}: PseudoBigInt): string {
|
||||
return (negative && base10Value !== "0" ? "-" : "") + base10Value;
|
||||
}
|
||||
|
||||
export function isValidTypeOnlyAliasUseSite(useSite: Node): boolean {
|
||||
return !!(useSite.flags & NodeFlags.Ambient)
|
||||
|| isPartOfTypeQuery(useSite)
|
||||
|| isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
|
||||
|| !isExpressionNode(useSite);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user