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

Relax types #15

Merged
merged 4 commits into from
Oct 7, 2023
Merged

Relax types #15

merged 4 commits into from
Oct 7, 2023

Conversation

Zn4rK
Copy link
Contributor

@Zn4rK Zn4rK commented Oct 7, 2023

The types for style was a bit too strict in some cases. This relaxes them quite a bit. It's still up to the user to write correct selectors.

Index signatures and template literal strings are not recognised by TypeScript, so users will have to cast in cases such as:

import { style } from '@navita/css';

const someName = 'a b c'.replaceAll(' ', '.');

const x = style({
// TypeScript will not be able to infer this as // "&${string}" even though that's the key. 
// Fix by doing "as const" (in some cases where it's able to be infered) or lie to the compiler like this
[`& ${someName}` as '& someName']: {
  background: 'hotpink',
}
});

// ^- That's a contrived example, and even though it works in Navita,
// you should try to avoid it and structure your html/css better.
// That will create a few css declarations that you are never going to be repeating, thus circumventing atomic css. 

@changeset-bot
Copy link

changeset-bot bot commented Oct 7, 2023

🦋 Changeset detected

Latest commit: 53e2e2d

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

This PR includes changesets to release 14 packages
Name Type
@navita/engine Patch
@navita/types Patch
@navita/css Patch
@navita/core Patch
@navita/jest Patch
navita-example-with-jest Patch
with-next-app-dir Patch
navita-with-next-example Patch
navita-with-vite-example Patch
navita-with-webpack-example Patch
@navita/vite-plugin Patch
@navita/webpack-plugin Patch
navita Patch
@navita/next-plugin 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

@Zn4rK Zn4rK merged commit aad73cd into main Oct 7, 2023
2 checks passed
@Zn4rK Zn4rK deleted the fix-relax-types branch October 7, 2023 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant