Typescript does not resolve esri/Map

3008
4
07-19-2019 05:19 AM
DavidGilmore
New Contributor

I have Typescript code that tries to use ESRI in a jQuery environment.  I have installed arcgis-js-api with NPM, and I have tried a number of things from various pages located here at ESRI concerning ArcGIS, Typescript, jQuery, and Visual Studio.  Nothing has borne fruit.  After stripping down the code as much as possible, I find it's the import that doesn't work;  tsc tries to resolve the module at that line and it can't do so, and it fails.

This was originally a very complicated thing in Visual Studio 2017.  The build is set up to use a tsconfig.json, which VS recognizes and employs.  When things didn't work I figured out what tsc VS was using (they put in four for some reason) and how to invoke it in a command window to see the errors VS was hiding from me.  Since then I've been attempting to build this cli only, to remove VS from the picture.  I mention VS mainly because 'intellisense' seems to know what everything is.  If I add a line to create a Map object, it doesn't show anything is wrong.  Most likely that's not relevant, but it is the case.

I've spent considerable time trying various things from module related searches on the 'net, but so far I've not hit upon the magic that makes it work

0 Kudos
4 Replies
Noah-Sager
Esri Regular Contributor

Hi David,

Did you install the JS API typings as well as the API?

npm install --save @types/arcgis-js-api

TypeScript - Setting up your development environment | ArcGIS API for JavaScript 4.12 

0 Kudos
DavidGilmore
New Contributor

Sorry for the late response.  I got pulled off this project for a while.  Yes I did install the typings as well, and I see them on the hard drive.

0 Kudos
by Anonymous User
Not applicable

Hi David,

Which project type in vs2017 are you using?

For command line , you can use that extension from vs marketplace to get more detail error.

Open Command Line - Visual Studio Marketplace 

And then you can use the Keyboard Shortcut ALT+Space instead of the context menu to open the command prompt.

You can then run your npm command: and see the error detail

DavidGilmore
New Contributor

After some time I got all the compiler errors to go away, but only after I stopped using the import statement in my code.  It still doesn't do things properly ... I have to use __esri.map for instance instead of just Map.  But it works.

0 Kudos