【问题标题】:Flow treats imported types as anyFlow 将导入的类型视为任何类型
【发布时间】:2018-11-01 04:02:10
【问题描述】:

我有一个类似这样的类型 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 将类型视为任何类型?

【问题讨论】:

    标签: javascript flowtype static-analysis


    【解决方案1】:

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

    【讨论】:

    • 是的,是一样的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-11
    • 2018-08-11
    • 2021-04-22
    • 1970-01-01
    相关资源
    最近更新 更多