π Search Terms
"inline type specifiers", "preferTypeOnlyAutoImports"
β
Viability Checklist
β Suggestion
Preamble
I did check the "Design Goals" guideline from the checklist but have doubts towards this one item since import { type T } from ... and import type { T } from ... don't necessarily behave the same wrt/ bundlers
- Use a consistent, fully erasable, structural type system.
For reference, this issue was ported from typescript-language-server/typescript-language-server#1068
This issue is about providing more control over the user preference preferTypeOnlyAutoImports. I suppose instead of a boolean, it could also accept one of the 2 known styles (to my knowledge): top-level and inline. Though the next question becomes: what happens when a user configures inline and another import statement from the same location already exists in the file using the top-level syntax (and vice versa)
β
Use Case A
Auto-importing FooProps behaves as expected when a symbol is already imported from the same path
import { Foo, type FooProps } from 'foo';
β Use Case B
Current behavior auto-importing FooProps when no symbols are imported from the location yet
import type { FooProps } from 'foo';
Expected behavior
import { type FooProps } from 'foo';
π Motivating Example
See https://oxc.rs/docs/guide/usage/linter/rules/import/consistent-type-specifier-style.html
π» Use Cases
-
What do you want to use this for?
Have consistent import styles across the codebase
-
What shortcomings exist with current approaches?
Auto-importing uses the wrong style by default when importing from a then unused path which has to be fixed in order to pass the linter
-
What workarounds are you using in the meantime?
No workaround
π Search Terms
"inline type specifiers", "preferTypeOnlyAutoImports"
β Viability Checklist
β Suggestion
Preamble
I did check the "Design Goals" guideline from the checklist but have doubts towards this one item since
import { type T } from ...andimport type { T } from ...don't necessarily behave the same wrt/ bundlersFor reference, this issue was ported from typescript-language-server/typescript-language-server#1068
This issue is about providing more control over the user preference
preferTypeOnlyAutoImports. I suppose instead of a boolean, it could also accept one of the 2 known styles (to my knowledge):top-levelandinline. Though the next question becomes: what happens when a user configuresinlineand another import statement from the same location already exists in the file using thetop-levelsyntax (and vice versa)β Use Case A
Auto-importing
FooPropsbehaves as expected when a symbol is already imported from the same pathβ Use Case B
Current behavior auto-importing
FooPropswhen no symbols are imported from the location yetExpected behavior
π Motivating Example
See https://oxc.rs/docs/guide/usage/linter/rules/import/consistent-type-specifier-style.html
π» Use Cases
What do you want to use this for?
Have consistent import styles across the codebase
What shortcomings exist with current approaches?
Auto-importing uses the wrong style by default when importing from a then unused path which has to be fixed in order to pass the linter
What workarounds are you using in the meantime?
No workaround