Closed misogohan closed 2 years ago
It might be that if url + '/index.d.ts' does not exist, it assumes there isn't a types file for it. I found another module that it was able to add x-typescript-types header for sub modules.
https://esm.sh/@heroicons/react@1.0.5/outline
It's types was
https://esm.sh/@heroicons/react@1.0.5/outline/index.d.ts
.
Maybe having it fallback to checking '.d.ts' would be a reasonable solution that would resolve the issue of it not being able to get the types for these react submodules.
now support submodule types from @types
example: https://github.com/alephjs/esm.sh/tree/master/test/deno/react-jsx-runtime
Case
I knew that Deno 1.16 supports new JSX transforms, and have tried it with https://esm.sh/react.
Minimum code:
After running
deno run
, I got this:However, I can dispense with these errors when I use https://esm.sh/preact instead of react.
Cause
With the new JSX transforms, TypeScript implicitly looks up https://esm.sh/react/jsx-runtime, but because its response header does not include
X-TypeScript-Types
, Deno cannot find the type declaration file of it, and TypeScript cannot resolveJSX
namespace.cf. https://esm.sh/preact/jsx-runtime has
X-TypeScript-Types
header, and such errors does not occur.Solution
I confirmed that there is the type declaration at https://cdn.esm.sh/v58/@types/react/jsx-runtime.d.ts. So just to link it, I guess.
Additional info