0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

TypeScript入門 Tips

Posted at

環境

npm list -g typescript
/Users/yuta/.nodebrew/node/v10.17.0/lib
└── typescript@3.8.3 
tsc --version
Version 3.8.3

怒られた

  • コード
function waite(duration: number) {
    return new Promise(resolve => {
        setTimeout(()=> resolve(`${duration} ms passed`), duration)
    })
}
waite(100).then((result) => {}) //resは{}
  • 愛のメッセージ
'Promise' only refers to a type, but is being used as a value here. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later

参考: https://qiita.com/k_hoso/items/a8b9de1f5f6b2b93b4f7#%E3%82%B3%E3%83%B3%E3%83%91%E3%82%A4%E3%83%AB%E3%81%99%E3%82%8B%E3%81%A8ts2580%E3%81%8C%E5%87%BA%E3%82%8Bdo-you-need-to-install-type-definitions-for-node

直した

npm list -g typescript
/Users/yuta/.nodebrew/node/v10.17.0/lib
└── typescript@3.8.3 

直った!!!

0
0
0

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?