-
Notifications
You must be signed in to change notification settings - Fork 5
Loading with v4 arcgis-js-api.d.ts #7
Comments
This is a good idea @nickcam. Can you share the cod you wrote, even if it's not working yet? |
Hi @tomwayson, In a nutshell, I got it working using the official *.d.ts file....but only when transpiling typescript using 'system' as the module type. The other types would work but would require minor edits to the *.d.ts file. The original loading remains intact, but if you specify an option of esriSystem.ts
Calling using maintainModuleNames.
Then to import just use the default import syntax.
This keeps Visual Studio happy which appears to be the harder to satisfy IDE as far as typescript compilation errors go. It works as system modules automatically add a default property to modules, so we can name the export 'default' in the register call and it will resolve when importing. Other module loaders don't do this, although to be honest I only tested commonjs. There's probably a better way to do it that's more consistent across module loaders though. It would still be nice if the official typings were changed to be more compliant with loaders/IDE's. Perhaps something like this for each module? I'm not sure how it would impact other users though.
I had a "fun" time upgrading from Angular 2 Beta-17 to RC1 in Visual Studio as well, but it's all running now, so might put together a starter repository for VS 2015 / ArcGIS 4 / Angular 2 when time permits. |
Just found that when I deployed the app to somewhere that contains a virtual path the getName function wouldn't work. Here's an updated esriSystem.ts. Now getName just looks for 'esri' or 'dojo' in the location to find out where to start getting the module name from.
|
@nickcam thanks for keeping plugging away at this. I still haven't had time to try this out on my own (just been very busy w/ UC around the corner), but this looks solid. Would you be interested in making a pull request with these changes? cc @jwasilgeo |
No worries...am using it in a new project so just getting sorted out up front. Bit pushed for time as well - unfortunately not because of UC :) - but want to try and take another look next week at getting all or at least more module types to load. Will raise a PR after I get a chance to check it out again. |
@nickcam awesome. Just wanted to hop on here and also say thanks and definitely encourage you to make a PR when you have the chance. |
Resolved in #10 |
Hi Guys,
Out of the box the loader won't work with the official typings for v4. https://github.com/Esri/jsapi-resources/blob/master/4.x/typescript/arcgis-js-api.d.ts
It's not surprising as the typings files declares everything as a separate module (as it should for amd I'm thinking), and the loader registers everything under the one module name in systemjs,
snippet from arcgis-js-api.d.ts
A "fairly" easy workaround is to add a new module to the typings file named the same as the output module name in the loader - for example "esri-mods" - that contains every interface as an export in it.
for example:
This way import statements are the same as they currently are as well.
But I was thinking that instead of having to modify the official typings, I just could modify esriSystem.ts.
Since the names of the modules added to the dojo loader call exactly match the typings file - as they should, I tried to create a System.register call for every esri module included using the modules name just by looping the returned modules in the require callback and calling System.register on each one.
Couldn't get it working after a couple of hours trying though and wasn't sure why. So instead of possibly burning days trying to get it going, thought I'd check if you had any ideas of how to handle this?
Thanks!
The text was updated successfully, but these errors were encountered: