cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.07k stars 397 forks source link

Property 'prop' does not exist on type 'BaseRule' #1233

Open pshurygin opened 4 years ago

pshurygin commented 4 years ago

Describe the bug:

Code like this:

styleSheet.getRule('ruleName').prop('propName', propValue)

used to work perfectly fine with jss 9.x, but with v10.0.0 it fails with the following typescript error during build:

Property 'prop' does not exist on type 'Rule'. Property 'prop' does not exist on type 'BaseRule'.

Expected behavior:

No typescript compile error

Versions:

kof commented 4 years ago
import jss from 'jss'

const sheet = jss.createStyleSheet({
  a: {color: 'red'}
}, {link: true}).attach()

sheet.getRule('a').prop('color', 'green')
pshurygin commented 4 years ago

@kof I'm sorry, but what does your comment have to do with the issue? I'm not asking for a code example, actually my code is pretty much the same as yours.

The problem is that i'm using jss combined with typescript, which validates types based on type definitions, provided by the jss v10, and typescript compilation of this line of code fails due to incorrectly provided type definitions.

kof commented 4 years ago

I interpreted your problem as if you have a runtime error, sorry. cc @HenriBeck

tcoughlin3 commented 3 years ago

@kof It seems like we just need to add a prop attribute to the Rule type definition somewhere around here: https://github.com/cssinjs/jss/blob/3c335148f5ba3dbe9d6fb017356f64a8fe6a3776/packages/jss/src/index.d.ts#L105-L116

I'm looking to help with some open source issues. I'm happy to create a PR for this.

kof commented 3 years ago

@tcoughlin3 totally send a PR, if you want to sync about how you could help on other issues, feel free to either just search for them or ping me in dm on gitter to find issues for you to work on