Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Remove flow types from the npm distribution #37

Open
@sansumbrella

Description

@sansumbrella

When I add mapbox-gl-js-mock to my project to a create-react-app project, I expect to be able to run unit tests that involve Mapbox types.

I add the mock as a dev dependency:

yarn add --dev mapbox-gl-js-mock

I then use it as a mock in my jest tests:

jest.mock("mapbox-gl", () => require("mapbox-gl-js-mock"));

Finally, I see failing tests because the Flow type annotations confuse Jest.

/node_modules/mapbox-gl-js-mock/node_modules/mapbox-gl/src/geo/lng_lat.js:24
        lng: number;
           ^
    SyntaxError: Unexpected token :

Unfortunately, Jest does not apply transformations to files in node_modules/, so I don't see a good way around this issue shy of updating the mock to not have type annotations. Any configuration suggestions that solve the problem would be great.

For what it's worth, the create-react-app typescript integration works just fine, but the workings of that are hidden in the react-scripts. After following the suggestions for enabling flow in create-react-app, I still have this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions