-
-
Notifications
You must be signed in to change notification settings - Fork 540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 In Svelte context=module Scripts error "import { type x ident }' are a TypeScript only feature." #2245
Comments
MouseEvent also fails with code below, interestingly only that part, interface itself does not produce any errors. "Type annotations are a TypeScript only feature. Convert your file to a TypeScript file or remove the syntax." <script context="module" lang="ts">
export interface ButtonProps {
onclick?: (event: MouseEvent) => void
}
</script> |
An option to override parsing would be great, forcing typescript on all "*.svelte" files might be an easy fix to this problem |
The fix should be fairly easy, we need to update the regex to take biome/crates/biome_service/src/file_handlers/svelte.rs Lines 26 to 35 in 19d761a
Can anyone help? |
@ematipico Instead of adding error prone syntaxes to our regexes, what do you think of using our jsx parser (for the time being of course) to parse the matched #[test]
pub fn jsx_test() {
let code = r#"
<script context="module" lang="ts">
"#;
let root = parse(code, JsFileSource::jsx(), JsParserOptions::default());
let syntax = root.syntax();
dbg!(&syntax, root.diagnostics(), root.has_errors());
} |
I'm not sure how reliable that would be though. The regex is good because it gives us the offsets we need to extract the code. With the parser, we need to calculate the offsets ourselves, and rely on how well our parser can recover itself and still provide the correct ranges of the script tag. |
What I wanted to say is that we still use regex to match the script block so we can still have our script body and offsets, but instead we use the JSX parser to parse the opening element to extract the |
Environment information
What happened?
Expected result
No error
Code of Conduct
The text was updated successfully, but these errors were encountered: