'Trying to use turf js in angular 5

I'm an angular 5 (and turfjs) noob trying to use the turfjs along().

I've got a pretty simple working angular 5 project (built with angular-cli).

To add turf I ran:

npm install @turf/along --save

and I see @turf/along in my node modules directory. I tried just adding to my js file:

declare var along: any;

but that didn't work. I also tried adding

"../node_modules/@turf/along/index.js"

to my angular-cli.json file, but no luck.

What is the correct way to import this method so I can use it?



Solution 1:[1]

Ok, (eventually) I discovered that I can just use

import along from '@turf/along';

No declarations or need to mess with other files (e.g. angular-cli.json) and I use it just as if it was defined locally.

If there is a more "TypeScript" way to do this, please drop a comment.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 eze