Implemented types.stringLiteral(.., {as})
This commit is contained in:
parent
97ce94d52a
commit
a4f83e0f84
8 changed files with 180 additions and 34 deletions
|
@ -62,11 +62,13 @@ export interface PropTypeConfig_StringLiteral<T extends string>
|
|||
type: 'stringLiteral'
|
||||
default: T
|
||||
options: Record<T, string>
|
||||
as: 'menu' | 'switch'
|
||||
}
|
||||
|
||||
export function stringLiteral<Opts extends {[key in string]: string}>(
|
||||
defaultValue: Extract<keyof Opts, string>,
|
||||
options: Opts,
|
||||
extras?: {as?: 'menu' | 'switch'},
|
||||
): PropTypeConfig_StringLiteral<Extract<keyof Opts, string>> {
|
||||
return {
|
||||
type: 'stringLiteral',
|
||||
|
@ -74,6 +76,7 @@ export function stringLiteral<Opts extends {[key in string]: string}>(
|
|||
options: {...options},
|
||||
[s]: 'TheatrePropType',
|
||||
valueType: null as $IntentionalAny,
|
||||
as: extras?.as ?? 'menu',
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue