-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
StatelessFunctionalComponenet that probably returns null cannot be instanciated in JSX #11955
Comments
This is annoying. I worked abound it by asserting that const Foo = ({ prop1 }: FooProps) => {
if (prop1) {
return null!; // <= never is assignable to anything, so the return type will be Element
}
return (
<div>Hello!</div>
);
} |
@alitaheri Good idea. I just decided to remove |
@yuit we should allow |
@yuit as well as null constructor functions |
Can someone explain what is happening in @alitaheri's workaround? I've never seen the |
This is the same as #11566 |
This is not fixed yet. |
TypeScript Version: 2.1.0-dev.20161019
Code
Expected behavior:
This is a valid JSX code. It is true that the return value of the SFC can be null but there is no way to check for its value in the code!
Actual behavior:
Compiler complains with these errors:
The text was updated successfully, but these errors were encountered: