HotTowel-Angular meet TypeScript
I've recently ported John Papa's popular Hot Towel Angular SPA Template to TypeScript. Why? Because it was there.
If you'd like to read more about HotTowel-Angular then have a read of John Papa's post. You can find my port on GitHub here.
#
What is this port you speak of?It is intentionally a "bare bones" port of the HotTowel-Angular JavaScript code across to TypeScript. It's essentially the same code as John's - just with added type annotations (and yes it is noImplicitAny
compliant).
You could, if you wanted to, go much further. You could start using a whole host of TypeScripts functionality: modules / classes / arrow functions... the whole shebang. But my port is deliberately not that; I didn't want to scare your horses... I wanted you to see how easy it is to move from JS to TS. And I'm standing on the shoulders of that great giant John Papa for that purpose.
If you wanted an example of how you might go further in an Angular port to TypeScript then you could take a look at my previous post on the topic.
#
What's in the repo?The repo contains the contents of HotTowel-Angular's app folder, with each JavaScript file converted over to TypeScript. The compiled JavaScript files are also included so that you can compare just how similar the compiled JavaScript is to John's original code.
In fact there are only 2 differences in the end:
getNavRoutes
#
1. sidebar.js's ...had the filtering changed from this:
to this: ```ts return (r.config.settings && r.config.settings.nav) ? true : false;
#
If you want to use thisThen simply follow the instructions for installing HotTowel-Angular and then drop this repo's app folder over the one just created when HotTowel-Angular was installed. If you're using Visual Studio then make sure that you include the new TS files into your project and give them the BuildAction
of TypeScriptCompile
.
You'll need the following NuGet packages for the relevant DefinitelyTyped Typings:
And you're good to go. If you're not using Visual Studio then you may need to add in some <reference path="angular.d.ts" />
etc. statements to the TypeScript files as well.
If you're interested in the specific versions of the typings that I used then you can find them in the packages.config
of the repo.
#
ThanksTo John Papa for creating HotTowel-Angular. Much love.
And my mum too... Just because.