@@ -25,7 +25,9 @@ export type IconProps<T> = TextProps & {
2525 innerRef ?: Ref < Text > ;
2626} ;
2727
28- export type IconComponent < GM extends Record < string , number > > = React . FC <
28+ type GlyphMap = Record < string , number | string > ;
29+
30+ export type IconComponent < GM extends GlyphMap > = React . FC <
2931 TextProps & {
3032 name : keyof GM ;
3133 size ?: number ;
@@ -44,17 +46,14 @@ export type CreateIconSetOptions = {
4446 fontStyle ?: TextProps [ 'style' ] ;
4547} ;
4648
47- export function createIconSet < GM extends Record < string , number > > (
49+ export function createIconSet < GM extends GlyphMap > (
4850 glyphMap : GM ,
4951 postScriptName : string ,
5052 fontFileName : string ,
5153 fontStyle ?: TextProps [ 'style' ] ,
5254) : IconComponent < GM > ;
53- export function createIconSet < GM extends Record < string , number > > (
54- glyphMap : GM ,
55- options : CreateIconSetOptions ,
56- ) : IconComponent < GM > ;
57- export function createIconSet < GM extends Record < string , number > > (
55+ export function createIconSet < GM extends GlyphMap > ( glyphMap : GM , options : CreateIconSetOptions ) : IconComponent < GM > ;
56+ export function createIconSet < GM extends GlyphMap > (
5857 glyphMap : GM ,
5958 postScriptNameOrOptions : string | CreateIconSetOptions ,
6059 fontFileNameParam ?: string ,
@@ -83,14 +82,14 @@ export function createIconSet<GM extends Record<string, number>>(
8382 fontStyle : 'normal' ,
8483 } ;
8584
86- const resolveGlyph = ( name : keyof GM ) => {
87- const glyph = glyphMap [ name ] ;
85+ const resolveGlyph = ( name : keyof GM ) : string => {
86+ const glyph = glyphMap [ name ] || '?' ;
8887
8988 if ( typeof glyph === 'number' ) {
9089 return String . fromCodePoint ( glyph ) ;
9190 }
9291
93- return '?' ;
92+ return glyph ;
9493 } ;
9594
9695 const Icon = ( {
0 commit comments