エンジニアとしての市場価値を測りませんか?PR

企業からあなたに合ったオリジナルのスカウトを受け取って、市場価値を測りましょう

30
26

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 独自オブジェクトの配列と連想配列(ハッシュ)の型の書き方

Last updated at Posted at 2015-07-15

よく忘れるのでメモしておきます。

公式に書いてない気がするのですが、気のせいでしょうか。

独自クラスの配列の型の書き方

例えばこんなやつです。

[{a:1234,b"1234},{a:1234,b"1234}]

配列の中身がオブジェクトになっているものです。

myArray:格納されるオブジェクトの型 []

var myA:MyType[] = [];
myA.push(new MyType())

オブジェクトの型の配列の型の書き方

myHash:{[キー名: string]: オブジェクトの型;}

こんなやつです。

{
a:{name:"test",body:"わー"},
a2:{name:"test",body:"わー"},
a3:{name:"test",body:"わー"}
}

var myHash:{[key: string]: MyType;} = {};;
myHash["key"] = new MyType()
30
26
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

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
30
26

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?