Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to use turf js in angular 5 (noob)

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?

like image 996
eze Avatar asked Jul 26 '18 11:07

eze


1 Answers

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.

like image 177
eze Avatar answered Oct 05 '22 04:10

eze