Skip to content

Commit c1078c7

Browse files
committed
fix: correct isTextmateTheme check in multi-theme validation
1 parent 66c6f60 commit c1078c7

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

package/src/lib/resolvers.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff 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+
114120
export 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) {

0 commit comments

Comments
 (0)