Skip to content

[BUG]: Enum传入数组,无法正确返回字典key的提示 #8

@mudoo

Description

@mudoo

Description

如MD文档示例数组字典,键入PetTypes.时,无法正确提示dog | cat | rabbit属性,但是输出结果是对的

const PetTypes = Enum([
  { value: 1, key: "dog", label: "狗" },
  { value: 2, key: "cat", label: "猫" },
  { value: 3, key: "rabbit", label: "兔子" },
] as const);

console.log(PetTypes.cat) // 输出 2,但是TS无法正确推导key属性

Steps to Reproduce

键入PetTypes.

Current Behavior

IDE无法正确提示dog | cat | rabbit

Expected Behavior

IDE可提示dog | cat | rabbit

How to Fix

No response

enum-plus version

2.3.1

Operating System

Please select

Environment

Please select

Environment Version

Node.js v20

Web Framework

I'm not using a framework

Web Framework Version

No response

Additional Context

No response

Code of Conduct

  • I have tested this issue with the latest version of enum-plus
  • I have searched existing issues and confirmed this is not a duplicate
  • I have included all the information needed to reproduce this bug
  • I have removed any sensitive information (personal data, access tokens, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: ConfirmedThe issue has been confirmedStatus: DoneThe issue has been resolvedbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions