Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definition file missing several type definitions #659

Closed
programmer24601 opened this issue Apr 19, 2023 · 3 comments
Closed

Definition file missing several type definitions #659

programmer24601 opened this issue Apr 19, 2023 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@programmer24601
Copy link

When attempting to transpile typescript > javascript for version 0.1.40 the compiler complains about the following missing type definitions:

> tsc

Error: node_modules/@napi-rs/canvas/index.d.ts(41,20): error TS2552: Cannot find name 'DOMMatrixInit'. Did you mean 'DOMMatrix2DInit'?
Error: node_modules/@napi-rs/canvas/index.d.ts(58,26): error TS2552: Cannot find name 'DOMPointInit'. Did you mean 'DOMPoint'?
Error: node_modules/@napi-rs/canvas/index.d.ts(87,24): error TS2552: Cannot find name 'DOMMatrixInit'. Did you mean 'DOMMatrix2DInit'?
Error: node_modules/@napi-rs/canvas/index.d.ts(88,27): error TS2552: Cannot find name 'DOMMatrixInit'. Did you mean 'DOMMatrix2DInit'?
Error: node_modules/@napi-rs/canvas/index.d.ts(119,22): error TS2552: Cannot find name 'DOMMatrixInit'. Did you mean 'DOMMatrix2DInit'?
Error: node_modules/@napi-rs/canvas/index.d.ts(144,20): error TS2304: Cannot find name 'DOMRectInit'.
Error: node_modules/@napi-rs/canvas/index.d.ts(152,28): error TS2552: Cannot find name 'DOMMatrixInit'. Did you mean 'DOMMatrix2DInit'?
Error: node_modules/@napi-rs/canvas/index.d.ts(166,21): error TS2552: Cannot find name 'DOMPointInit'. Did you mean 'DOMPoint'?
Error: node_modules/@napi-rs/canvas/index.d.ts(253,5): error TS2304: Cannot find name 'CanvasRenderingContext2D'.
Error: node_modules/@napi-rs/canvas/index.d.ts(262,66): error TS2304: Cannot find name 'CanvasGradient'.
Error: node_modules/@napi-rs/canvas/index.d.ts(279,6): error TS2304: Cannot find name 'CanvasPattern'.
Error: Process completed with exit code 2.
@Brooooooklyn Brooooooklyn added help wanted Extra attention is needed good first issue Good for newcomers labels Apr 24, 2023
@Milan9805
Copy link

Any progress on this? Also hitting this issue

@programmer24601
Copy link
Author

This can be resolved by adding "dom" to the "lib" property in your tsconfig.json:

  "compilerOptions": {
    "lib": ["ES2022", "dom"],
    ...

@chearon
Copy link

chearon commented Dec 31, 2024

I think this should be reopened. Including "dom" in lib is not a good solution because it adds a whole bunch of ambient types like navigator and window that aren't actually defined in node. If you use a triple-slash directive, you'll pollute the global namespace for any (indirect) importers: I opened samizdatco/skia-canvas#211 today. So the only real solution is to write out the types manually, which is what we did in node-canvas: Automattic/node-canvas#2174.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants