Как я могу явно объявить тип при импорте * как ... в TypeScript?Как объявить тип импорта TypeScript *?
У меня этот код:
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}
...
, и я получаю
ERROR in ./src/components/App.tsx
(16,24): error TS2322: Type 'typeof "~/src/interfaces/InterfaceA"'' is not assignable to type '{ [key: string]: string | ComponentClass<any> | StatelessComponent<any>; }'.
Index signature is missing in type 'typeof "~/src/interfaces/InterfaceA"'.
хотя это только экспорт объектов, простирающиеся React.ComponentClass
Нет, я определенно имел в виду «* в качестве» - Я хотел использовать простой синтаксис, чтобы объявить список компонентов, которые в сумме были бы интерфейс. в JS, который был бы общим объектом. – Jabher
@ Jabher Вы нашли, что такое впечатывание импорта? – ziv