技術

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

【Vagrant】はじめまして!はじめました!

どうも中田です。 仮想マシンと言えば、VMWare、EC2、VirtualBox …

esaに貼る画像をリサイズする方法

こんにちは。たなかです。 みなさん、esa使ってますか? esaは「情報を育てる …

no image

Angular6で子コンポーネントに文字列を渡す

文字列と変数の値を渡す時、記述が少しだけ違います。 // 文字列を渡したい時 & …

no image

[Rails]updateの時だけvalidationを実行させる

こんにちは アプリを作っていて、create時にはvalidationを実行させ …

[AWS S3] This XML file does not appear to have any style information associated with it. The document tree is shown below.

はじめまして。田中です。 AWSを触りはじめてから1ヶ月ちょっと。七転び八起きな …