1

I am using react and Next.js, I am following this guide https://github.com/observablehq/plot with the goal to render/visualize some data from a heroku postgres DB. I used npm install @observablehq/plot.

import * as Plot from '@observablehq/plot'

This import line is raising a ts7016 error:

Could not find a declaration file for module '@observablehq/plot'. '/Users/alejandrozapien/bexar-dash/node_modules/@observablehq/plot/src/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/observablehq__plot` if it exists or add a new declaration (.d.ts) file containing `declare module '@observablehq/plot';

I am new to learning Typescript and creating declaration files. How should I go about resolving this error properly? I read I should create a global.d.ts file but I am unsure of where to place that file or how to structure it

  • Does this answer your question? [Could not find a declaration file for module 'module-name'. '/path/to/module-name.js' implicitly has an 'any' type](https://stackoverflow.com/questions/41292559/could-not-find-a-declaration-file-for-module-module-name-path-to-module-nam) – juliomalves Nov 08 '21 at 22:36
  • It helped thank you, I created a single file in the project root named observablehq.d.ts and it has a single ‘declare module’ statement. That resolved the issue, however I feel it’s a bit excessive to create its own file. My question is where should I put a single file fire statements like this in my project tree? – Alejandro Zapien Nov 10 '21 at 00:38
  • I wouldn't say it's excessive if it helps you remember why you did that, looking back after you've forgot. – bgoosman Dec 06 '22 at 22:44
  • Plot now exports declaration files, as of v0.6.5, released April 1. https://github.com/observablehq/plot/blob/main/CHANGELOG.md#065 – Toph Jun 23 '23 at 20:16

0 Answers0