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 committed Nov 30, 2022
1 parent 8eea6e0 commit 7a8273c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 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,14 @@ 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;
// match all
string_.replace(regex, (...match) => {
const { lang } = parseAttributes((match?.length && match[1]) || '');
if (lang === 'ts') isTypeScript = true;
return '';
});
return isTypeScript;
}

/** Create a tag matching regexp. */
Expand Down

0 comments on commit 7a8273c

Please sign in to comment.