简体   繁体   中英

what type do you give an object with children in a typescript interface

I have a response

filereader.onload = function(evt: any) {
  url = evt.target.result; //sending the link to url
};

But considering the fact that removing type any makes the application faster. I tried giving the vet parameter the type of object but then the property target did not exist on type object. I also tried using an interface but giving it any still brings the same issue I am trying to get rid of.

The following inline type should do the trick:

filereader.onload = function(evt: { target: { result: string } }) {
  url = evt.target.result; //sending the link to url
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM