Skip to content
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

String literals with methods cause incorrect error messages #271

Open
jantimon opened this issue Feb 7, 2025 · 0 comments
Open

String literals with methods cause incorrect error messages #271

jantimon opened this issue Feb 7, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@jantimon
Copy link
Contributor

jantimon commented Feb 7, 2025

I ran into an issue while using next-yak 4.1.0 with Node 22.13.1.

When trying to use JavaScript's String.prototype.repeat() method inside a styled component's template literal, the compiler throws a parsing error

Here's a minimal reproduction:

import { styled } from "next-yak";

const CompA = styled.div`
  grid-template-columns: ${() => "1f".repeat(12)};
`;

This results in the error:

Error:   × Could not parse member expression
   ╭─[app/page.tsx:4:1]
 1 │ import { styled } from "next-yak";
 2 │ 
 3 │ const CompA = styled.div`
 4 │   grid-template-columns: ${() => "1f".repeat(12)};
   ·                                  ───────────
 5 │ `;

This should be valid code since it's a runtime expression that generates a CSS value

Environment:

  • next-yak: 4.1.0
@jantimon jantimon added the bug Something isn't working label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant