初級 › Cannot assign to because it is a constant の原因と直し方 › パターン5
Cannot assign to because it is a constant の原因と直し方
constで宣言した変数に再代入しようとしたときに出るエラーです。
1 const label = "X"; 2 _________ = "Y"; ^ 3 console.log(label);
main.ts(2,1): error TS2588: Cannot assign to 'label' because it is a constant.
空欄を埋めてコンパイルを通す
labelはconstです。別の値を代入し直すことはできません。
次の問題