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

Improve dynamic value error message #212

Merged
merged 5 commits into from
Nov 26, 2024

Conversation

Mad-Kat
Copy link
Collaborator

@Mad-Kat Mad-Kat commented Nov 17, 2024

Closes: #208

Error message before:

  x The value for variable "$pageHeaderHeight" could not be found in the top scope
    ,-[input.js:17:1]
 16 |     ` : css`
 17 |       margin-top: ${$pageHeaderHeight}px;
    :                     ^^^^^^^^^^^^^^^^^
 18 |     `};
    `----

Error message afterwards:

  x The shorthand access to the variable "$pageHeaderHeight" is not allowed in a nested expression.
  | To be able to use the property turn it into a CSS variable by wrapping it in a function:
  | 
  | ${() => $pageHeaderHeight};
  | 
    ,-[input.js:17:1]
 16 |     ` : css`
 17 |       margin-top: ${$pageHeaderHeight}px;
    :                     ^^^^^^^^^^^^^^^^^
 18 |     `};
    `----

Copy link

changeset-bot bot commented Nov 17, 2024

🦋 Changeset detected

Latest commit: 8781a8c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
yak-swc Patch
next-yak Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codspeed-hq bot commented Nov 17, 2024

CodSpeed Performance Report

Merging #212 will not alter performance

Comparing improve-dynamic-value-error-message (8781a8c) with main (94354f3)

Summary

✅ 2 untouched benchmarks

@Mad-Kat Mad-Kat marked this pull request as ready for review November 17, 2024 15:04
@Mad-Kat Mad-Kat requested a review from jantimon November 17, 2024 15:04
Copy link
Collaborator

@jantimon jantimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could have a false positive if there is a typo in a constant name - but I guess that’s handled by typescript anyway

@Mad-Kat Mad-Kat merged commit 411ad36 into main Nov 26, 2024
8 checks passed
@Mad-Kat Mad-Kat deleted the improve-dynamic-value-error-message branch November 26, 2024 18:49
jantimon pushed a commit that referenced this pull request Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Css template literal variable scope issue
2 participants