Skip to content

Cannot define an arrow function with a single generic type parameter that has a default value with JSXΒ #47062

Description

Bug Report

πŸ”Ž Search Terms

typescript
jsx
tsx
generic
arrow function
default value

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about generics.

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

import React from 'react'

const myFunc = <T = string,>() => {

}

πŸ™ Actual behavior

The typescript compiler throws multiple errors

πŸ™‚ Expected behavior

I would be allowed to create an arrow function with a single type parameter that has a default value.

Note:

  • This happens only on with JSX enabled
  • Removing the default value (= string) doesn't throw errors
  • Adding a second type parameter before T, ie <K, T=string> doesn't throw errors

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions