Select based on enum in Angular2

One more solution if you don’t want to create a new pipe. You could also extract keys into helper property and use it: @Component({ selector: ‘my-app’, providers: [], template: ` <div> <select> <option *ngFor=”let key of keys” [value]=”key” [label]=”countries[key]”></option> </select> </div> `, directives: [] }) export class App { countries = CountryCodeEnum constructor() { this.keys … Read more

How to configure custom global interfaces (.d.ts files) for TypeScript?

“Magically available interfaces” or global types is highly discouraged and should mostly be left to legacy. Also, you should not be using ambient declaration files (e.g. d.ts files) for code that you are writing. These are meant to stand-in the place of external non-typescript code (essentially filling in the typescript types into js code so … Read more

why is return type `null` (or any other type) assignable to return type `void`?

Canonical answers to this question can be found in: The TypeScript FAQ entry for “Why are functions returning non-void assignable to function returning void?” microsoft/TypeScript#8581 “how come () => void is a subtype of () => a if void isn’t a subtype of a and a isn’t subtype of void?” microsoft/TypeScript#20006 “[documentation] Clarify the semantics … Read more