This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Hero { | |
constructor(public name: string, public weapon?: string) {} | |
abstract attack(): void; | |
} | |
class BlastingHero extends Hero { | |
attack() { | |
console.log(`${this.name} blasted ${this.weapon}.`); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hero { | |
constructor(public name: string, public weapon?: string) {} | |
} | |
class Avengers { | |
private ensemble: Hero[] = []; | |
private blast(hero: Hero) { | |
console.log(`${hero.name} blasted ${hero.weapon}`); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createDeepTruthChecker(useStrategy = Object.keys) { | |
return function check(obj) { | |
return !!obj && ( | |
typeof obj === 'object' | |
? useStrategy(obj).every(key => check(obj[key])) | |
: true | |
); | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// requires TypeScript v3.6+ | |
export { DeepBoolean }; | |
type Mutable<T> = { | |
-readonly [P in keyof T]: T[P]; | |
}; | |
declare class DeepBoolean<T = any> { | |
constructor(source: T); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// /User/keybindings.json | |
[ | |
{ | |
"key": "shift+alt+t", | |
"command": "editor.action.insertSnippet", | |
"when": "resourceLangId == typescript && editorTextFocus && !editorReadonly", | |
"args": { | |
"langId": "typescript", | |
"name": "Disable TSLint" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ChangeDetectionStrategy, Component } from '@angular/core'; | |
@Component({ | |
selector: 'app-card-title', | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
template: ` | |
<h5 class="card-title"> | |
<ng-content></ng-content> | |
</h5> | |
`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ContentChild, ElementRef, Input } from '@angular/core'; | |
import { CardTitleComponent } from './card-title.component'; | |
export abstract class AbstractCard { | |
@Input() action = () => {}; | |
@Input() color = 'primary'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
ChangeDetectionStrategy, | |
Component, | |
Input, | |
Optional, | |
} from '@angular/core'; | |
import { CardVerticalComponent } from './card-vertical.component'; | |
@Component({ | |
selector: 'app-card-image', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; | |
@Component({ | |
selector: 'app-card-image', | |
changeDetection: ChangeDetectionStrategy.OnPush, | |
template: ` | |
<img [alt]="alt" [src]="src" [ngClass]="classes" (load)="ready = true" /> | |
<span *ngIf="ready && attribution"> | |
Image by <a [href]="attribution.href">{{ attribution.text }}</a> | |
</span> |