3 ms·
Does anyone have a good tutorial on migrating existing JS codebases to TS? Talking specifically Angular 1 if you have one, otherwise a general tutorial is fine
by joshschreuder 10y ago
Does anyone have a good tutorial on migrating existing JS codebases to TS?
Talking specifically Angular 1 if you have one, otherwise a general tutorial is fine.
I'm interested in whether it is worth the effort migrating a pretty large frontend codebase.
- jestar_jokin 10y agoI did this on my current project. Basically: - Set up your TypeScript config - Set up Typings (or some other type def manager) - Rename all ".js" files to ".ts" - Replace all "var x = require()" calls to "import x = require()" - Gradually refactor components (controllers, directives, services) to classes, or at least add type annotations to everything. Because TypeScript is a superset of JavaScript, you can work on an untyped system and add gradual typing until the codebase starts looking nicer. Any new functionality can be implemented in TypeScript; any existing functionality can be slowly refactored when it is touched by changes.
- whatever_dude 10y agoI'd add tslint to that once the basic migration is done. It can get a lot of issues in the code that are either bad stylistic options, or things that can produce errors in the future.