-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
📚 noUndeclaredDependencies
and useImportType
report issues with output from TypeScript code actions
#50
Comments
I have to take some time to write a complete answer. However, as a preliminary answer for |
@Conaclos I moved this issue here, but maybe I made a mistake. What do we need to do to address the issue and close it? |
We could add a note in the docs of Regarding |
@chrisgrieser Could you share with us your current tsconfig file that allows to use import relative to the project root? This will help us to document this. |
@Conaclos tbh, part of the reason why I opened this issue was because I wasn't totally sure on what all the configs are, that you need to change to make biome "compatible" with typescript. And I have to admit that for now, I have simply disabled the respective biome rules 🙈 |
After some research, I think we are using the legacy |
I think the import specifier is controlled by this option. Maybe we should add it to the document? This is an LSP option: |
Documentation URL
https://biomejs.dev/linter/rules/use-import-restrictions/
Description
Using typescript code actions
Add missing imports
results in code that is reported by biome. I am using the default typescript language server settings.While I think the first can be resolved by changing the typescript configuration to
importModuleSpecifierPreference = relative
(see here),I am not aware of any typescript setting to deal with the latter.(preferTypeOnlyAutoImports
does that, see comment below)Expectations
That a recommended rule (
useImportType
) reports output of typescript as an issue is quite irritating, and probably very confusing for less experienced users.You could argue that this is somewhat a bug of those rules, but technically, the rules work as expected. Possible solutions to this:
A) Change the documentation
However, 2. is complicated by the fact that there is (to my knowledge) no typescript setting to make typescript add type imports instead of imports.(preferTypeOnlyAutoImports
does that, as commented below)Also, changing typescript configs is not always straightforward. Since tsserver is not "fully" open, users with an editor other than VSCode need to install special language server replacements to be able to configure the
typescript.preferences
, e.g. typescript tools.That means: Quite a lot of effort to be able to comply with biome for new users.
B) Change rule behavior
Alternatively, the rule's behavior should be modified to be less strict.
noUndeclaredDependencies
could be modified to check if an import is simply project-relative, before reporting a violation.Not sure how to deal with
useImportType
though. I'd consider demoting it from a recommended to a purely opt-in rule.Code of Conduct
The text was updated successfully, but these errors were encountered: