LoginSignup
0
0

More than 1 year has passed since last update.

error TS2550: Property 'fill' does not exist on type 'any[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2015' or later.の解決法

Posted at

tscを使ってたらエラーが出た

tscを使ってローカルの環境でTypeScriptを使用していたが、fillを使おうとした瞬間エラーが出た。

error TS2550: Property 'fill' does not exist on type 'any[]'. Do you need to change your target library? 
Try changing the 'lib' compiler option to 'es2015' or later.

es2015より後でしかfillは使えないよって言われてるな。ってことはわかった。
その後、tsconfig.jsonを確認。

スクリーンショット 2023-03-11 3.15.13.png

あれ?ちゃんとes2020にしてるはずだけど??
理由はtsconfig.jsonが反映されていないだけだった。

tsc ファイル名 

でコンパイルをしてしまうとtsconfigの設定が反映されない。

tsc 

だけでコンパイルをしてあげるとうまくいった

結論

tsc ファイル名ではなくtscを使うべし

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0