2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

TypeScriptでES2015のCollectionを利用する

Last updated at Posted at 2017-05-30

ES2015には、以下のようなCollectionクラスが定義されています。

TypeScriptでは、tsconfig.jsonのcompileOptions.libに"es2015.collection"を追加することで、Collectionクラスが利用できるようになります。

tsconfig.json
{
  "compilerOptions": {
    "lib": ["es2015.collection"]
    // その他の定義
}

importなしでCollectionが使えるようになります。

let myMap = new Map<String, number>();
myMap.set("a", 1);
myMap.set("b", 1);

型定義は以下で見れますので、ご確認ください。

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?