mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.7k stars 32.23k forks source link

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

Open Rijndael1998 opened 4 hours ago

Rijndael1998 commented 4 hours ago

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 :+1:

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 commented 3 hours ago

Alert is having similar typing issues: image