Typings problem: Incorrect Import Path in TypeScript Declaration
Hello @crotwell,
First, thank you for your work on the seisplotjs library. We are using your library in a Next.js application with TypeScript, and we encountered an issue with the typings.
Problem: The current TypeScript declaration file specifies the import path incorrectly, which causes TypeScript to fail during compilation and results also to in errors in IDE. The problematic declaration is as follows:
declare module 'seisplotjs' {
import main = require('seisplotjs/index');
export = main;
}
Steps to Reproduce: 1. Create a Next.js project with TypeScript. 2. Install seisplotjs. 3. Attempt to import seisplotjs in a TypeScript file. 4. Observe the TypeScript compilation error due to the incorrect import path.
Workaround: We created a custom TypeScript declaration file in our project to override the incorrect import path. Here is the workaround we used:
declare module 'seisplotjs' {
import main = require('seisplotjs/src/index');
export = main;
}
Possible Fix: To address this issue permanently, you could update the dts script in your package.json to generate the correct declaration files. This can be done by adding the --entry option to specify the correct entry point, which is the same approach used for Node.js typings.
"scripts": {
/* ... */
"dts": "npx npm-dts generate --entry src/index.ts --output dist/index.d.ts",
/* ... */
}