Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
However, in React, function components can return a ReactNode. This type includes number | string | Iterable | undefined and will likely also include Promise( in the future.
In an effort to address the issue described in the previous section, Sebastian opened a pull request to TypeScript: “RFC: Consult new JSX.ElementType for valid JSX element types". In that PR, Sebastian explained the issue and proposed a solution — introducing a new type, JSX.ElementType.
The TypeScript pull request was merged, so Sebastian (who helps maintain the React type definitions) exercised new powers in this pull request to the DefinitelyTyped repository for the React type definitions. At the time of writing, this pull request is still open, but once merged and shipped the React community we will feel its benefits.
Related posts
- Functional Programming with TypeScript's Type System
- TypeScript PR merged to allow components to return anything renderable (raw strings, numbers, promises for RSC), instead of just JSX.Element and null.
- Thinking in ReScript
- Merging to objects in a type-safe way with Lodash?
- Why Become a TypeScript Fan?