VS code Intellisense with JS - ArcGIS API (not TS)

1837
6
Jump to solution
04-03-2018 02:23 PM
Ravichandran_M_Kaushika
Occasional Contributor

dear readers,

using NPM install etc and using Mr. Rene's video, I was able to get Intellisense of  ArcGIS API to work in VS Code 1.21.x.  It was very useful.

Now is getting the same EXPERIENCE with JS not possible? are there any links I could look at?

thanks to all.  Special thanks to Mr. Rene for taking the time to do you tube videos.

regards

ravi.

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

You can install the typings for the JSAPI and if you write your code with ES6 imports using babel to transform your code, you can get intellisense in your code.

I have a couple of videos on this.

This ones a little long, but info is there: TypeScript Typings for JavaScript - YouTube 

This one talks about using babel for to transpile: Set up Babel for your ArcGIS API for JavaScript Project - YouTube 

Hope that helps.

View solution in original post

6 Replies
ReneRubalcava
Frequent Contributor

You can install the typings for the JSAPI and if you write your code with ES6 imports using babel to transform your code, you can get intellisense in your code.

I have a couple of videos on this.

This ones a little long, but info is there: TypeScript Typings for JavaScript - YouTube 

This one talks about using babel for to transpile: Set up Babel for your ArcGIS API for JavaScript Project - YouTube 

Hope that helps.

Ravichandran_M_Kaushika
Occasional Contributor

Rene,

good afternoon. thanks a lot for the awesome videos. it helped me a quite a bit.

regards

ravi.

0 Kudos
VovaZhdanov
New Contributor II

Rene, 

I followed your videos and I was able to get it work, but when I am using intellisense it doesn't compile "watchUtils" it comes out always undefined. It works with everything else but not the Utils. If I go to the compiled file and just erase *2.default it works. Is there a specific way to use it? I really don't want to go back and write code without the intellisense, I would appreciate your help.

Thank you.  

0 Kudos
ReneRubalcava
Frequent Contributor

If I remember right, watchUtils is a module where you need to import * as watchUtils from "esri/core/watchUtils"

Of you could import the individual exports, import { whenFalseOnce } from "esri/core/watchUtils"

That should work with the typings.

0 Kudos
VovaZhdanov
New Contributor II

This is what I am doing: first I import the module 

import watchUtils from "esri/core/watchUtils";

Then I use it in the code 

/* Check for map extent change */
watchUtils.whenFalse(view'stationary'function (evt) {
    if (!view.stationary) {
        watchUtils.whenTrueOnce(view'stationary'function (evt) {
            if (view.extent) {
                if (lf.getInteriorReferenceLayerMinScale()) {
                    if (lf.interiorReferenceLayerMinScale >= view.scale) {
                        floorButton.displayFloorButtons(view.extentdom);
                    }
                    else {
                        floorButton.hideFloorButtons(dom);
                    }
                }
            }
        });
    } else {
        watchUtils.whenFalseOnce(view'interacting'function (evt) {
            console.log(view.extent);
        });
    }
})

and in the console I get:

dojo.js:19 Uncaught TypeError: Cannot read property 'whenFalse' of undefined

VovaZhdanov
New Contributor II

Rene, 

The second way of importing worked, if you import each method separately it works! Thank you for the tip! 

0 Kudos