Skip to content

String literals with methods cause incorrect error messages #271

Open
@jantimon

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions