danchitnis / webgl-plot

A high-Performance real-time 2D plotting library based on native WebGL
https://danchitnis.github.io/webgl-plot-examples/vanilla/
MIT License
576 stars 33 forks source link

Fixed export of typing #79

Closed na-trium-144 closed 1 year ago

na-trium-144 commented 1 year ago

Fixed the following error which occured when I tried to use this library in my typescript project, due to specification change of typescript.

src/components/valueCard.tsx:4:49 - error TS7016: Could not find a declaration file for module 'webgl-plot'. '/Users/kou/projects/webcface1/webui/node_modules/webgl-plot/dist/webglplot.esm.mjs' implicitly has an 'any' type.
  There are types at '/Users/kou/projects/webcface1/webui/node_modules/webgl-plot/dist/webglplot.d.ts', but this result could not be resolved when respecting package.json "exports". The 'webgl-plot' library may need to update its package.json or typings.

4 import { WebglPlot, WebglLine, ColorRGBA } from "webgl-plot";
                                                  ~~~~~~~~~~~~
danchitnis commented 1 year ago

Thanks. Can you duplicate the error in CodeSandbox? It may create breaking changes for some

na-trium-144 commented 1 year ago

https://codesandbox.io/p/sandbox/interesting-ben-m5f9zl?welcome=true This reproduces the error using the latest typescript and the same code given in the readme.

danchitnis commented 1 year ago

Why are you doing npx tsc? The compile should be part of your build process set to be typescript. You don't need to run typescript compile manually each time. As you see the build is passing without any errors.

na-trium-144 commented 1 year ago

Because Parcel does not check types on build process. Also, CodeSandbox uses older version of typescript by default. So I needed to install the latest typescript and run npx tsc manually to reproduce the error in CodeSandbox.

danchitnis commented 1 year ago

It is fixed now in version v0.7.1. However, in your example in tsconfig.json change "moduleResolution": "NodeNext" to "moduleResolution": "node"