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
Type JSX elements based on createElement function #14729
Comments
|
I think this is doable and could potentially cut out a lot of code from the compiler. When we added JSX support we didn't have spread types or The remaining difficulty is just technical - the overload resolution code is hardcoded in a lot of places with the assumption that it's operating over an actual argument list syntax tree rather than some abstract set of parameters. |
|
Having this would allow one to utilize the concept of generalized JSX with TS. Currently it seems impossible, because the return type of any JSX expression is always a non-generic In fact, given this it would make sense to ditch the whole "JSX" global namespace and just use the declared type of the locally scoped |
That's exactly what I thought!
The compiler already handles different kinds of function calls. @niieani That's an interesting use case. I think that it would be useful in a lot of situations, other than the DOM, where some domain specific language is desired. |
|
@ivogabe yeah, I especially like the example with ASTs, represented by JSX. So much more readable than declaring plain objects for AST. |
|
I'd like to ping this issue ; could it be possible that the whole jsx mechanic be simply a transform to a function call with its implied checking ? This would allow for so much flexibility in library creation. |
No. Two reasons and there may be more:
[1] interface Point {
x: number;
y: number;
}
var m: Point;
var j: Point = { z: 10, ...m }; // Not an error due to spread |
|
@RyanCavanaugh The first could be fixed via other types of constructs that could be added to the language:
Second we could think about. Maybe the spreads in JSX would behave differently? There's probably something we could do. In any case, this would massively simplify the API and allow for custom JSX applications as I've mentioned in the comment above. |
|
AFAIK it's not just class Foo extends React.Component<{a:string}>{}
//This works:
<Foo b-3="bar" a="ggg"/> |
|
@RyanCavanaugh now that the second point has been fixed, can this be revisited? interface Point {
x: number;
y: number;
}
var m: Point;
var j: Point = { z: 10, ...m }; // NOW ERRORS |
|
Another problem to consider here is how to deal with backwards compatibility, particularly around the DefinitelyTyped definitions for React, which would have to be updated to support this. Existing types that depend on the JSX namespace would no longer work because the compiler wouldn't look there anymore. The most graceful way I can see to handle that would be to modify the React definitions so that the JSX namespace definitions are dependent on (or at least structurally equivalent to) whatever types are used for For non-React use cases, this will probably just have to be a breaking change, with a suggested migration pattern. If someone is already using the JSX namespace for typing JSX, all they need to do is add a I agree that having this would improve the flexibility of JSX-in-TS considerably, but the migration for existing code will probably be quite painful. |
|
should be covered by #21699 |
* feat: setup TS for stories * fix: eslint was ignore .storybook * feat: add TS to storybook * refactor: move stories to TS (WIP) * refactor: move more stories to TS (WIP) * refactor: src changes for TS move over I think these were TS problems that were missed. * fix: ContactShadows story * refactor: move more stories to TS * refactor: add MapControls.tsx after raising issues in three Two errors linked to three.js: mrdoob/three.js#21058 mrdoob/three.js#21059 * fix: TS errors for passing refs & children * refactor: add more stories (WIP) * fix: useContextBridge TS to accept array of children fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729 * refactor: convert more stories to TS also useGLTF does not need to declare it's type * chore: update storybook * fix: revert useTexture accidentally committed a WIP change * refactor: move stories to TS (WIP) * refactor: revert useGLTF story * Minor type fixes * chore: update react-three-fiber to latest Required for Types * refactor: move stories to TS * fix: shaderMaterial on init returns void, not null * refactor: remove unnecessary type in useFBX * refactor: type Environment stronger there was issues with useAsset not understanding it's types.... * Fixes CSB CI (#230) Co-authored-by: Gianmarco Simone <gianmarcosimone89@gmail.com>
* feat: setup TS for stories * fix: eslint was ignore .storybook * feat: add TS to storybook * refactor: move stories to TS (WIP) * refactor: move more stories to TS (WIP) * refactor: src changes for TS move over I think these were TS problems that were missed. * fix: ContactShadows story * refactor: move more stories to TS * refactor: add MapControls.tsx after raising issues in three Two errors linked to three.js: mrdoob/three.js#21058 mrdoob/three.js#21059 * fix: TS errors for passing refs & children * refactor: add more stories (WIP) * fix: useContextBridge TS to accept array of children fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729 * refactor: convert more stories to TS also useGLTF does not need to declare it's type * chore: update storybook * fix: revert useTexture accidentally committed a WIP change * refactor: move stories to TS (WIP) * refactor: revert useGLTF story * Minor type fixes * chore: update react-three-fiber to latest Required for Types * refactor: move stories to TS * fix: shaderMaterial on init returns void, not null * refactor: remove unnecessary type in useFBX * refactor: type Environment stronger there was issues with useAsset not understanding it's types.... * Fixes CSB CI (#230) Co-authored-by: Gianmarco Simone <gianmarcosimone89@gmail.com> Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com>
* change: move components into core folder * feat: add import types web & native index points to web to avoid breaking changes(?) but also cause that's a good default. * refactor: rollup so it looks for ts not tsx * refactor: move Html & Loader to web folder, make folders for native & web index points to web * Fixes CSB CI (#230) * [Feature] move stories to TS (#223) (#231) * feat: setup TS for stories * fix: eslint was ignore .storybook * feat: add TS to storybook * refactor: move stories to TS (WIP) * refactor: move more stories to TS (WIP) * refactor: src changes for TS move over I think these were TS problems that were missed. * fix: ContactShadows story * refactor: move more stories to TS * refactor: add MapControls.tsx after raising issues in three Two errors linked to three.js: mrdoob/three.js#21058 mrdoob/three.js#21059 * fix: TS errors for passing refs & children * refactor: add more stories (WIP) * fix: useContextBridge TS to accept array of children fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729 * refactor: convert more stories to TS also useGLTF does not need to declare it's type * chore: update storybook * fix: revert useTexture accidentally committed a WIP change * refactor: move stories to TS (WIP) * refactor: revert useGLTF story * Minor type fixes * chore: update react-three-fiber to latest Required for Types * refactor: move stories to TS * fix: shaderMaterial on init returns void, not null * refactor: remove unnecessary type in useFBX * refactor: type Environment stronger there was issues with useAsset not understanding it's types.... * Fixes CSB CI (#230) Co-authored-by: Gianmarco Simone <gianmarcosimone89@gmail.com> Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com> * 2.2.16 * chore: add templates (#232) * chore: add react-dom as optional peer depency if you're using react-native you don't need it. * docs: update readme * fix: fix storybook imports that should have been done before my bad. Co-authored-by: Gianmarco <gianmarcosimone89@gmail.com>
* [Feature] move stories to TS (#223) (#231) * feat: setup TS for stories * fix: eslint was ignore .storybook * feat: add TS to storybook * refactor: move stories to TS (WIP) * refactor: move more stories to TS (WIP) * refactor: src changes for TS move over I think these were TS problems that were missed. * fix: ContactShadows story * refactor: move more stories to TS * refactor: add MapControls.tsx after raising issues in three Two errors linked to three.js: mrdoob/three.js#21058 mrdoob/three.js#21059 * fix: TS errors for passing refs & children * refactor: add more stories (WIP) * fix: useContextBridge TS to accept array of children fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729 * refactor: convert more stories to TS also useGLTF does not need to declare it's type * chore: update storybook * fix: revert useTexture accidentally committed a WIP change * refactor: move stories to TS (WIP) * refactor: revert useGLTF story * Minor type fixes * chore: update react-three-fiber to latest Required for Types * refactor: move stories to TS * fix: shaderMaterial on init returns void, not null * refactor: remove unnecessary type in useFBX * refactor: type Environment stronger there was issues with useAsset not understanding it's types.... * Fixes CSB CI (#230) Co-authored-by: Gianmarco Simone <gianmarcosimone89@gmail.com> Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com> * 2.2.16 * chore: add templates (#232) * chore: add react-dom as optional peer depency if you're using react-native you don't need it. * docs: update readme * fix: fix storybook imports that should have been done before * BREAKING CHANGE: refactor internal to solve react-native imports my bad. Co-authored-by: Gianmarco <gianmarcosimone89@gmail.com> * 2.3.0-beta.0 * fix: edit transformOutputPath to remove .ts from files * 2.3.0-beta.1 * fix: useAnimations ref type & chore: add storybook entry for useAnimations * Added THREE.Group to useAnimations types * Small refactor * Added useAnimations story * Clean up storybook * Fix null ref typing on useAnimations * Forgot to change typing on useAnimations api * chore: add storybook entry to README Co-authored-by: Josh Ellis <joshua.ellis18@gmail.com> * [fix] Blob is undefined when using SSR (#239) * fix: #233 Blob is undefined in SSR * refactor: it appears Billboard is fixed Looks like Typescript does not suck. * 2.3.0-beta.2 * fix: create polyfill for atob * 2.3.0-beta.3 * chore: update readme in response to #240 * fix: #242 Frustum has incorrect spelling in softshadows (#243) * fix: suggestion for fixing #242 * refactor: default should be other way round * chore: update readme with correct spelling * 2.3.0-beta.4 * feat: Add MeshoptDecoder support to useGLTF (#246) * Add MeshoptDecoder support to useGLTF * chore: move center Co-authored-by: Josh Ellis <joshua.ellis18@gmail.com> * 2.3.0-beta.5 * feat: #181 – adding points to line (#247) * feat: re-create geometry on new points * refactor: useMemo the geometry instead of useEffect * 2.3.0-beta.6 * 3.0.0-beta.1 * 3.0.0-beta.2 * feat: update troika with new features (#255) * 3.0.0-beta.3 * feat: add ability to add custom scene as prop (#256) * feat: add ability to add custom scene as prop * docs: update Environment with new feats * 3.0.0-beta.4 * refactor: shuffle imports for beta * 3.0.0-beta.5 * docs: clearly specify name of package & old has been deprecated * BREAKING CHANGE: Upgrade Three.js to r125 (#262) * chore: update Three.js dependency * refactor: remove subdivision modifier * fix: remove use of FaceNormalsHelper as it no longer exists in Three * fix: update typings for THREE * fix: update modifiers to work without THREE.Geometry * docs: update README * chore: add Three.js peer dependency * fix: change install instructions to use yarn instead of npm (#265) * repurpose reflector, make it capable to blur (#260) * repurpose reflector, make it capable to blur * refactor: move materials out to reduce noise & fix types * refactor: merge beta * fix: add child propType * refactor: update reflector story & fix children type * changes * fix: shuffle types so reflectorProps come from what the material expects * docs Co-authored-by: Josh Ellis <joshua.ellis18@gmail.com> * chore: add workflows to beta release * BREAKING CHANGE force build * 3.0.0-beta.6 Co-authored-by: Gianmarco Simone <gianmarcosimone89@gmail.com> Co-authored-by: Tanner Hartwig <tanner.hartwig57@gmail.com> Co-authored-by: Matt Rossman <rossman@gatech.edu> Co-authored-by: Renaud Rohlinger <renaud.rohlinger@gmail.com> Co-authored-by: Jure Triglav <juretriglav@gmail.com> Co-authored-by: Jason Bixon <jbixon13@gmail.com> Co-authored-by: Paul Henschel <drcmda@gmail.com>
|
Hey. |
|
It is not possible yet. |
|
So how do you type them when, for example, you need to iterate the children array and access the props? TS will not understand that the children has that props. This is key to produce high quality components that are type safe, is it at least on the roadmap? |
* feat: setup TS for stories * fix: eslint was ignore .storybook * feat: add TS to storybook * refactor: move stories to TS (WIP) * refactor: move more stories to TS (WIP) * refactor: src changes for TS move over I think these were TS problems that were missed. * fix: ContactShadows story * refactor: move more stories to TS * refactor: add MapControls.tsx after raising issues in three Two errors linked to three.js: mrdoob/three.js#21058 mrdoob/three.js#21059 * fix: TS errors for passing refs & children * refactor: add more stories (WIP) * fix: useContextBridge TS to accept array of children fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729 * refactor: convert more stories to TS also useGLTF does not need to declare it's type * chore: update storybook * fix: revert useTexture accidentally committed a WIP change * refactor: move stories to TS (WIP) * refactor: revert useGLTF story * Minor type fixes * chore: update react-three-fiber to latest Required for Types * refactor: move stories to TS * fix: shaderMaterial on init returns void, not null * refactor: remove unnecessary type in useFBX * refactor: type Environment stronger there was issues with useAsset not understanding it's types.... * Fixes CSB CI (#230) Co-authored-by: Gianmarco Simone <gianmarcosimone89@gmail.com>
* feat: setup TS for stories * fix: eslint was ignore .storybook * feat: add TS to storybook * refactor: move stories to TS (WIP) * refactor: move more stories to TS (WIP) * refactor: src changes for TS move over I think these were TS problems that were missed. * fix: ContactShadows story * refactor: move more stories to TS * refactor: add MapControls.tsx after raising issues in three Two errors linked to three.js: mrdoob/three.js#21058 mrdoob/three.js#21059 * fix: TS errors for passing refs & children * refactor: add more stories (WIP) * fix: useContextBridge TS to accept array of children fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729 * refactor: convert more stories to TS also useGLTF does not need to declare it's type * chore: update storybook * fix: revert useTexture accidentally committed a WIP change * refactor: move stories to TS (WIP) * refactor: revert useGLTF story * Minor type fixes * chore: update react-three-fiber to latest Required for Types * refactor: move stories to TS * fix: shaderMaterial on init returns void, not null * refactor: remove unnecessary type in useFBX * refactor: type Environment stronger there was issues with useAsset not understanding it's types.... * Fixes CSB CI (#230) Co-authored-by: Gianmarco Simone <gianmarcosimone89@gmail.com> Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com>
* change: move components into core folder * feat: add import types web & native index points to web to avoid breaking changes(?) but also cause that's a good default. * refactor: rollup so it looks for ts not tsx * refactor: move Html & Loader to web folder, make folders for native & web index points to web * Fixes CSB CI (#230) * [Feature] move stories to TS (#223) (#231) * feat: setup TS for stories * fix: eslint was ignore .storybook * feat: add TS to storybook * refactor: move stories to TS (WIP) * refactor: move more stories to TS (WIP) * refactor: src changes for TS move over I think these were TS problems that were missed. * fix: ContactShadows story * refactor: move more stories to TS * refactor: add MapControls.tsx after raising issues in three Two errors linked to three.js: mrdoob/three.js#21058 mrdoob/three.js#21059 * fix: TS errors for passing refs & children * refactor: add more stories (WIP) * fix: useContextBridge TS to accept array of children fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729 * refactor: convert more stories to TS also useGLTF does not need to declare it's type * chore: update storybook * fix: revert useTexture accidentally committed a WIP change * refactor: move stories to TS (WIP) * refactor: revert useGLTF story * Minor type fixes * chore: update react-three-fiber to latest Required for Types * refactor: move stories to TS * fix: shaderMaterial on init returns void, not null * refactor: remove unnecessary type in useFBX * refactor: type Environment stronger there was issues with useAsset not understanding it's types.... * Fixes CSB CI (#230) Co-authored-by: Gianmarco Simone <gianmarcosimone89@gmail.com> Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com> * 2.2.16 * chore: add templates (#232) * chore: add react-dom as optional peer depency if you're using react-native you don't need it. * docs: update readme * fix: fix storybook imports that should have been done before my bad. Co-authored-by: Gianmarco <gianmarcosimone89@gmail.com>
* [Feature] move stories to TS (#223) (#231) * feat: setup TS for stories * fix: eslint was ignore .storybook * feat: add TS to storybook * refactor: move stories to TS (WIP) * refactor: move more stories to TS (WIP) * refactor: src changes for TS move over I think these were TS problems that were missed. * fix: ContactShadows story * refactor: move more stories to TS * refactor: add MapControls.tsx after raising issues in three Two errors linked to three.js: mrdoob/three.js#21058 mrdoob/three.js#21059 * fix: TS errors for passing refs & children * refactor: add more stories (WIP) * fix: useContextBridge TS to accept array of children fixed using DefinitelyTyped/DefinitelyTyped#44572 (comment) because microsoft/TypeScript#14729 * refactor: convert more stories to TS also useGLTF does not need to declare it's type * chore: update storybook * fix: revert useTexture accidentally committed a WIP change * refactor: move stories to TS (WIP) * refactor: revert useGLTF story * Minor type fixes * chore: update react-three-fiber to latest Required for Types * refactor: move stories to TS * fix: shaderMaterial on init returns void, not null * refactor: remove unnecessary type in useFBX * refactor: type Environment stronger there was issues with useAsset not understanding it's types.... * Fixes CSB CI (#230) Co-authored-by: Gianmarco Simone <gianmarcosimone89@gmail.com> Co-authored-by: Josh <37798644+joshuaellis@users.noreply.github.com> * 2.2.16 * chore: add templates (#232) * chore: add react-dom as optional peer depency if you're using react-native you don't need it. * docs: update readme * fix: fix storybook imports that should have been done before * BREAKING CHANGE: refactor internal to solve react-native imports my bad. Co-authored-by: Gianmarco <gianmarcosimone89@gmail.com> * 2.3.0-beta.0 * fix: edit transformOutputPath to remove .ts from files * 2.3.0-beta.1 * fix: useAnimations ref type & chore: add storybook entry for useAnimations * Added THREE.Group to useAnimations types * Small refactor * Added useAnimations story * Clean up storybook * Fix null ref typing on useAnimations * Forgot to change typing on useAnimations api * chore: add storybook entry to README Co-authored-by: Josh Ellis <joshua.ellis18@gmail.com> * [fix] Blob is undefined when using SSR (#239) * fix: #233 Blob is undefined in SSR * refactor: it appears Billboard is fixed Looks like Typescript does not suck. * 2.3.0-beta.2 * fix: create polyfill for atob * 2.3.0-beta.3 * chore: update readme in response to #240 * fix: #242 Frustum has incorrect spelling in softshadows (#243) * fix: suggestion for fixing #242 * refactor: default should be other way round * chore: update readme with correct spelling * 2.3.0-beta.4 * feat: Add MeshoptDecoder support to useGLTF (#246) * Add MeshoptDecoder support to useGLTF * chore: move center Co-authored-by: Josh Ellis <joshua.ellis18@gmail.com> * 2.3.0-beta.5 * feat: #181 – adding points to line (#247) * feat: re-create geometry on new points * refactor: useMemo the geometry instead of useEffect * 2.3.0-beta.6 * 3.0.0-beta.1 * 3.0.0-beta.2 * feat: update troika with new features (#255) * 3.0.0-beta.3 * feat: add ability to add custom scene as prop (#256) * feat: add ability to add custom scene as prop * docs: update Environment with new feats * 3.0.0-beta.4 * refactor: shuffle imports for beta * 3.0.0-beta.5 * docs: clearly specify name of package & old has been deprecated * BREAKING CHANGE: Upgrade Three.js to r125 (#262) * chore: update Three.js dependency * refactor: remove subdivision modifier * fix: remove use of FaceNormalsHelper as it no longer exists in Three * fix: update typings for THREE * fix: update modifiers to work without THREE.Geometry * docs: update README * chore: add Three.js peer dependency * fix: change install instructions to use yarn instead of npm (#265) * repurpose reflector, make it capable to blur (#260) * repurpose reflector, make it capable to blur * refactor: move materials out to reduce noise & fix types * refactor: merge beta * fix: add child propType * refactor: update reflector story & fix children type * changes * fix: shuffle types so reflectorProps come from what the material expects * docs Co-authored-by: Josh Ellis <joshua.ellis18@gmail.com> * chore: add workflows to beta release * BREAKING CHANGE force build * 3.0.0-beta.6 Co-authored-by: Gianmarco Simone <gianmarcosimone89@gmail.com> Co-authored-by: Tanner Hartwig <tanner.hartwig57@gmail.com> Co-authored-by: Matt Rossman <rossman@gatech.edu> Co-authored-by: Renaud Rohlinger <renaud.rohlinger@gmail.com> Co-authored-by: Jure Triglav <juretriglav@gmail.com> Co-authored-by: Jason Bixon <jbixon13@gmail.com> Co-authored-by: Paul Henschel <drcmda@gmail.com>
This comment has been minimized.
This comment has been minimized.
|
@WilliamPeralta This is not a help channel for JSX component generics. This topic is specifically about the return type of JSX expressions. I would kindly recommend to delete the post so it isn't distracting, and ask in the appropriate channels (StackOverflow, Discord, etc). You'll get way better help that way. |
|
Joe, it's directly related. If JSX was typed as all other function calls,
TS would be able to infer generic parameters. It's not only a return type
problem, it's all about JSX being typed incorrectly.
…On Sat, Dec 4, 2021, 05:17 Joe Pea ***@***.***> wrote:
@WilliamPeralta <https://github.com/WilliamPeralta> This is not a help
channel for JSX component generics. This topic is specifically about the
return type of JSX expressions.
I would kindly recommend to delete the post so it isn't distracting, and
ask in the appropriate channels (StackOverflow, Discord, etc). You'll get *way
better* help that way.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#14729 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAWYQIIMDDKEXRQUUFQTIVLUPF22DANCNFSM4DEG63DQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
|
I'm all for proper types everywhere, but this issue is about the return types. Once those are in place, this opens room for the generics to be improved. @RyanCavanaugh As you fear the performance of JSX return types, what about a compromise? Either:
At least allow us to try the feature in a nightly release and see if it does as poorly as you say. Let us measure it! |
|
We kinda did with experimental builds, that's why we know the perf is so bad. |
|
Is it worse than nested function calls like |
|
No but yes. No, it's pretty much that exactly (slight note: class/function components are essentially two calls of cost per tag, rather than one), yes, because people don't chain generic functions 100 levels deep in practice (convention simply dictates you use a temporary variable after a few levels of nesting), but do chain jsx tags 100 levels deep. |
|
@weswigham would it much of a burden for your team if this were to land behind a flag? Most uses might not need generic JSX, but there are plenty of niche uses that would greatly benefit from this, and 100-level deep nesting of any kind can (and should) be avoided in well crafted code anyway. |
|
What about return types, without inference of generics? |
I'm voting for that second option. |
|
Any idea how to get JSX typing per file when using Before I could just use #22207:
namespace mything {
export namespace JSX {
type Element = ...
}
}
export function mything(...) {...}
/** @jsx mything */
import { mything } from './things'
const a = <a/>What can I do now? /edit: figured it out:
export namespace JSX {
type Element = ...
}
export function jsx(...) {...}
/** @jsxImportSource . */
const a = <a/> |
TypeScript currently uses a JSX namespace to type the props of JSX elements. This is customisable by modifying
JSX.IntrinsicElements,JSX.ElementClass. However, the type of an element is alwaysJSX.Element.Of course more interfaces could be added to the
JSXnamespace. However, I think that with less effort, the compiler could be made more flexible. I'd propose to check JSX elements based on a (virtual) call toJSX.createElement. For instance, the current behaviour can approximately be written like this:Given that function signatures are well customisable with the use of generics for instance, most requests can be implemented this way. For instance, #13890 and #13618 would benefit from this change. Libraries that use JSX, but not on the React-way, will benefit from this too.
Proposed semantics
For a JSX element, a virtual call to
JSX.createElementis constructed. It is passed three arguments:<div />). Otherwise, the identifier is passed (Foofor<Foo />).This should be roughly the same as the JSX transform used in the emitter phase. One notable difference is the following: in case of no properties or no children, an empty object or an empty array should be passed, instead ignoring the argument. This makes it easier to write
JSX.createElementfor library authors.Backwards compatibility
For backwards compatibility, one of the following approaches could be taken:
JSX.createElementdoes not exist.JSX.createElementdoes not exist, default it to (roughly) the definition above.Error reporting
When type checking the generated function call, the checker can give error messages like "Argument of type .. " or "Supplied parameters do not match any signature of call target". These messages should be replaced when checking JSX elements.
The text was updated successfully, but these errors were encountered: