技術

TypeScriptで連想配列の型定義をする

投稿日:

TypeScriptを書いているときに、毎回調べていたので簡単にまとめました。

// 連想配列
let list1: { str: string; flag: boolean } = {
    str: 'string',
    flag: true
};

// 配列内連想配列
let list2: { key: string; index: boolean }[] = [
    {
      key: 'string',
      index: true
    },
    {
      key: 'hogehoge',
      index: false
    }
];

-技術

執筆者:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

関連記事

fullpage.jsでコンテンツを画面幅いっぱいでスクロールさせる。

fullpage.jsとは fullpage.jsは一つのコンテンツを画面いっぱ …

[Xcode] iOSソフトウェアアップデート後に、Could not locate device support files.

こんにちは。たなかです。 Xcodeで開発中に以下のエラーにぶつかりました。 エ …

[Rails] モデルが初期化されてないとな(not initialized)

どうも中田です Railsで、modelの initialize に処理を追加す …

[ Ionic ] A problem occurred evaluating project ‘:app’. > Failed to apply plugin [class ‘com.google.gms.googleservices.GoogleServicesPlugin’] > For input string: “+”

こんにちは。たなかです。 相変わらずモバイルアプリ開発やっています。 先日、Io …

[ionic] Error code 70 / requires a provisioning profile with the Push Notifications feature.

どうも中田です ionic使っててbuildで引っかかりましたー ionicでp …