What's really challenging was upgrading to OpenLayers 4 and using the ES2015 module version of it (https://www.npmjs.com/package/ol)... in TypeScript!
Here's a quick summary:
Biggest lesson was a reminder that TypeScript is a strict superset of ES2015.
I was able to simply use the OL4 Modules as is, but, I have to admit, I stumbled a lot. First I installed the ol package from npm:
npm install ol@4.1.1 --saveEasy enough. Then I tried using it like I do with all the other Angular stuff:
import { Map } from 'ol/map';What!? Why does this not work?! Remember, I'm still new at ES2015...
So yes, the first problem was that OL was not exporting named members, only one default member. So removing those curly braces fixed that issue, but took me way too long to get there in the first place :(
Hopefully, this alone will help save someone else's precious time. More than likely, I'm probably the only dumbass in the world that didn't realize this.
This will work with Webpack and Angular CLI out of the box.
If you want typing to work (which, of course, you do... who wouldn't when you're working in TypeScript?), you're gonna need to do a bit more. DefinitelyTyped only has the definition for OpenLayers 3 as of this writing. They may have version 4 now by the time you read this, so check with them first.
In the meantime, I used
typings install file:custom_typings/ol.d.ts --save --globalNote the special "file:" protocol. I've also put my custom typing for this in my "custom_typings" directory. Seems, though, that I had to exclude this directory in my tsconfig.json file, otherwise I was getting duplicate definition errors.
Another snag I hit was that I was using things like ol.interaction.Select.Event, which is a public class, by the way. These were not its own module and there were no typings definition for it. I had to create my own "extended" typing file for these. I was able to open up ol module again and extend like such: