The function cannot be used in a string template
Environment
Linaria version: v4+ Bundler (+ version): Webpack 5+ Node.js version: 16+
Description
Using a function declaration in a string template results in the error "This expression cannot be used in a template because it is a function parameter.":
function getColor() {
return 'red';
}
const Title = styled.h1`
color: ${getColor()};
`;
At the same time, the use of function expression is correctly processed:
const getColor = () => {
return 'red';
}
const Title = styled.h1`
color: ${getColor()};
`;
Reproducible Demo
https://codesandbox.io/s/jolly-leftpad-6gfqz1?file=/pages/index.js
Also seeing this issue, it happens when I try to upgrade @linaria/webpack-loader from 3.0.0-beta.16 to 4.1.3
The issue appears to happen here: https://github.com/callstack/linaria/blob/master/packages/babel/src/utils/collectTemplateDependencies.ts#L142
binding.kind is set to hoisted and the above error message is generated