File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed
Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 22
33# enum-plus Changelog
44
5+ ## Unreleased
6+
7+ 2025-10-??
8+
9+ ### Features
10+
11+ - ✨ Allow extending ` EnumItemLabel ` type for better type safety and IntelliSense support.
12+
513## 3.0.1
614
7152025-10-6
Original file line number Diff line number Diff line change @@ -16,13 +16,14 @@ declare module 'enum-plus/extension' {
1616 *
1717 * **CN:** 枚举本地化的全局扩展
1818 */
19+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
1920 interface EnumLocaleExtends {
2021 /**
2122 * **EN:** Key values of the localized text of the enumeration, which can be used to enhance the
2223 * intelligent prompt of the editor
2324 *
2425 * **CN:** 枚举本地化文本的Key值,可以用来增强编辑器的智能提示
2526 */
26- LocaleKeys : never ;
27+ // LocaleKeys: NonNullable<string> ;
2728 }
2829}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import type { EnumLocaleExtends } from 'enum-plus/extension';
22
33export type { LocalizeInterface } from './localize-interface' ;
44
5+ // @ts -expect-error: because LocaleKeys is a user-defined type, so ignore the error here
56export type EnumItemLabel = EnumLocaleExtends [ 'LocaleKeys' ] | NonNullable < string > ;
67
78// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -53,11 +54,13 @@ export interface StandardEnumItemInit<V extends EnumValue> {
5354}
5455export interface ValueOnlyEnumItemInit < V extends EnumValue > {
5556 value : V ;
57+ label ?: never ;
5658}
5759export interface LabelOnlyEnumItemInit {
5860 label : EnumItemLabel ;
61+ value ?: never ;
5962}
60- export type CompactEnumItemInit = Record < string , never > ; // 等价于 {}
63+ export type CompactEnumItemInit = Record < string , never > ; // equivalent to {}
6164
6265/**
6366 * - **EN:** Data structure of enumeration item options, used in `toList` method
You can’t perform that action at this time.
0 commit comments