如何声明TypeScript导入*类型?

如何声明TypeScript导入*类型?,types,casting,typescript,type-conversion,strong-typing,Types,Casting,Typescript,Type Conversion,Strong Typing,如何在导入时将类型显式声明为。。。打字稿 我有以下代码: import * as UnauthorizedInterface from './interfaces/InterfaceA' import * as AuthorizedInterface from './interfaces/InterfaceB' export class App extends React.Component<{children?: React.ReactChildren, authorized?: Bo

如何在导入时将类型显式声明为。。。打字稿

我有以下代码:

import * as UnauthorizedInterface from './interfaces/InterfaceA'
import * as AuthorizedInterface from './interfaces/InterfaceB'

export class App extends React.Component<{children?: React.ReactChildren, authorized?: Boolean}, {}> {
public render() {
    return <Router>
        <Route component={Interface}>
            <Route path="/application" components={InterfaceA}
...
import*作为未经授权的接口从“/interfaces/InterfaceA”
从“./interfaces/InterfaceB”导入*作为授权接口
导出类应用程序扩展React.Component{
公共渲染(){
返回
将*作为未经授权的接口从“/interfaces/InterfaceA”导入

我想您可能是想从“/interfaces/InterfaceA”
导入{UnauthorizedInterface}。当然,如果您将模块(这是您在
*as
中得到的)用作类,您将得到错误,这就是您得到的错误

将*作为未经授权的接口从“/interfaces/InterfaceA”导入


我想你可能是想从“/interfaces/InterfaceA”导入{UnauthorizedInterface}。当然,如果你将模块(这是你通过
*as
得到的)作为一个类来使用,你会得到你得到的错误。

遇到了同样的问题。基本上是想

import * as Util from './Util'
然后使用Util作为参数。这通过使用
typeof Util

function thing(localUtil: typeof Util) {...}

thing(Util);

遇到了同样的问题基本上是想

import * as Util from './Util'
然后使用Util作为参数。这通过使用
typeof Util

function thing(localUtil: typeof Util) {...}

thing(Util);

不,我的意思是“*as”-我想用简单的语法来声明组件列表,这些组件的总和将是一个接口。在JS中,这将是一个常见的对象。@Japher你找到导入的类型了吗?不,我的意思是“*as”-我想用简单的语法来声明组件列表,这些组件的总和将是一个接口。在JS中,这将是一个公共对象。@Japher您找到导入的类型了吗?