Skip to content

[Button][material-ui] Button href TypeScript error #39287

Open
@kmoyse-apizee

Description

@kmoyse-apizee

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Hi, I found issue that really looks like mine : #22699
Steps:

  1. Developing in typescript
  2. Use <Button with href
  3. add target="_blank" property to it
  4. I get error ;
    TS2769: No overload matches this call.
    Overload 1 of 3, '(props: { href: string; } & ButtonOwnProps & Omit<ButtonBaseOwnProps, "classes"> & CommonProps & Omit<Omit<DetailedHTMLProps<AnchorHTMLAttributes, HTMLAnchorElement>, "ref"> & { ...; }, "color" | ... 24 more ... | "startIcon">): Element', gave the following error.
    Type 'string | undefined' is not assignable to type 'string'.
    Type 'undefined' is not assignable to type 'string'.

Trying to set strictNullChecks: true in tsconfig.json does not solve the problem

Current behavior 😯

typescript transpile error

Expected behavior 🤔

No response

Context 🔦

No response

Your environment 🌎

System:
OS: Linux 5.19 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
Binaries:
Node: 16.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 9.6.4 - /usr/local/bin/npm
Browsers:
Chrome: 117.0.5938.132
npmPackages:
@emotion/react: ^11.11.1 => 11.11.1
@emotion/styled: ^11.11.0 => 11.11.0
@mui/base: 5.0.0-beta.17
@mui/core-downloads-tracker: 5.14.11
@mui/icons-material: ^5.14.11 => 5.14.11
@mui/material: ^5.14.11 => 5.14.11
@mui/private-theming: 5.14.11
@mui/styled-engine: 5.14.11
@mui/system: 5.14.11
@mui/types: 7.2.4
@mui/utils: 5.14.11
@types/react: ^18.2.12 => 18.2.12
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
typescript: ^4.9.5 => 4.9.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: buttonThis is the name of the generic UI component, not the React module!typescript

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions