Skip to content

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

Open
@brandongit2

Description

@brandongit2

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions