question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Separate import and import type

See original GitHub issue

With the new import type syntax in Typescript, I feel it would be better for that to be separated than treated the same as any other import currently.

For example, there should be a separation between the two with an empty line, whilst the current setup autofixes both of them together. 2021-08-31_02-26

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
lydellcommented, Aug 31, 2021

Hi! You can do this with Custom grouping:

Type imports have \u0000 appended to their from string (ends with \u0000). You can match them with "\\u0000$" – but you probably need more than that to avoid them also being matched by other groups.

Here are some examples:

https://github.com/lydell/eslint-plugin-simple-import-sort/blob/1f753fb3e5b8eadf6cf9fdda8790d01dd9eade26/examples/.eslintrc.js#L121-L222

1reaction
lydellcommented, Sep 4, 2021

My conclusion here is:

  • The defaults won’t change soon.
  • But feel free to open an issue about the defaults if you like, which could stay open for a long time to collect feedback from others.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Should I explicitly separate "import" and "import type ... - GitHub
Worst style: use import type as much as possible, separating values and types from the same module into separate import statements.
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 >
Do I need to use the "import type" feature of TypeScript 3.8 if ...
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 >
type-only imports — A new TypeScript feature that benefits ...
import type ... from — Lets the compiler know that what you're importing is definitely a type and is not needed (or wanted)...
Read more >
Import a Type from Another file using TypeScript | bobbyhadz
To import a type from another file in TypeScript: Export the type from file A , e.g. export type Employee = {} ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found