linaria
linaria copied to clipboard
Could not parse valid code
Environment
- Linaria version: 4.1.2
- Bundler (+ version): webpack 5
- Node.js version: 16
- OS: Mac
Description
I have code:
function Root() {
return <div>test</div>
}
function render() {}
function renderApp() {
const reactElement = <Root></Root>;
const rootElement = document.getElementById("root");
render(reactElement, rootElement);
}
I get error:
Property body of FunctionDeclaration expected node to be of a type ["BlockStatement"] but instead got undefined
if I comment render(reactElement, rootElement);. Code will be parsed without errors.
Reproducible Demo
https://github.com/Mavrin/linaria-issue
also expression like this could not be parsed
const checkHoveredStateTimeoutId = useRef<ReturnType<typeof setTimeout> | null>();
Property exprName of TSTypeQuery expected node to be of a type ["TSEntityName","TSImportType"] but instead got undefined
I also got the Property body of FunctionDeclaration expected node to be of a type ["BlockStatement"] but instead got undefined error on code like this:
import { useState } from 'react'
export function useBreakpoint(breakpoint: number): boolean {
const [match] = useState(window.innerWidth >= breakpoint)
return match
}
It worked once I extracted window.innerWidth >= breakpoint into a separate function.