Skip to content

TS2589 Error throws in TS3.6 if SVGIcon component being wrapped with styled-components #17275

@leoyli

Description

@leoyli
  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

import styled from 'styled-components';
import SearchIcon from '@material-ui/icons/Search';
import InputBase from '@material-ui/core/InputBase';

const StyledSearchIcon = styled(SearchIcon)`
  position: relative;
  cursor: pointer;
  left: -2px;
`;

const MyInput = (props) => {
  return (<InputBase
    {...props}
    endAdornment={<StyledSearchIcon />}
              // wwwwwwwwwwwwwwwwwwwww
              // TS2589 Type instantiation is excessively deep and possibly infinite.
  />)
}

Expected Behavior 🤔

TS3.5 gives no errors, probably is due to this (comments).

Steps to Reproduce 🕹

Steps:

The code is straightforward, just copy paste and use in any component to see this TS error.

Context 🔦

Other components seems okay but SVG components are doomed. Perhaps we can simplify a bit the type declaration so it is less deep.

Your Environment 🌎

Tech Version
Material-UI v4.4.0
React v16.8.x
TypeScript v3.6.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    external dependencyBlocked by external dependency, we can’t do anything about ittypescript

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions