Skip to content

Conversation

@weswigham
Copy link
Member

Fixes #27948 in the general case where the union elements are like ComponentType - very similar signatures in each union member.

if (refKind === JsxReferenceKind.Function) {
const sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
if (sfcReturnConstraint) {
checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement, Diagnostics.JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements);
Copy link

@Jessidhia Jessidhia Oct 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(note) as of React 16, components are also allowed to return number / string / boolean (in other words, anything other than undefined, symbol or a non-Element, non-Array object), but at least TS@latest will reject SFC which include those return types. It does validate with classes, just not functions.

If fixed this probably goes in another PR though.

@weswigham weswigham merged commit 972c403 into microsoft:master Oct 26, 2018
@weswigham weswigham deleted the jsx-union-kludge branch October 26, 2018 23:02
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants