Skip to content

Commit ccef14a

Browse files
authored
Merge pull request Hexastack#753 from Hexastack/752-issue---make-settingtypeselect-return-options-type-instead-returning-a-string-type
fix: make SettingType.select inferring options as type
2 parents 97e29d8 + 60a6455 commit ccef14a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

api/src/setting/index.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/*
2-
* Copyright © 2024 Hexastack. All rights reserved.
2+
* Copyright © 2025 Hexastack. All rights reserved.
33
*
44
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
55
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
66
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
77
*/
88

9+
import { SettingType } from '@/setting/schemas/types';
10+
911
import { SettingByType } from './schemas/types';
1012
import { DEFAULT_SETTINGS } from './seeds/setting.seed-model';
1113

@@ -22,10 +24,14 @@ declare global {
2224
? { [K in keyof T]: TNativeType<T[K]> }
2325
: T;
2426

27+
type SettingValue<K> = K['type'] extends SettingType.select
28+
? K['options'][number]
29+
: TNativeType<K['value']>;
30+
2531
type SettingObject<
2632
T extends Omit<Setting, 'id' | 'createdAt' | 'updatedAt'>[],
2733
> = {
28-
[K in T[number] as K['label']]: TNativeType<K['value']>;
34+
[K in T[number] as K['label']]: SettingValue<K>;
2935
};
3036

3137
type SettingMapByType<
@@ -38,7 +44,7 @@ declare global {
3844
T extends Omit<Setting, 'id' | 'createdAt' | 'updatedAt'>[],
3945
> = {
4046
[G in T[number] as G['group']]: {
41-
[K in T[number] as K['label']]: TNativeType<K['value']>;
47+
[K in T[number] as K['label']]: SettingValue<K>;
4248
};
4349
};
4450

0 commit comments

Comments
 (0)