-
-
Notifications
You must be signed in to change notification settings - Fork 8
Description
What’s happening?
When a project uses modern module resolution (e.g. Next 15’s default "moduleResolution": "bundler" or any environment that honours the exports map), TypeScript can’t see react-ogl’s declaration file:
Could not find a declaration file for module 'react-ogl'
react-ogl does ship ./dist/index.d.ts and even declares it via
"types": "./dist/index.d.ts", but the package’s exports map only exposes JavaScript:
Once an exports map is present, Node & TS ignore the legacy types field and rely solely on the map.
Because index.d.ts isn’t referenced there, resolvers treat the package as untyped.
Minimal reproduction
-
npx create-next-app@latest --typescript(Next 15) -
yarn add ogl react-ogl -
Add a file:
import { Canvas } from 'react-ogl'; // ❌ TS7016: Could not find a declaration file …
-
Run
yarn tsc– the error appears.
Expected behaviour
TypeScript should pick up the shipped declarations without extra config or patches.
Actual behaviour
Typings are invisible
Fix (I think this should fix it)
Expose the type file inside the exports map:
- "exports": "./dist/index.mjs",
+ "exports": {
+ ".": {
+ "import": "./dist/index.mjs",
+ "types": "./dist/index.d.ts"
+ }
+ },This would be backwards-compatible (old Node/TS still read main/module/types)
My Environment
| package | version |
|---|---|
| react-ogl | 0.15.0 |
| ogl | 1.0.11 |
| typescript | 5.3.x |
| next | 15.x |
| node | 20.x |
Thanks for the great library!