cssinjs/jss

TS error using a function to customise defaults with the default unit plugin

Open

#1 444 ouverte le 20 janv. 2021

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)JavaScript (434 forks)batch import
help wantedtypescript

Métriques du dépôt

Stars
 (7 000 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

Expected behavior: Use the 'jss-plugin-default-unit' to override default units for numeric values in combination with TypeScript.

Describe the bug: The plugin itself doesn't appear to have any issues but I am receiving TypeScript related errors in my IDE when using a function to define an option for the plugin.

const options = {
    width: val => `${val / 2}px`
}
jss.use(defaultUnit(options));

Source: https://cssinjs.org/jss-plugin-default-unit/?v=v10.5.0#customizing-defaults

I'm not sure if the following is the cause but the two definitions of the Options type do not seem to match:

Codesandbox: N/A

Versions:

  • react-jss: 10.5.0
  • typescript: 4.0.3
  • OS: Linux

Guide contributeur