Closed ekrapfl closed 4 years ago
Hey @ekrapfl, your approach is good, there is no incorrect answer as related to noImplicitAny. You do raise a good point and I can definitely update the code and make the typings implementation cleaner if someone does set that flag. Here's a quote from the Angular docs https://angular.io/guide/typescript-configuration:
* TypeScript developers disagree about whether the noImplicitAny flag should be true or false. There is no [in]correct answer and you can change the flag later. But your choice now can make a difference in larger projects, so it merits discussion.
Also note, you can set "esModuleInterop": true
in tsconfig.json
and then you should be able to use this pattern with "noImplicitAny": true
:
import Map from "esri/Map";
I'll make some updates.
Thanks for the feedback @andygup! Just wanted to make sure I wasn't doing anything wrong :)
I am looking into using the
arcgis-angular-webpack
branch as an example for how to implement nice module loading for the ArcGIS JS API in our Angular application. I have used the branch as an example, and it seems to work pretty well. One thing of note, however, is that when you import modules the way the example shows:They are imported as
any
This is pretty problematic to use, and in a lot of cases, people like to use thenoImplicitAny
compiler flag. This workflow will not allow you to do that.In my experimentation, I was able to structure the imports as such:
This is using the module names as defined in the typings, and by doing so, the imported modules come in with the correct typings. It seems much nicer this way, and everything seems to continue functioning.
My question is: Is what I am doing a bad practice in some way? If not, could the example be updated to import in this way?
Thanks, Eben