PIXI types not loading in ESM project
See original GitHub issueCirca the latest version of pixi, I am unable to have typescript resolve the pixi import because it cannot find the associated types file. This is likely due to it resolving the import to dist/cjs/pixi.js
, and attempting to find the .d.ts
in that folder instead of index.d.ts
.
Expected Behavior
pixi.js is able to be included by typescript in ESM mode
Current Behavior
Typescript is unable to find the types for it
Possible Solution
This can be fixed via adjustments to the package.json
(in my case at least, not sure if there are other cases I’m not thinking about)
For more detail, see this page from the ts 4.7 release notes
{
"exports": {
".": {
"import": {
"default": "dist/esm/pixi.js",
"types": "index.d.ts"
},
"require": {
"default": "dist/cjs/pixi.js",
"types": "index.d.ts"
}
}
},
"types": "index.d.ts"
}
Steps to Reproduce
Create a new project with ts 4.7 and pixi. In the compiler options, set module
to NodeNext
and in the package.json
set type
to module
. Create a new typescript file and import something from pixi.js
. Typescript will throw an error.
Environment
pixi.js
version: 6.3.2typescript
version: 4.7.2- Browser & Version: N/A
- OS & Version: MacOS 12.1
- Running Example: N/A (could probably throw one together if needed)
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top GitHub Comments
All packages, please!
I don’t think there is much harm in this as it is backward compatible. This all seem rather new but would unblock 4.7+ TS users.
So yeah, PR welcome. Thanks for offering.