You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Search Terms: TSX, generics, required, jsx, typescript
I also read the jsx section in documentation.
Code
.tsximport*asReactfrom"react";classGenerics<T>extendsReact.Component{render(){return<span>Generics is rendered even though it's T is not defined</span>;}}exportdefault()=>(<h1>
This should fail as Generics does not have a default type. <Generics/></h1>);
Expected behavior:
The above code should fail during compilation.
Actual behavior:
The above code passes the compilation, even though the generic type is not provided and not defaulted
Type parameters that cannot be inferred and don't have a default, fall back to {}.
There once was a PR to add an option to make this behavior an error. But that PR was rejected and it was decided this should be implemented in a linter instead.
TypeScript Version: 3.0.1
Search Terms: TSX, generics, required, jsx, typescript
I also read the jsx section in documentation.
Code
Expected behavior:
The above code should fail during compilation.
Actual behavior:
The above code passes the compilation, even though the generic type is not provided and not defaulted
Playground Link:
https://codesandbox.io/s/4q15l927x
Related Issues:
#3960
The text was updated successfully, but these errors were encountered: