Skip to content

Issue with generic syntax in .tsx #2295

@ArnaudBarre

Description

@ArnaudBarre

Describe the bug

This is a common hack to use a comma to declare generics without default or extends in TSX file. It's seems that some part of the build chain (in dev mode) drop the comma, making the file invalid.

image

Reproduction

https://github.com/ArnaudBarre/vite-generic-bug

Equivalent to yarn create @vitejs/app --template react-ts + update main.tsx to:

const App = <T,>(props: {value: T}) => {
    return <div>Hello {typeof props.value}</div>
}

ReactDOM.render(
  <React.StrictMode>
    <App value="string" />
  </React.StrictMode>,
  document.getElementById('root')
)

System Info

  • vite version: 2.0.4 (esbuild 0.8.53)
  • Operating System: Mac
  • Node version: 14.13.1
  • Package manager: yarn 1.22.10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions