【问题标题】:How to configure mapbox-gl-js types with flow?如何使用流配置 mapbox-gl-js 类型?
【发布时间】:2019-04-06 03:14:46
【问题描述】:

所以我在 react 项目中使用 "mapbox-gl": "0.50.0"// @flow

但是,当我运行流程时,它会遇到很多类型错误。

是否需要向.flowconfig 添加规则或如何配置?

如果我将此添加到我的.flowconfig

[ignore]
.*/node_modules/@mapbox/.*
.*/node_modules/mapbox-gl/.*

然后当我尝试在我的实际代码中导入 mapbox-gl 时引发错误

谢谢!

【问题讨论】:

    标签: mapbox mapbox-gl-js mapbox-gl


    【解决方案1】:

    您需要像这样将 mapbox-gl 添加到 [libs] 部分:

    [libs]
    ./node_modules/mapbox-gl/flow-typed
    ./node_modules/mapbox-gl/dist/mapbox-gl.js.flow
    

    您可能还想忽略一些mapbox-gl 依赖项:

    [ignore]
    .*/node_modules/jsonlint-lines/.*
    .*/node_modules/@mapbox/jsonlint-lines-primitives/.*
    

    仅供参考,我的.flowconfig 文件如下所示:

    [ignore]
    .*/node_modules/jsonlint-lines/.*
    .*/node_modules/@mapbox/jsonlint-lines-primitives/.*
    
    [include]
    
    [libs]
    ./flow-typed
    ./node_modules/mapbox-gl/flow-typed
    ./node_modules/mapbox-gl/dist/mapbox-gl.js.flow
    
    [options]
    esproposal.class_static_fields=enable
    esproposal.class_instance_fields=enable
    
    [lints]
    

    它适用于 mapbox-gl v0.51.0 和 flow-bin v0.86.0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-03-20
      • 1970-01-01
      • 2019-11-19
      • 2017-01-26
      • 2016-06-05
      • 2018-02-03
      • 1970-01-01
      相关资源
      最近更新 更多