Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Bug: [consistent-type-imports] Using with isolatedModules and emitDecoratorMetadata #5468

Copy link
Copy link
Closed
@HaoboZ

Description

@HaoboZ
Issue body actions

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

https://typescript-eslint.io/play/#ts=4.7.4&sourceType=module&code=JYWwDg9gTgLgBDAnmApnA3nA0ixcC+cAZlBCHAORQoCGAxjBQNwBQLAJinQDY3XEBXAHYNgEIXAAiXaDRjQAFGFKpYiAHI0QKAPwAuOAGcYUYEIDmASgMAFPlpQwUUaXVnyorFigAekWHCcRDQC3PA8NIaGcAAqKMYYbHBwkYgigiIKLMnJAAKu7oqWcGD2IAY4iNlwxejVydQwAlASpVBarMn4bN1AA&eslintrc=N4KABGBECmAeAu0B2ATAzpAXGA2uCUADgDYCuA5gJZKYAC8AnodGgMYBOlh8AtC8dXgB6dtFYB7ALaTkKaCkj4AugBp8kQgEN2aaOyxR6TFhy69+goVp17IaiBu272AeW6VxSDNlAEi7cQArMXgDSAA6IXg2TwAzSnJwwLRPRQgAX3siMiovAzw-SCNmNk5uPjQBJFDlLMh2UmIWA18CIsYS03KLaqEJL0o0RGqeDugeSklCcXZo-PxCgHdtJDsFgla-B0JRWNtsSDGJqZm59Yz1pXx0kHSgA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEk8sAJgK4YVTolHoAeekANOBqRkJWKgCGedAwCyjFhzZ5MTdIJrt4yPABF0cTFNiZZ6PBIZSJy1eqG0eiLMnjoiF1PsPHMZSipqQgC+IMFAA

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

{
	"compilerOptions": {
		"module"                : "esnext",
		"isolatedModules"       : true,
		"emitDecoratorMetadata" : true,
		"experimentalDecorators": true
	}
}

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

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workinglocked due to agePlease 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.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.