Select to view content in your preferred language

@arcgis/core ES Modules auto imports typescript

652
2
07-11-2022 04:32 PM
DavidWilton
Occasional Contributor II

Does anyone know why auto imports won't work with core in VSCode? They work fine when using the types 

I have resolved the issue by creating a definition file based on the types and a find and replace. However, I'd like to know why/get esri to fix this so I don't have to maintain this.

Without my definition file, no suggestions show up for esri imports:

DavidWilton_0-1657582158375.png

 

With my definition file, I get auto complete suggestions:

DavidWilton_1-1657582224890.png

 

 

0 Kudos
2 Replies
ReneRubalcava
Frequent Contributor II

Not sure. Looks like vscode isn't scanning all the d.ts files. Not much we can do to force it to work. Maybe a way to configure this in the jsconfig for vscode, but not something I've looked into. Relying on module names for autoimports is a little iffy because default imports aren't named, so you can call SceneView, ArcGISSceneView, or SV, so not sure how vscode handles that.

0 Kudos
NiklasKöhn
Esri Contributor

Hey @DavidWilton @ReneRubalcava,

warming up this topic one year after the fact.. I hope it's not too late for you. I've had the exact same issue in projects using @arcgis/core (ESM), no matter which other tools (webpack, vite, react, ...) were involved. The solution: Explicitely include the definition in tsconfig.json like:

"include": ["./src/**/*", "./node_modules/@arcgis/core/**/*.d.ts"]

With this entry I have auto import in all of my projects, while intellisense and type checking did work without it. ✌️