Closed brct-james closed 1 year ago
Thanks for reporting. The type issues will be fixed with the next version.
FYI, I am not adding @types/d3
as the types are automatically resolved for me. If you have a reproducible example, I can look into it.
I've tested regl-scatterplot with the following simple Vite+TS setup and I don't see any type issues.
package.json
{
"name": "regl-scatterplot-ts-test",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"devDependencies": {
"typescript": "^4.9.3",
"vite": "^4.0.0"
},
"dependencies": {
"regl-scatterplot": "1.5.0"
}
}
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
src/main.ts
import { setupScatter } from './scatter';
document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
<div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0;">
<canvas
id="canvas"
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
/>
</div>
`
setupScatter(document.querySelector('#canvas')!);
src/scatter.ts
import createScatterplot from 'regl-scatterplot';
const generatePoints = (length: number) => ({
x: Array.from({ length }, () => -1 + Math.random() * 2),
y: Array.from({ length }, () => -1 + Math.random() * 2),
z: Array.from({ length }, () => Math.round(Math.random())), // category
w: Array.from({ length }, () => Math.random()), // value
});
export function setupScatter(canvas: HTMLCanvasElement) {
const scatter = createScatterplot({ canvas });
scatter.draw(generatePoints(10000));
}
I am going to close this issue for now. But if you're still running into problem, please reopen the ticket and provide a reproducible example.
I encountered the same issue as @joaorulff in #43 while integrating this with an existing Angular project. It seems the camera-2d-simple module does not have a type declaration file, which should be a relatively easy fix since you author both projects. Error:
There is also an issue that I assume to be caused by the relative path
import('./renderer')
in types.d.ts#L126. Error:Finally, I also had this issue:
Which was easily resolved with
npm install @types/d3 --save-dev
. It's not clear to me why the necessary types aren't being installed withd3-scale
itself, but perhaps adding@types/d3
to the dependencies would fix this.For all of these issues, using the
--skipLibCheck
typescript option or including the following intsconfig.json
is a workaround.