gdsestimating / three-dxf

A dxf viewer for the browser using three.js
MIT License
546 stars 171 forks source link

Can't import #65

Open AAshSa opened 3 years ago

AAshSa commented 3 years ago

Sorry, beginner in Angular here. I got dxf-parser to install types by running npm install dxf-parser-typings. But three-dxf shows this error after installing it: Could not find a declaration file for module 'three-dxf'. .../ClientApp/node_modules/three-dxf/dist/three-dxf.js' implicitly has an 'any' type. Try npm i --save-dev @types/three-dxf if it exists or add a new declaration (.d.ts) file containing declare module 'three-dxf';ts(7016)

I have tried running npm i --save-dev @types/three-dxf, npm install @types/three-dxf, and npm install three-dxf-typings and it shows this error in the console: npm ERR! code E404 npm ERR! 404 Not Found - GET http://registry.npmjs.org/three-dxf-typings - Not found npm ERR! 404 npm ERR! 404 'three-dxf-typings@latest' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url.

Please help :(

bzuillsmith commented 3 years ago

No one has sat down and defined TypeScript definitions for the library. I believe that means you need to go the route of declare module 'three-dxf'; as it says in the error message there and you just won't get compile-time help. But I'm not entirely sure, it's been a while since I've had to use an untyped library in typescript.

oubenruing commented 3 years ago

Adding an index.d.ts file to the '/src' directory might solve this problem temporarily, which is what I did under my typescript project. This also does not give full compile-time help.

//index.d.ts
export declare class Viewer {
  constructor(data: any, parent: Element, width: number, height: number, font: any);
}
AAshSa commented 3 years ago

Adding an index.d.ts file to the '/src' directory might solve this problem temporarily, which is what I did under my typescript project. This also does not give full compile-time help.

//index.d.ts
export declare class Viewer {
  constructor(data: any, parent: Element, width: number, height: number, font: any);
}

I did end up creating my own typings file and it was able to call it okay, but like you mentioned then there were build issues which I was able to sort out some, but then some were caused by a mismatch of THREE.js since Geometry and Face3 are now depreciated and this uses that.

bzuillsmith commented 3 years ago

then some were caused by a mismatch of THREE.js since Geometry and Face3 are now depreciated and this uses that.

The latest version resolves this issue. We no longer use Face3 and are compatible with the latest version of Three