Skip to content

Commit

Permalink
fix(isTypeScriptComponent): check all script tags (BuilderIO#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
milahu authored Nov 30, 2022
1 parent 8eea6e0 commit 756c9f5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/core/src/parsers/svelte/typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 756c9f5

Please sign in to comment.