darkfo
darkfo copied to clipboard
Work towards using ES6
ES6 is becoming more and more supported, and it offers some very nice features (const, let, destructuring, Map, Set, etc.)
TypeScript transpiles a lot of these, but the codebase doesn't use much of them (in particular I recall wrapping some blocks in lambdas to mimic let.)
const should be defaulted to when making bindings we won't change, and let otherwise.
We may also use for(let x of xs) ... for loops over arrays, and Object.assign for cloning/mass-assigning objects.
Arrow functions are some of the most useful for this. I ported worldmap.ts to ES6. The other files still remain.
Like I said in #101:
A lot of the callback hell spaghetti can be replaced with promises (which as a huge benefit makes our asynchronous code composable, and will replace monsters like the image loading stuff -- we can use Promise.all instead).
We might also want to target ES6 natively (since it's supported by a large majority of modern browsers) in TypeScript ("target": "ES6"} and use ES6 libs.)