microsoft / fluentui

Fluent UI web represents a collection of utilities, React components, and web components for building web applications.
https://react.fluentui.dev
Other
18.33k stars 2.72k forks source link

v9's `makeStyles` doesn’t accept valid ZIndexProperty on pseudoelements #22232

Closed thure closed 2 years ago

thure commented 2 years ago

Environment Information

Please provide a reproduction of the bug in a codepen:

Actual behavior:

In a makeStyles call like this:

const useStyles = makeStyles({
  root: {
    '&:before': {
      zIndex: -1
    }
  }
})

TypeScript errors on &:before with:

      Property 'zIndex' is incompatible with index signature.
        Type 'number' is not assignable to type 'GriffelStylesCSSValue | GriffelStylesCSSObjectCustomL3 | undefined'.

Even though Griffel identifies the type of zIndex as

export type ZIndexProperty = Globals | "auto" | number

The error is not present when applied directly to root.

Expected behavior:

An acceptable zIndex value should not cause TypeScript issues, even on pseudo-elements.

Priorities and help requested:

Are you willing to submit a PR to fix? (Yes, No)

Requested priority: (Blocking, High, Normal, Low)

Products/sites affected: Fluent Blocks (https://github.com/OfficeDev/fluent-blocks)

micahgodbolt commented 2 years ago

It appears to work with :before but not &:before.

Both produce the same result, but only the first one appears properly typed.

layershifter commented 2 years ago

This was fixed in Griffel itself, https://github.com/microsoft/griffel/issues/49. I will work on PR to bump Griffel in Fluent UI.