- TypeScript part2 [転載禁止]©2ch.net
62 :デフォルトの名無しさん[sage]:2015/10/24(土) 14:26:29.93 ID:otxAXsrh - >>59
class Base { getThis(): Base { return this; } } class Derived extends Base { print(): void { console.log('Derived'); } } let derived = new Derived(); derived.getThis().print(); // 1.6.2だとBaseにprint()がねーよと怒られる 1.7だと getThis(): this { return this; } にする事でコンパイル通ってちゃんと実行も出来る って事は理解したけど、equals(other: this)のthisって自分の型名のエイリアス として使えるから便利って事であってるの?
|
- TypeScript part2 [転載禁止]©2ch.net
63 :デフォルトの名無しさん[sage]:2015/10/24(土) 14:31:41.39 ID:otxAXsrh - >>60
Emacsと https://github.com/ananthakumaran/tide ↑を使う事でVSに劣らないインテリセンス環境が出来上がるぞ(ページ内のscreencastを見るべし!) ちなみに常用してるけどMac版Emacsは使った事ないから詳細は分からん
|
- TypeScript part2 [転載禁止]©2ch.net
64 :デフォルトの名無しさん[sage]:2015/10/24(土) 14:48:22.39 ID:otxAXsrh - >>59
class Base { equals(other: this): boolean { return other.name === "Derived"; } } class Derived extends Base { name = "Derived"; } let derived = new Derived(); console.log(derived.equals(derived)); だと、1.7でも(正確には1.7.0-dev.20151016) test.ts(3,18): error TS2339: Property 'name' does not exist on type 'Base'. って、ポリモらないけど…なんでなん?
|