0

I created a monorepo which will contain 2 apps created with create-react-app and 1 module with shared components. Right now I have 1 create-react-app and the shared component module.

For my project I would like to use Flow. Thus I used flow init in the root of my project. Running yarn start works fine with using flow types inside the create-react-app files. But I am importing one file from the shared components with the following content:

export class Decision {
    mainTopic: string;

    constructor(mainTopic, options) {
        this.mainTopic = 1;
        this.options = 1;
    }
}

For this file I get the following error:

SyntaxError: /packages/shared_components/model/Decision.js: Unexpected token (2:13)

Removing the type annotations lets the app compile. What do I have to change to get the flow types inside the shared components module working?

Thanks in advance!

skyboyer
  • 22,209
  • 7
  • 57
  • 64
Deutro
  • 3,113
  • 4
  • 18
  • 26

1 Answers1

0

Make sure you have // @flow in the very top:

// @flow
export class Decision {...}

Docs

Alejandro
  • 5,834
  • 1
  • 19
  • 36