[過去ログ] TypeScript part2 [転載禁止]©2ch.net (1002レス)
前次1-
抽出解除 必死チェッカー(本家) (べ) 自ID レス栞 あぼーん

このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
62
(1): デフォルトの名無しさん [sage] 2015/10/24(土) 14:26:29 ID:otxAXsrh(1/3) AAS
>>59
59(2): デフォルトの名無しさん [sage] 2015/10/23(金) 23:22:47 ID:vOh1PKiJ(1) AAS
interface IEquatable {
equals(other: this): boolean
}
とかかな
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って自分の型名のエイリアス
として使えるから便利って事であってるの?
63
(1): デフォルトの名無しさん [sage] 2015/10/24(土) 14:31:41 ID:otxAXsrh(2/3) AAS
>>60
60(2): デフォルトの名無しさん [sage] 2015/10/23(金) 23:33:29 ID:oFKlQBDH(1) AAS
typescriptで使いやすいEditorでおすすめってなんですかね?
MS由来からいってVSなんでしょうけど、当方Macなので、、、、
Emacsと
外部リンク:github.com
↑を使う事でVSに劣らないインテリセンス環境が出来上がるぞ(ページ内のscreencastを見るべし!)
ちなみに常用してるけどMac版Emacsは使った事ないから詳細は分からん
64
(3): デフォルトの名無しさん [sage] 2015/10/24(土) 14:48:22 ID:otxAXsrh(3/3) AAS
>>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'.
って、ポリモらないけど…なんでなん?
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.041s