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

consistent-type-specifier-style: Add exception for resolution-mode import attributes #233

Open
brandongit2 opened this issue Feb 23, 2025 · 0 comments

Comments

@brandongit2
Copy link

brandongit2 commented Feb 23, 2025

In TypeScript, you can force a type import's module resolution to be either ESM or CJS with the following:

import type {Foo} from 'some-package' with {'resolution-mode': 'import'};

This is documented here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-3.html#stable-support-resolution-mode-in-import-types

However, TypeScript only allows this when the type is top-level. In other words, this gives a compiler error:

import {type Foo} from 'some-package' with {'resolution-mode': 'import'};
// ^ Error: `resolution-mode` can only be set for type-only imports.

This is a problem when import-x/consistent-type-specifier-style is set to prefer-inline. The rule option shouldn't warn in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant