From 756c9f509b75542604d67b6ff7fdf117a2291ecd Mon Sep 17 00:00:00 2001 From: milahu Date: Wed, 30 Nov 2022 20:51:38 +0100 Subject: [PATCH] fix(isTypeScriptComponent): check all script tags (#933) --- packages/core/src/parsers/svelte/typescript/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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. */