Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript Coding Style Guide? [closed]

I love the Airbnb JavaScript Style Guide. Most of the rules also apply to TypeScript, but of course it doesn't cover specific TypeScript language features.

I have also found the Microsoft TypeScript Coding Guidelines but they are for the TypeScript project itself, not for projects that use TypeScript.

Finally I found the TypeScript Style Guide by Platypi but it's not as detailed as I'd like it to be. Is there another (official?) TypeScript Style Guide that I missed? Or are the two I listed the only ones that exist?

like image 641
Johannes Fahrenkrug Avatar asked Aug 13 '15 14:08

Johannes Fahrenkrug


2 Answers

The TypeScript team doesn't issue an "official" style guide for other projects using TypeScript. The guidelines for working on the compiler itself are both too specific and not broad enough for general use; I would not use them as a baseline.

Any JavaScript style guide that is up-to-date for ES6 is going to cover nearly all TypeScript constructs except for type annotations, so I would start with your favorite JS style and decide on what you want the rules for type annotations to be.

TSLint is a good choice for enforcing style rules around types / type annotations.

Update: TSLint is currently deprectated in favour of ESLint.

like image 196
Ryan Cavanaugh Avatar answered Sep 19 '22 13:09

Ryan Cavanaugh


Maybe this is a bit late, but I stumbled upon https://github.com/excelmicro/typescript which also provides a bit more detailed tslint.json in the linters folder ... it is also based on the airbnb/javascript styleguide ...

Yet another Styleguide (which we use for angular 1 development with TypeScript) is https://angular.io/guide/styleguide

like image 28
david Avatar answered Sep 19 '22 13:09

david