This is an example of a module I am currently utilizing in my project.
I have come across TypeScript type definitions for the npm module polylabel, which can be found at https://github.com/mapbox/polylabel. When I run
npm install --save @types/polylabel
, I get the types. However, when I run npm install --save polylabel
, I only get the npm module itself.
My question is how can I import polylabel
while still using the TypeScript type definitions from @types/polylabel
? For instance:
import polylabel from "polylabel";
export default class SomeClass extends Base {
console.log(polylabel(coordinates, 1.0))
}
The above code will not work as expected, as TypeScript will attempt to import a function that is defined but not functional from the module itself.
Should I include the module in webpack directly, or is there another solution to this issue? As for the webpack configuration:
new webpack.ProvidePlugin({
polylabel: 'polylabel'
}),
I hope this clarifies the question regarding the problem I am trying to solve.