角度组件的类型 [英] Type of angular components

查看:28
本文介绍了角度组件的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将角度组件类称为类型吗?我看到 Ionic 使用 any 作为组件.是否可以在 Typescript 中声明一个只需要组件类的参数类型?

Can I refer to angular component class as a type? I see Ionic uses any for components. Is it possible in Typescript to declare an argument type, that expects only component classes?

我看到了这个问题,但是组件在构造函数中没有任何共同点:将类作为参数传递会导致不可更新"错误

I saw this question, but components don't have anything in common in constructors: Passing class as parameter causes "is not newable" error

推荐答案

事实证明,目前这在 TypeScript 中是不可能的.装饰器不能改变类的类型,这意味着它们对于类型系统是不可见的.
更多信息可以在这里找到:

As it turns out this is not possible in TypeScript right now. Decorators cannot change type of a class, that means they are invisible for a type system.
More info can be found here:

这篇关于角度组件的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆