Reputation: 96969
I'm wondering if there's at least some community consensus on how to write reusable Angular2 code in TypeScript. I tried to summarise what I found out and what I'd like to know in context of Angular2.
In the official tutorial I see they put all code into app
directory and all dependencies like node_modules
or typings are in the parent directory.
Lowercase file names, .component.ts
suffix for components and .service.ts
for services. They put all files to the same directory which is going to be a huge mess?
One class/interface/enum per file. For classes, functions, interfaces and other names its probably best to stick to Coding guidelines for TypeScript by Microsoft?
postinstall
npm
hook? Or is it better to provide bundled version directly on git like most JavaScript libraries do? system
type of modules by default when I'm expecting that my module's going to be used only by browser or is it better to always use UMD? system
? <script>
tags or they'll load it using System.import()
? package.json
?Upvotes: 2
Views: 7151
Reputation: 135862
There's the Angular 2 Style Guide (https://github.com/mgechev/angular2-style-guide), as featured in Angular2 News:
The purpose of the following style guide is to present a set of best practices and style guidelines for the development of Angular 2 applications. If you are looking for an opinionated style guide for syntax, conventions...
Upvotes: 4
Reputation: 65043
Angular 1 had a community accepted style guide written by John Papa. There will be something similar created for Angular 2 in fact you can see the start of this coming together with the Tour of Heroes examples in place at angular.io
Upvotes: 1