エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
ここにツイート内容が記載されます https://b.hatena.ne.jp/URLはspanで囲んでください
Twitterで共有ONにすると、次回以降このダイアログを飛ばしてTwitterに遷移します
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています
TypeScript version: v4.3.5 元々やりたかったのは以下のようなこと。外部入力の文字列を Union Type に... TypeScript version: v4.3.5 元々やりたかったのは以下のようなこと。外部入力の文字列を Union Type にマッチするか検証してマッチしなければデフォルト値を返すみたいなやつ。 const colors = ["red", "blue", "yellow"] as const; type Color = typeof colors[number]; const defaultColor = colors[0]; function toColor(color: string): Color { return colors.includes(color) ? color : defaultColor; // Type 'string' is not assignable to type '"red" | "blue" | "yellow"'. } const col