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】型アサーション

0
Posted at

今日の学び

// これはダメ
const hoge = document.querySelector('.hoge') as HTMLElement;

// これでオッケー
const hoge = document.querySelector<HTMLElement>('.hoge');

型アサーションは任意の型へ強制的に変更できるが、型安全性が保証されないので極力使用しないこと。

参考文献

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?