taye / taye/interact.js

Typescript implementation doesn't work with individual modules

Open
#933 13 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
12.9k
Forks
804
PR merge metrics
No merged PRs in 30d

Description

Expected 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'.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure in the linked StackBlitz using index.ts and the two individual imports, then inspect @interactjs/interact/index.js, its shipped type declarations, and the @interactjs/core package. Done means TypeScript resolves declarations for @interactjs/interact and module imports also work with pnpm or yarn workspaces without relying on adjacent scoped packages.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.