Add user preference for preferring type-only auto imports#56090
Add user preference for preferring type-only auto imports#56090andrewbranch merged 2 commits intomainfrom
Conversation
jakebailey
left a comment
There was a problem hiding this comment.
Seems good to me, though I can't help but feel like we're going in circles a bit 😅
I guess anyone who actually wants to enforce this needs verbatimModuleSyntax and/or the two ts-eslint rules, and this at least helps the editor do the right thing, more or less exactly like my proposal for how we should better handle import sorting.
| compilerOptions.verbatimModuleSyntax && | ||
| (compilerOptions.verbatimModuleSyntax || preferences.preferTypeOnlyAutoImports) && |
There was a problem hiding this comment.
Can this use shouldUseTypeOnly somehow?
There was a problem hiding this comment.
The concern with verbatimModuleSyntax is slightly different, so I don’t think so
|
(of course note that the PR is failing, some missing baselines) |
|
Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page. Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up. |
|
This is amazing!! I will be updating my blog post on the topic: https://johnnyreilly.com/typescript-5-importsnotusedasvalues-error-eslint-consistent-type-imports I'll confess to being possibly unhealthily interested in being exact in the type (ha!) of my imports. Every time a type import is used, an angel gets their wings. |
Closes #55675
This makes the auto-imports behavior of
verbatimModuleSyntaxavailable as an editor preference, independent of compiler options. Stylistic preference for type-only imports has been a popular demand since the syntax was introduced, and compiler options which may or may not be appropriate for a user’s actual compilation have long been adopted for their side effects on auto-import behavior. This setting allows users to separate their stylistic preference from picking the right compiler options for their actual use case.