技術

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

関連記事

no image

【nginx/unicorn】(13: Permission denied) while connecting to upstream

どうも中田です。 AWS上でAPIサーバを構築してて、 * Webサーバ:ngi …

[Xcode] SDK Version Issue – This app was built with the iOS 12.0 SDK. Starting March 2019, all iOS apps submitted to the App Store must be built with the iOS 12.1 SDK or later, included in Xcode 10.1 or later.

こんにちは。たなかです。 2019年、ブログ初更新になります。今年もよろしくお願 …

no image

wordpressで固定ページが表示されない時は.htaccessを確認しよう

こんばんは 個人でwordpressサイトを持っているのですが いきなり固定ペー …

no image

【ionic】view-titleが更新できない!!

どうも中田です。 ionicのview-titleを動的に変えるってパターンはし …

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 …