javascript - 从文件夹索引中的多个文件重新导出流命名接口导出
问题描述
我有一个interfaces
文件夹,其中包含一个或多个 Flow 接口的不同文件。
我想从一个index.js
文件中导出我的所有接口,如下所示:
interfaces/index.js
/* @flow */
import type config from './config'
export default {
...config,
}
但 Flow 不会让我返回此错误:
Cannot reference type config [1] from a value position.Flow(InferError)
interfaces/config.js
/* @flow */
export interface Config {
smtp: {
host: string,
secure: boolean,
port: number,
auth: {
user: string,
pass: string,
},
tls: {
rejectUnauthorized: boolean,
},
},
company: Company,
}
export interface Company {
name: string,
phone: string,
address: string,
product: {
name: string,
},
}
有没有办法做到这一点?提前致谢
解决方案
终于找到了解决办法,我需要用到的export type { ... } from '...'
语法,如下:
interfaces/index.js
/* @flow */
export type * from './config'
希望这对其他人有用:)
推荐阅读
- electron - Electronjs如何检测监视器/屏幕是否关闭
- reactjs - 未指定时如何在 React 组件中显式创建可选属性?
- javascript - 将 Class 应用程序转换为 React Next 应用程序的 Hooks
- docker - 用于环境版本控制的 Docker 映像存储库名称或标记
- django - 如何在 Django 中为 python 请求创建队列?
- eclipse - 使用 Eclipse Buildship 插件运行 gradle 构建任务时如何排除测试任务?
- c# - AdysTech/CredentialManager 删除凭据问题
- azure-functions - Azure 函数 - 获取 java.lang.IllegalStateException:与 cosmos 客户端连接时阻塞读取 120000 MILLISECONDS 时超时
- java - mongodb中如何设计文本的外观?
- android - 在 Android 29 上运行可执行文件的路径是什么?