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

How to set strict mode? #858

Open
ivanbanov opened this issue Oct 25, 2021 · 6 comments
Open

How to set strict mode? #858

ivanbanov opened this issue Oct 25, 2021 · 6 comments
Labels
feature New feature

Comments

@ivanbanov
Copy link

I saw that you guys merged this PR #206 which does exactly what I was looking for.
Despite the PR I can not find it in the docs, was it removed? What is the right way to set it up?

@peduarte
Copy link
Contributor

It has been removed, yes. You can still have a strict-er way to use tokens via the theme object though

https://stitches.dev/docs/typescript#stricter-experience

@kylemh
Copy link

kylemh commented Oct 26, 2021

Is there any chance of this returning? What about returning another function similar to styled like strictStyled?

@peduarte
Copy link
Contributor

There's a chance, yes. This API is what I had drafted too :D

@willdspd
Copy link

willdspd commented Jan 6, 2022

@peduarte any updates on this? This is the only thing that is really lacking in stitches at the moment IMO!

@hadihallak hadihallak added the feature New feature label Jun 1, 2022
@vincerubinetti
Copy link

vincerubinetti commented Nov 16, 2022

Not sure if related, but it seems like no typing at all is working:

const dialogStyle = css({
  displays: "flex ",
  flexDirection: "diagonal",
  background: 1,
  // any other nonsensical key/value i can think of also does not throw any error
});

Basically no type errors (for valid CSS properties and values) seem to get caught. I'm trying to switch from emotion, which catches these errors.

The recommended way to share styles across components is to create them via the css or the styled functions. This way you'll get typing for free.

Not sure if you can consider this "getting typing". Checking for CSS property/value errors is one of the main points (imo) for doing CSS-in-JS.

@excursus
Copy link

excursus commented Apr 7, 2023

I've been using something like:

import { css as css_ } from '@stitches/core'
import { SimplePseudos, StandardProperties } from '@stitches/core/types/css'

type CSS = Partial<StandardProperties> & Partial<Record<SimplePseudos, Partial<StandardProperties>>>
const css: (x: CSS) => ReturnType<typeof css_> = css_

const tagStyle = css({
    borderRadius: 5,
    foobar      : 'error!'
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
Development

No branches or pull requests

7 participants