Typescript implementation doesn't work with individual modules
See original GitHub issueExpected behavior
You should be able to import the parts of the library individually and types should work. Unfortunately due to the way the types packages are defined this doesn’t currently function. I believe also the current module structure expects a certain layout in the node_modules folders which means this project doesn’t work with alternative node_module package managers like pnpm or yarn workspaces.
https://stackblitz.com/edit/typescript-ff3ss5?file=index.ts
Importing using this form:
import '@interactjs/actions/drag';
import interact from '@interactjs/interact';
Actual behavior
Assuming you’re using npm, then the above will result in a typescript error: Could not find a declaration file for module '@interactjs/interact'
This is because the @interactjs/interact
package does not actually define a types field and the index.js
has no adjacent index.d.ts
in the shipped package.
If you’re using pnpm or other package managers that don’t necessarily put all the scoped packages adjacent to each other, then the form of import used in the @interactjs/interact/index.js
will cause issues:
import { Scope } from "../core/scope.js";
This makes the assumption that the @interactjs/interact
module is adjacent and findable through the relative module resolution here. Which is not guaranteed to be the case, the correct import would be import { Scope } from '@interactjs/core'
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:11 (2 by maintainers)
Top GitHub Comments
not stale
The situation is improved with the latest version. You shouldn’t need to install or import
@interactjs/types
.