-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Should I explicitly separate "import" and "import type" statements? #39861
Comments
Ideally one goes for - |
The intention is for you not to use If you don’t have a specific need for type-only imports, you could consider them a stylistic choice. My personal suggestion for how to consider that stylistic choice is
|
Thanks, @andrewbranch, great to hear the author's intent first-hand 👍 I'd argue that the second presented option is actually the best one; |
Those each have different meanings and you should use the one corresponding to the behavior you want to have happen. |
Where can i read more about the different meaning between |
@chribjel Above all, the
… applies to both
… the |
@parzhitsky That is what i assumed, just got confused when Ryan said the three imports had different meaning. If you only have ONE imported type they have the same "meaning", or at least ends up meaning the same thing. |
Not under // index.ts
import type { Thing } from "things-1";
import { type Thing } from "things-2"; becomes // index.js
import {} from "things-2"; |
A.S.: This is an opinion-based question, I cannot ask such on StackOverflow
I've been using the
import type
statement for a while now, and I wonder, what was the intended use-case for it:import
, designed to be used in the case when only type information is actually used, i.e. fallback?I always thought of
import type
as "import for types", the first option, so the code always looked like this:import type { Type } from "some-module"; + import { value } from "some-module";
… but auto-import in VSCode suggests it is actually the second, fallback-ish:
Now, I understand that both will work correctly, and it is basically a matter of stylistic choice for the team, but the authors' original intention is important for me, and I'm a sole developer in this case
The text was updated successfully, but these errors were encountered: