TypeScript Type的等效scala类型是什么

问题描述 投票:0回答:1

我正在使用TypeScript库(angular),它具有一个以Type作为参数的函数:

ComponentFactoryResolover.resolveComponent(component: Type<any>)

但我不知道如何在我的scala代码中定义它。具体来说,如果有一个类型,那么Type [any]的相应scala类型是什么:

@js.native
@JSImport("@angular/core","ComponentFactoryResolver")
class ComponentFactoryResolver extends js.Object {
    def resolveComponentFactory(component: ???): Unit = js.native
}
angular scala.js
1个回答
0
投票

Scala.js没有特定于运行时类值(或构造函数)的类型。因为我们传递给这样一个参数的实际值通常是为某些js.constructorOf[Foo]调用Foo的结果,它返回一个js.Dynamic,我建议将TypeScript的Type<T>转换为Scala.js中的js.Dynamic

© www.soinside.com 2019 - 2024. All rights reserved.