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

Cannot find namespace 'THREE' error, when using with Angular 16. #110

Open
VadimKhismatov opened this issue Aug 9, 2024 · 3 comments
Open

Comments

@VadimKhismatov
Copy link

Hello. I am trying to implement dxf-viewer to my project on Angular 16. But I have error when building my project Cannot find namespace 'THREE'. All i did is installed packages dxf-viewer and three.js, added imports to component and run project with ng serve command, after that received several errors like this:

Error: node_modules/dxf-viewer/src/index.d.ts:21:17 - error TS2503: Cannot find namespace 'THREE'. 21 clearColor: THREE.Color,

My imports:
import * as THREE from 'three'; import { DxfViewer } from "dxf-viewer";

This is stackblitz example with same errors.

How to fix this error?

@vagran
Copy link
Owner

vagran commented Aug 9, 2024

It seems that the problem is that src/index.d.ts does not import three.js. It worked for me, but probably it depends on bundler/compiler. I am not really aware, if TS types declaration file should import something.

@igortheodoro
Copy link

Did you manage to solve this? I'm having the same issue here.

@VadimKhismatov
Copy link
Author

Hello. I cloned package and added it to my project in root level of src folder src/dxf-viewer, after this added
import * as THREE from 'three'; to dxf-viewer/src/index.d.ts file. In my component I import lib as always import { DxfViewer } from "src/dxf-viewer";but with path to my copy, not to node_modules. It seems to work for now, but if add worker like in example it still has same error for other declarations for DOM elements and other. May be if to make a build and add it to project, will be no errors, but in this case, all typing will be lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants