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

Switch property 'checked' does not exist on type 'IntrinsicAttributes & SwitchProps'. #44177

Open
Rijndael1998 opened this issue Oct 21, 2024 · 4 comments
Assignees
Labels
component: switch This is the name of the generic UI component, not the React module! typescript

Comments

@Rijndael1998
Copy link

Rijndael1998 commented Oct 21, 2024

Steps to reproduce

Tested on v6.1.4 after doing a large upgrade from v5.

<Switch checked={true} />

^ this gives a squiggly type error.

Check it out on your own StackBlitz link. Use the "controlled" switch example.
https://mui.com/material-ui/react-switch/

Here's my forked version:
https://stackblitz.com/edit/react-486rye?file=Demo.tsx

Current behavior

Type error

StackBlitz:
image

VSCodium:
image

Expected behavior

No type error 👍

Context

I'm writing code.

Your environment

  System:
    OS: Linux 6.6 NixOS 24.05 (Uakari) 24.05 (Uakari)
  Binaries:
    Node: 20.15.1 - /run/current-system/sw/bin/node
    npm: 10.7.0 - /run/current-system/sw/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: Not Found
  npmPackages:
    @emotion/react: ^11.13.3 => 11.13.3 
    @emotion/styled: ^11.13.0 => 11.13.0 
    @mui/base:  5.0.0-beta.59 
    @mui/core-downloads-tracker:  6.1.4 
    @mui/icons-material: ^6.1.4 => 6.1.4 
    @mui/lab: ^6.0.0-beta.12 => 6.0.0-beta.12 
    @mui/material: ^6.1.4 => 6.1.4 
    @mui/private-theming:  6.1.4 
    @mui/styled-engine:  6.1.4 
    @mui/system:  6.1.4 
    @mui/types:  7.2.18 
    @mui/utils:  6.1.4 
    @types/react: ^18.3.11 => 18.3.11 
    react: ^18.3.1 => 18.3.1 
    react-dom: ^18.3.1 => 18.3.1 
    typescript: ^5.6.3 => 5.6.3 
{
  "compilerOptions": {
    "target": "esnext",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

Search keywords: Switch, checked, SwitchProps

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

Alert is having similar typing issues:
image

@zannager zannager added the component: switch This is the name of the generic UI component, not the React module! label Oct 22, 2024
@mj12albert mj12albert added typescript and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 23, 2024
@Rijndael1998
Copy link
Author

Tested with v6.1.5 and it still seems to be an issue. For clarity I'm referring to both the switch component and the alert component.

@LuuchoRocha
Copy link

LuuchoRocha commented Nov 5, 2024

Same error here, using the @mui/material/Radio component, using 5.15.19
Looks like this bug has been around for a while

image

image

@ZeeshanTamboli
Copy link
Member

I think this is a problem only in StackBlitz because it works for me locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: switch This is the name of the generic UI component, not the React module! typescript
Projects
None yet
Development

No branches or pull requests

5 participants