So I’m trying to learn TypeScript. TypeScript is not necessarily difficult to learn, I think most of my stumbling blocks have to do with working with definition files. Sometimes they work, sometimes they don’t and sometimes I just can’t get my vim or Grunt build scripts to understand what I’m doing.
Not a love story
Here is what I came up with. First off, let’s go over the main.ts file.
One thing to note, if you are new to TypeScript, is the use of import and require, which is very much like commonjs. TypeScript of course also allows you to do type checking at compile time, which I really like. It’s like another layer of confidence in my code. For getting started, I’m using the any type, which is kind of cheating. For the mapOptions, I would probably actually create a Type for it and use that.
The next module is my actual widget, which just adds the map.
This isn’t ideal, but it’s still a good learning exercise. I’m hoping to pick some Esri brains and get more insight here. Maybe just deep-dive mind-meld with TypeScript for a few days and fully embrace it, it will seep in. I mostly get stuck on the compile side with integrating definition files. I’m sure I’ll post more about TypeScript in the future. I’m really interested in Dojo 2 and Mayhem, so really doing things in a TypeScripty way is on my todo list.