Useful Grammar Tips / Snippets for TypeScript


I would like to share some useful snippets for TypeScript coding!

😀 Read-Only Class Properties

Cool!!!

class Circle {
readonly radius: number;

constructor(radius: number) {
this.radius = radius;
}

get area() {
return Math.PI * this.radius ** 2;
}
}

😼 Type of HTMLElement

interface HTMLElementEventextends HTMLElement> extends Event {
target: T;
}

var element = document.createElement('input');
element.addEventListener('click', function(event: HTMLElementEvent) {
alert(event.target.value); // 補完できるヤッター
}, false);
element.click();

🐹 References

🖥 Recommended VPS Service

VULTR provides high performance cloud compute environment for you. Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour). In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!