首页 > 解决方案 > Flow 将导入的类型视为任何类型

问题描述

我有一个类型 def 文件是这样的:

// Type Definitions
export interface IPane {
  key: string;
  tab?: string;
  closable?: boolean;
  title?: string;
}


export interface ApolloGraphQLResult<T> {
  data: T;
  errors: Array<any>;
  loading: boolean;
  networkStatus: NetworkStatus;
  stale: boolean;
}

但是,当我导入这些类型时,Flow 只是将其视为任何类型:

import type { IPane } from '../../types'; // [Flow] IPane: any

这是我的 flowconfig 设置。

[ignore]
.*/dist/.*
.*/node_modules/jsonlint/.*
.*/node_modules/rc-util/.*

[include]

[libs]
./src/global.js
flow-typed

[options]
esproposal.decorators=ignore
module.name_mapper='^.*\.css$' -> 'css-module-flow'
module.name_mapper='^.*\.scss$' -> 'css-module-flow'
module.name_mapper='^.*\.less$' -> 'css-module-flow'
module.name_mapper='^components\(.*\)$' -> '<PROJECT_ROOT>/src/components/\1'
module.name_mapper='^containers\(.*\)$' -> '<PROJECT_ROOT>/src/containers/\1'
module.system=haste
module.system.node.resolve_dirname=node_modules

[lints]

我的设置似乎没有问题。重新启动流程不会改变任何事情。

我错过了什么?为什么 Flow 将类型视为任何类型?

标签: javascriptflowtypestatic-analysis

解决方案


您是否尝试过使用export type而不是export interface


推荐阅读