技術

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 を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

関連記事

[Cocos Creator] java.util.NoSuchElementException

どうも中田です CocosCreatorでビルド後、AndroidStudioで …

no image

heroku + node.jsでError R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch

こんにちは heroku + node.jsでアプリを作っていて、いざherok …

no image

【AngularJS】angularjs-datatable。クリックが効かない問題!

どうも中田です。 今日は情けないブログを書きます。 angularJSでdata …

Google PolyをFusion360でお試し

Googleさんが公開した無料の3Dデータライブラリ Poly AR・VRアプリ …

no image

[Rails]if文とcontent_for

こんばんは content_for便利ですよね。 今回はcontent_forと …