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

Invalid output when using function() (anonymous functions) in prop #1485

Open
dddlr opened this issue Jul 28, 2023 · 0 comments
Open

Invalid output when using function() (anonymous functions) in prop #1485

dddlr opened this issue Jul 28, 2023 · 0 comments
Labels
bug 🐛 Something isn't working has workaround 💫 You can work around this bug.

Comments

@dddlr
Copy link
Collaborator

dddlr commented Jul 28, 2023

Describe the bug

We don't currently support anonymous functions in components that are not arrow functions. When we try to do this, we get very bizarre output. We should throw an error in these situations (if we decide not to support them).

To Reproduce

Variant 1

const Button = styled.div({
  width: function({ width, height = 16 }) {
    return `${width + height}px`;
  },
});

Screenshot 2023-07-27 at 17 06 46

Variant 2

const Button = styled.div({
  width({ width, height = 16 }) {
    return `${width + height}px`;
  },
});

Screenshot 2023-07-27 at 17 11 40

Workarounds

Workaround is to use an arrow function instead.

Expected behavior

There should be a build-time error.

Version

Tested with master branch as of 8add86d (compiled/babel-plugin 0.20.0)

@dddlr dddlr added bug 🐛 Something isn't working has workaround 💫 You can work around this bug. labels Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working has workaround 💫 You can work around this bug.
Projects
None yet
Development

No branches or pull requests

1 participant