TypeScript(ESLint) - Type number trivially inferred from a number literal, remove type annotation.

TypeScript(ESLint)で発生するエラーの原因と解決方法

エラーメッセージ

Type number trivially inferred from a number literal, remove type annotation.

説明

数値リテラルから型を推測できるため、型の指定を削除します。

エラー例

const userId: number = 9;

解決方法

型の指定を削除します。
const userId = 9;

検証環境

関連ページ