Skip to content

Commit db605d3

Browse files
committed
fix(Types): fix importing react types in jsx/tsx
1 parent 84cf763 commit db605d3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/livecodes/core.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ import { appLanguages } from './i18n/app-languages';
164164
import { themeColors } from './UI/theme-colors';
165165
import { getCommandMenuActions } from './UI/command-menu-actions';
166166
import { createLanguageMenus, createProcessorItem } from './UI/create-language-menus';
167+
import { hasJsx } from './editor/ts-compiler-options';
167168

168169
// declare global dependencies
169170
declare global {
@@ -370,8 +371,9 @@ const loadModuleTypes = async (
370371
...config.types,
371372
...config.customSettings.types,
372373
};
374+
const reactImport = hasJsx.includes(scriptLanguage) ? `import React from 'react';\n` : '';
373375
const libs = await typeLoader.load(
374-
getConfig().script.content + '\n' + getConfig().markup.content,
376+
reactImport + getConfig().script.content + '\n' + getConfig().markup.content,
375377
configTypes,
376378
loadAll,
377379
force,

0 commit comments

Comments
 (0)