Recently, I encountered an issue that was resolved by utilizing the import type
feature in TypeScript instead of just using import
. It came to my attention that there exists an eslint rule called
@typescript-eslint/consistent-type-imports
which, when activated, automatically replaces import
with import type
through eslint --fix
where necessary.
It appears that opting for import type
over import
whenever possible is quite logical. Supposedly, it allows for optimization during compilation and enhances code readability in certain situations without causing any adverse effects on existing code if applied correctly. In essence, it seems like a beneficial choice with no downsides.
However, I observed that the widely used eslint recommended configurations such as airbnb-typescript
or @typescript-eslint/recommended
do not include the
@typescript-eslint/consistent-type-imports
rule. This omission raises doubts about whether this rule might not be as advantageous as it initially appears.
Therefore, are there any potential risks associated with enabling the
@typescript-eslint/consistent-type-imports
rule within a project?