Skip to Content
プログラミングTypeScript ―スケールするJavaScriptアプリケーション開発
book

プログラミングTypeScript ―スケールするJavaScriptアプリケーション開発

by Boris Cherny, 今村 謙士, 原 隆文
March 2020
Intermediate to advanced
376 pages
5h 9m
Japanese
O'Reilly Japan, Inc.
Content preview from プログラミングTypeScript ―スケールするJavaScriptアプリケーション開発

6章高度な型

TypeScriptは、偏屈なHaskellプログラマーでさえうらやむような、型レベルの強力なプログラミング機能をサポートする、ワールドクラスの型システムを備えています。もうご存知のように、その型システムは、驚くほど表現力が豊かなだけでなく、使うのが容易で、型の制約と関係を簡潔に宣言することを可能にすると同時に、ほとんどの場合、それらの推論を可能にします。

そのように表現力が豊かで、並外れた型システムが必要とされるのは、JavaScriptが非常に動的だからです。プロトタイプ、thisの動的バインド、関数のオーバーロード、絶えず変化するオブジェクトといったものをモデル化するには、機能が豊富な型システムと、バットマンが驚いて二度見するような型演算子のユーティリティベルト†1が必要です。

[†1] 訳注:バットマンが腰に巻く、さまざまなガジェットを携帯可能なベルト。

この章ではまず、TypeScriptでのサブタイプ、割り当て可能性、変性、型の拡大について詳しく取り上げ、これまでのいくつかの章にわたって育んできた洞察にさらに明確な定義を与えます。次に、型の絞り込みや完全性など、TypeScriptの制御フローベースの型チェック機能について解説し、いくつかの高度な型レベルのプログラミング機能——オブジェクト型に対するルックアップとマッピング、条件型の使用、独自の型ガードの定義、および型アサーションや明確な割り当てアサーションのようなエスケープハッチを紹介します。最後に、さらなる型安全性を得るための高度なパターン——コンパニオンオブジェクトパターン、タプル型についての推論の改善、名前的型のシミュレート、プロトタイプの安全な拡張——について説明します。

6.1 型の間の関係 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

リーダーの作法 ―ささいなことをていねいに

リーダーの作法 ―ささいなことをていねいに

Michael Lopp, 和智 右桂
行動を変えるデザイン ―心理学と行動経済学をプロダクトデザインに活用する

行動を変えるデザイン ―心理学と行動経済学をプロダクトデザインに活用する

Stephen Wendel, 武山 政直, 相島 雅樹, 反中 望, 松村 草也

Publisher Resources

ISBN: 9784873119045Other