Closed
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Problem
I'm using TypeScript with "moduleResolution": "Node16"
and JSX, and I want to have explicit return types. Currently I do this:
import type { Root, Element } from "hast";
const Foo = (): Root | Element => <div />;
Instead, I'd like to be able to do this:
const Foo = (): JSX.Element => <div />;
I know it's an alias of HResult
, which can be imported from lib/core
, but it isn't idiomatic, and lib/core
currently isn't exposed, so it doesn't work in this module resolution mode.
Solution
@types/react
puts JSX in declare global
. Could hastscript
do that too?
Alternatives
Export lib/core
.