File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -111,29 +111,32 @@ interface ThemeResult {
111111 * - singleTheme: The single theme if it exists
112112 * - themesToLoad: The themes to load when creating the highlighter
113113 */
114+ const isTextmateTheme = ( value : unknown ) : value is ThemeRegistrationAny =>
115+ typeof value === 'object' &&
116+ value !== null &&
117+ 'tokenColors' in value &&
118+ Array . isArray ( ( value as ThemeRegistrationAny ) . tokenColors ) ;
119+
114120export function resolveTheme ( themeInput : Theme | Themes ) : ThemeResult {
115- const isTextmateTheme =
116- typeof themeInput === 'object' &&
117- 'tokenColors' in themeInput &&
118- Array . isArray ( themeInput . tokenColors ) ;
121+ const inputIsTextmateTheme = isTextmateTheme ( themeInput ) ;
119122
120123 // Assume non textmate objects are multi theme configs
121124 const isMultiThemeConfig =
122125 typeof themeInput === 'object' &&
123126 themeInput !== null &&
124- ! isTextmateTheme ;
127+ ! inputIsTextmateTheme ;
125128
126129 const validMultiThemeObj =
127130 typeof themeInput === 'object' &&
128131 themeInput !== null &&
129- ! isTextmateTheme &&
132+ ! inputIsTextmateTheme &&
130133 Object . entries ( themeInput ) . some (
131134 ( [ key , value ] ) =>
132135 key &&
133136 value &&
134137 key . trim ( ) !== '' &&
135138 value !== '' &&
136- ( typeof value === 'string' || isTextmateTheme )
139+ ( typeof value === 'string' || isTextmateTheme ( value ) )
137140 ) ;
138141
139142 if ( isMultiThemeConfig ) {
You can’t perform that action at this time.
0 commit comments