I'd like to use the JavaScript package cesium-navigation (that installs via npm
and node
) in my project. However, my project uses webpack and TypeScript instead of just plain JavaScript. The package itself is not available in the npm repository, meaning it cannot be employed using npm install 'packageNameHere' --save
; additionally, the use of javascript in that package means that no types exist for use in TypeScript.
How can I adapt this package to be used in a TypeScript, webmodules environment? Would I have to install this manually every time I wanted to use it?
Add a file named types.d.ts
and declare the module.
declare module "Cesium";
You can also declare all of the available options and types. You might need to restart typescript so the new types get picked up.
If you use Visual Studio Code - hover over the import statement and it will tell you what to put in your types.d.ts file.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.