LoginSignup
0
0

More than 3 years have passed since last update.

TypeScriptで FileReaderのonloadした後、resultに対してエラーが出る時の暫定対処

Posted at

FileReader

なんかおかしいらしい。

スクリーンショット 2020-01-23 15.48.46.png

TS2339: Property 'result' does not exist on type 'EventTarget'

なぜか怒られる

https://github.com/Microsoft/TypeScript/issues/4163
なんかおかしいらしい。
※翻訳してまで読んでないので興味がある方は調べてください。

const reader = new FileReader();
      reader.onload = (e) => {
        //(e.target as any)でany型に変換する
        console.log((e.target as any).result);
      };
      reader.readAsDataURL(file);
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