TypeScript 4.1 + Preact: TypeScript does not pick up JSX.IntrinsicElements w. jsx: react-jsx #41118
Labels
Bug
A bug in TypeScript
Domain: JSX/TSX
Relates to the JSX parser and emitter
Fix Available
A PR has been opened for this issue
Milestone
Uh oh!
There was an error while loading. Please reload this page.
This is Re: #40502 cc @weswigham @DanielRosenwasser
Using the new JSX transform and Preact as import source, TypeScript doesn't seem to pick up the JSX types that are shipped by Preact. It works as described in #40502 with additionally installed
@types/react
, but not with the types that come with Preact itself. Daniel suggested filing a new bug 😄TypeScript Version: 4.1.0-dev.20201015
Search Terms: Preact, JSX, JSX Transform
Code
This is the
d.ts
file that contains the JSX definitions: https://github.com/preactjs/preact/blob/master/jsx-runtime/src/index.d.tsNote: The JSX definitions are in the
jsx
andjsxDEV
namespaces. I thought this might be an issue. But If I move JSX into the global namespace withI get a compile error: Cannot read property 'get' of undefined
Expected behavior: Since TypeScript knows to pull in jsx from
preact/jsx-runtime
, I'd expect it to pull in JSX types frompreact/jsx-runtime/src/index.d.ts
.Actual behavior: JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists.ts(7026)
Playground Link: I have a branch in a repo: https://github.com/ddprrt/preact-typescript-starter/tree/jsx-transform
Related Issues: #40502
The text was updated successfully, but these errors were encountered: