Skip to content

'const enum' conflict with 'importsNotUsedAsValue'' #36003

@ajafff

Description

@ajafff

TypeScript Version: 3.8.0-dev.20200104

Search Terms:

Code

// @importsNotUsedAsValue: true

// @filename: a.ts
export const enum E {
  One,
  Two,
}

// @filename: b.ts
import type {E} from './a';

export let v = E.One;

Expected behavior:

No error.

Actual behavior:

Type-only import causes Enum 'E' cannot be used as a value because only its type has been imported.ts(1362)
Since importing const enums at runtime is not necessary due to inlining, they should be allowed to be used with type-only import.

If I use a regular import, I get This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValue' is set to 'error'.ts(1371)

Related Issues: Introduced by @andrewbranch in #35200

Metadata

Metadata

Assignees

No one assigned

    Labels

    In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions