-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Domain: Auto-importWorking as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Milestone
Description
TypeScript Version: 4.0.0-dev.20200705
Search Terms: auto import type
Code
// tsconfig.json
{
"compilerOptions": {
"target": "es2019",
"module": "esnext",
"noEmit": true,
"allowJs": true,
"importsNotUsedAsValues": "error",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"maxNodeModuleJsDepth": 1
},
"include": ["src", "types"]
}
// secret.ts
export type Secret = number
export const secret: Secret = 42
// main.ts
import { secret } from './secret'
// type `: Secret` after `newSecret`, then tab to auto-import it
// the import is added with the existing import,
// instead of as a type-only on a new line
const newSecret = secret + 42
Expected behavior:
When auto-importing a type in a type-only place, with "importsNotUsedAsValues": "error"
, it should always add a type import
Actual behavior:
If there is an existing import for where the type is coming from, it'll add it to that import, instead of creating a new type-only import
Playground Link: Not applicable
Related Issues: Didn't see any
Metadata
Metadata
Assignees
Labels
Domain: Auto-importWorking as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug