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
Currently, the JSX support in the N4JS compiler is producing raw types as the types of JSX elements. This is a problem because raw types are checked only partially and should therefore be used only in rare special cases.
For example:
import*asReactfrom"react";interface~FooPropsextendsReact.ComponentProps{publicfooProp?: string;}interface~OtherPropsextendsReact.ComponentProps{public otherProp: string;}functionFoo(props: FooProps): React.Element<?>{returnnull;}letfooTag=<Foo/>;// XPECT FIXME errors --> "Element<FooProps> is not a subtype of Element<OtherProps>" at "fooTag"letelem: React.Element<OtherProps>=fooTag;// this assignment should not be allowed!!
The type of fooTag will be Element (i.e. a raw type not providing a type argument for Element's type parameter), leading to the problem that the assignment in the last line is allowed. Instead, the type of fooTag should be at least Element<?>, or better Element<MyProps>.
The problem, however, is that this fix will break client code because it leads to stronger type checking.
The text was updated successfully, but these errors were encountered:
mor-n4
changed the title
As a developer I want the JSX support in N4JS to not ignore PropsT of JSX tags
As a developer I want the JSX support in N4JS to not ignore the properties of JSX elements/fragments
Apr 15, 2021
Currently, the JSX support in the N4JS compiler is producing raw types as the types of JSX elements. This is a problem because raw types are checked only partially and should therefore be used only in rare special cases.
For example:
The type of
fooTag
will beElement
(i.e. a raw type not providing a type argument forElement
's type parameter), leading to the problem that the assignment in the last line is allowed. Instead, the type offooTag
should be at leastElement<?>
, or betterElement<MyProps>
.The problem, however, is that this fix will break client code because it leads to stronger type checking.
The text was updated successfully, but these errors were encountered: