diff --git a/packages/core/src/parsers/svelte/typescript/index.ts b/packages/core/src/parsers/svelte/typescript/index.ts index 12f6f0d24a..dc55ad9347 100644 --- a/packages/core/src/parsers/svelte/typescript/index.ts +++ b/packages/core/src/parsers/svelte/typescript/index.ts @@ -9,9 +9,12 @@ import type { SveltosisComponent } from '../types'; export function isTypeScriptComponent(string_: string) { const regex = createTagRegex('script', 'gi'); - const match = regex.exec(string_); - const { lang } = parseAttributes((match?.length && match[1]) || ''); - return lang === 'ts'; + let isTypeScript = false; + string_.replace(regex, (...match) => { + const { lang } = parseAttributes((match?.length && match[1]) || ''); + if (lang === 'ts') isTypeScript = true; + }); + return isTypeScript; } /** Create a tag matching regexp. */