简体   繁体   English

你在打字稿界面中给一个带孩子的对象提供什么类型

[英]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.但考虑到删除类型 any 会使应用程序更快的事实。 I tried giving the vet parameter the type of object but then the property target did not exist on type object.我尝试给 vet 参数指定对象的类型,但是类型对象上不存在属性目标。 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
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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