Skip to content
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

Request: option to let no-duplicates force type & normal imports to be de-duplicated #909

Open
TiddoLangerak opened this issue Aug 4, 2017 · 9 comments · May be fixed by #2229
Open

Request: option to let no-duplicates force type & normal imports to be de-duplicated #909

TiddoLangerak opened this issue Aug 4, 2017 · 9 comments · May be fixed by #2229

Comments

@TiddoLangerak
Copy link

#225 asked to allow both type & normal imports to be allowed together, e.g.

import {someFunction} from '../src/foo';
import type {someType} from '../src/foo';

This was requested because according to the author there was no way to merge these together at that point in time.

However, currently flow does support merging these imports together:

import { someFunction, type someType } from '../src/foo';

I think it would therefore be useful if no-duplicates could be configured to have the same behaviour as before #225, i.e. to require type & normal imports to be merged.

@sibelius
Copy link

this should be optional

@ljharb
Copy link
Member

ljharb commented Mar 14, 2018

I agree this should be controlled by an option.

@loyd
Copy link

loyd commented Jul 3, 2018

Some progress?

@ljharb
Copy link
Member

ljharb commented Jul 4, 2018

@loyd not til somebody submits a PR ¯\_(ツ)_/¯

@remcohaszing
Copy link
Contributor

Regular imports and type imports can be merged in TypeScript as well by the same logic. The difference with flow is that in TypeScript, the type imports will look like regular imports.

import {someFunction} from '../src/foo';
import type {someType} from '../src/foo';

becomes

import {someFunction, someType} from '../src/foo';

@SimenB
Copy link
Contributor

SimenB commented Aug 15, 2022

TypeScript 4.5 also supports inline type: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#type-modifiers-on-import-names

@ljharb
Copy link
Member

ljharb commented Aug 15, 2022

We'd probably have to detect TS version regardless to support that, and we may want it to be a separate option. Let's explore it in #2229.

@michal-niemiec-discovery

any progress in this?

@SimenB
Copy link
Contributor

SimenB commented Jan 26, 2023

I'd assume somebody picking up #2229 would be welcome, so I suggest starting there 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
7 participants