Enforce import type for type imports
See original GitHub issueFor the next major, we should enforce using the new import type
feature of TypeScript to import types everywhere. This will let babel drop import statements when only types are used from a file and result in smaller file size/better tree shaking.
To do this, we can add "importsNotUsedAsValues": "error"
in the tsconfig.json
and then fix all of the type errors (it’d be just changing import
to import type
).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:9 (9 by maintainers)
Top Results From Across the Web
consistent-type-imports | typescript-eslint
TypeScript allows specifying a type keyword on imports to indicate that the export exists only in the type system, not at runtime.
Read more >typescript-eslint/consistent-type-imports.md at main - GitHub
TypeScript allows specifying a type keyword on imports to indicate that the export exists only in the type system, not at runtime.
Read more >eslint - Is there a way to automatically fix `import type` errors ...
As the project grew, I decided it is a good idea in terms of optimization to enforce import type when an import is...
Read more >Documentation - TypeScript 3.8
import type only imports declarations to be used for type annotations and declarations. It always gets fully erased, so there's no remnant of...
Read more >Enforce @typescript-eslint/consistent-type-imports - Tuleap
Starting from TypeScript 3.8, new syntax import type and export type have been added. TypeScript analyses types for "the whole project" at ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@BatDroid try updating
@babel/core
andmetro-react-native-babel-preset
as well, and if it doesn’t work, try deletingyarn.lock
entirely.Feel free