typescript-book
typescript-book copied to clipboard
:books: The definitive guide to TypeScript and possibly the best TypeScript book :book:. Free and Open Source 🌹
> It will be good if you could provide us an example for abstract class and properties here. Made here https://www.gitbook.com/book/basarat/typescript/discussions/64
E.g. https://stackoverflow.com/a/44424850/390330 New to JavaScript devs miss it too commonly :rose: [Beginning nodejs covers portions of it.](http://www.apress.com/us/book/9781484201886)
e.g : ``` ts function test({ x, y }: { x: number, y: number }) { console.log(x, y); } test({ x: 1, y: 2 }); ``` with defaults : ```...
Add to tips somewhere. https://stackoverflow.com/a/44124349/390330 ```ts interface Model { content: string; count: number } function createModel({ // Add defaults content = '', count = 0 } = {}): Model {...
Seen a few people struggle to find good docs on the following * `{foo}` object creation `shorthand property names` * `{[foo]: bar}` `shorthand computed names` :rose:
https://github.com/Microsoft/TypeScript/pull/14496
Hello Basarat, I would first like to thank you for your generous contribution by your book about TypepScript. Since you are my current reference when it comes to the TypeScript...
What am I doing wrong in my command? I am on Windows 10. PS D:\proj\tsnode> node ./node_modules/.bin/tsc --init D:\proj\tsnode\node_modules\.bin\tsc:2 basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") ^^^^^^^ SyntaxError: missing )...
The third block of example code in the chapter on index signatures produces this error in the TypeScript Playground: `Type '{ toString(): string; }' cannot be used as an index...
Mixin
Here is a good solution : https://github.com/Microsoft/TypeScript/issues/6502#issuecomment-173312747 that uses `Object.assign` https://github.com/Microsoft/TypeScript/issues/2919#issuecomment-173384825 ``` ts function Mixin(...mixins) : new() => T { class X { constructor() { mixins[0].call(this); } } Object.assign(X.prototype, ...mixins.map(m...