-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(icon): icon name extendable type (#4045)
- Loading branch information
Showing
6 changed files
with
45 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import type { VuesticIconAliases } from './../../services/icon/presets/vuestic-aliases' | ||
import type { ExtractIconAliasesName } from '../../services/icon/types/define-aliases' | ||
|
||
type DefaultIconAliases = ExtractIconAliasesName<typeof VuesticIconAliases> | ||
|
||
/** | ||
* This is a placeholder meant to be implemented via TypeScript's Module | ||
* Augmentation feature to allow key type inference | ||
* | ||
* @example | ||
* ```ts | ||
* declare module 'vuestic-ui' { | ||
* interface CustomIconAliasesNKeys { | ||
* from: string | ||
* } | ||
* } | ||
* ``` | ||
* | ||
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation | ||
*/ | ||
export interface CustomIconAliasesNKeys {} | ||
|
||
export type VaIconName = DefaultIconAliases | keyof CustomIconAliasesNKeys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { IconConfiguration } from '../types' | ||
|
||
export const defineIconAliases = <Name extends string>(aliases: IconConfiguration<Name>[]) => aliases | ||
|
||
export type ExtractIconAliasesName<T> = T extends IconConfiguration<infer Name> | ||
? Name | ||
: T extends IconConfiguration<infer Name>[] ? | ||
Name | ||
: never |