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
There are some long standing issues in Typescript and its types for JSX which make it impossible to restrict the type of children that a component will accept (microsoft/TypeScript#13618 which is not fixed).
The Typescript type for ReactElement does have enough information to do this:
Any chance of getting support for specifying P and T?
There are a few other changes that would be needed to take full advantage of this such as ensuring that WithAttrs and KeyAddingStage captures these types. FunctionalComponentCore would just work since it has Props and Result. Component et al. would need a Result type.
The text was updated successfully, but these errors were encountered:
There are some long standing issues in Typescript and its types for JSX which make it impossible to restrict the type of children that a component will accept (microsoft/TypeScript#13618 which is not fixed).
The Typescript type for
ReactElement
does have enough information to do this:It is the JSX that has the issue as everything ends up as
ReactElement<any, any>
.AFAIK Flow already supports this: https://flow.org/en/docs/react/children/#toc-only-allowing-a-specific-element-type-as-children
Any chance of getting support for specifying
P
andT
?There are a few other changes that would be needed to take full advantage of this such as ensuring that
WithAttrs
andKeyAddingStage
captures these types.FunctionalComponentCore
would just work since it hasProps
andResult
.Component
et al. would need aResult
type.The text was updated successfully, but these errors were encountered: