Closed
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
import type { Key } from 'react';
declare function Decorator( propertyName?: string ): ParameterDecorator;
export default class Test {
async func(
@Decorator() param: Key
) {
return param;
}
}
ESLint Config
{
"parser" : "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins" : [ "@typescript-eslint" ],
"rules" : {
"@typescript-eslint/consistent-type-imports": [ "warn", { "prefer": "type-imports" } ]
}
}
tsconfig
Expected Result
No errors showing for both the decorator and the type import
Actual Result
if you use import type, you get
ESLint: Type import "Key" is used by decorator metadata.(@typescript-eslint/consistent-type-imports)
while if you use just import, you get
TS1272: A type referenced in a decorated signature must be imported with 'import type' or a namespace import when 'isolatedModules' and 'emitDecoratorMetadata' are enabled.
Not sure if there's a better way to do this since isolatedModules must be set
Additional Info
This doesn't need complex setup, literally any type import will throw an error for this so I'm not sure if this needs reproduction repository
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
5.33.0 |
@typescript-eslint/parser |
5.33.0 |
TypeScript |
4.7.4 |
ESLint |
8.21.0 |
node |
16.5.0 |
Metadata
Metadata
Assignees
Labels
Go ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueSomething isn't workingSomething isn't workingPlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Issues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin