-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
Expose ~JSX namespace~ HResult
globally
#18
Comments
Sounds like something @remcohaszing has ideas on! |
The A quick history on this topic:
As far as I know, this requires a global JSX namespace. However, this issue suggests this is incorrect. If this is indeed incorrect, then IMO it is the desired behaviour, because it would allow to mix multiple JSX implementationg using JSX comments. I do think it would be nice to expose the import { HResult } from 'hastscript'
const Foo = (): HResult => <div />; |
Thanks, that makes sense! So I went ahead and checked if anybody has reported this in TypeScript, since this feels like their responsibility, and I found something even better: microsoft/TypeScript#41330 (comment) Here's how Preact implemented it: https://github.com/preactjs/preact/pull/2811/files Edit: And I see that it's already exported, so why doesn't it work? Edit 2: Ah, likely because it isn't re-exported here and here and here. Edit 3: No, I still don't understand why this isn't sufficient: // svg/jsx-runtime.d.ts
export * from '../lib/runtime-svg.js'
// lib/runtime-svg.d.ts
export * from './jsx-automatic.js'
// lib/jsx-automatic.d.ts
export namespace JSX ... Edit 4: Okay, finally found the definitive answer to this: microsoft/TypeScript#47072 (comment) The JSX namespace is an implementation detail, not meant to be public. So, in the end, |
As far as I understand the above comments, then it would be bad to do this? |
Yep! Looks like
I believe so. The name is a little cryptic, but it's not worth a refactor, and breaking existing consumers. |
I’m up for exposing |
HResult
globally
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Released in 7.1.0! I noticed that HChild, HProperties, were also exposed as |
Sorry for the radio silence, thank you! |
Initial checklist
Problem
I'm using TypeScript with
"moduleResolution": "Node16"
and JSX, and I want to have explicit return types. Currently I do this:Instead, I'd like to be able to do this:
I know it's an alias of
HResult
, which can be imported fromlib/core
, but it isn't idiomatic, andlib/core
currently isn't exposed, so it doesn't work in this module resolution mode.Solution
@types/react
puts JSX indeclare global
. Couldhastscript
do that too?Alternatives
Export
lib/core
.The text was updated successfully, but these errors were encountered: