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

sx Prop Types #93

Closed
NeilTheFisher opened this issue May 18, 2024 · 3 comments
Closed

sx Prop Types #93

NeilTheFisher opened this issue May 18, 2024 · 3 comments
Assignees
Labels
package: system Specific to @mui/system

Comments

@NeilTheFisher
Copy link

NeilTheFisher commented May 18, 2024

Steps to reproduce

No response

Current behavior

Putting the sx prop on a React element like a div doesn't give type hints
image

Expected behavior

No response

Context

I am converting a project's emotion css props to use pigment's sx prop since they work the same. It just doesn't have types.

Your environment

npx @mui/envinfo
  System:
    OS: Windows 11 10.0.22631
  Binaries:
    Node: 18.19.0 - D:\Program Files\nodejs\node.EXE
    npm: 10.2.3 - D:\Program Files\nodejs\npm.CMD
    pnpm: 9.1.1 - D:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Chrome: Not Found
    Edge: Chromium (123.0.2420.97)
  npmPackages:
    react: beta => 19.0.0-beta-26f2496093-20240514 
    react-dom: beta => 19.0.0-beta-26f2496093-20240514 
    types-react:  19.0.0-beta.1 
    typescript: ^5.4.5 => 5.4.5

Search keywords: sx types

@NeilTheFisher NeilTheFisher added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 18, 2024
@NeilTheFisher
Copy link
Author

Two solutions:

  1. Create an index.d.ts file with the contents:

    import type { sx } from "@pigment-css/react";
    
    declare global {
      namespace React {
        interface DOMAttributes<T> {
          sx?: Parameters<typeof sx>[0];
        }
      }
    }
  2. Add this to sx.d.ts. (presumably in a PR)

    declare global {
      namespace React {
        interface DOMAttributes<T> {
          sx?: Parameters<typeof sx>[0];
        }
      }
    }

    Then add /// <reference types="@pigment-css/react" /> to a type declaration file

@NeilTheFisher
Copy link
Author

@zannager zannager added the package: system Specific to @mui/system label May 24, 2024
@brijeshb42
Copy link
Contributor

Feel free to re-open if you are still facing any issue.

@zannager zannager removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: system Specific to @mui/system
Projects
None yet
Development

No branches or pull requests

3 participants