I'm not sure if my build is good or not, but in my package.json, I have
"scripts": {
    "build": "flow-remove-types src/ -d build/",
And I have a types/sentence.js, which has:
// @flow
type SentenceObject = {
  foo: number,
  bar: boolean,
  baz: string,
};
module.exports = {
  SentenceObject
};
And in my library file, I have:
const { SentenceObject } = require('../interfaces/sentence');
The problem, when I do yarn build is:
src/interfaces/sentence.js
 ↳ Syntax Error: Unexpected token, expected = (3:27)
   2:  export type SentenceObject {
What am I doing incorrectly?
There seems to no CommonJS style for require flow types. Instead you can use export/import as suggested in docs. So in your case it might be something like:
types/sentence.js:
// @flow
export type SentenceObject = {
  foo: number,
  bar: boolean,
  baz: string,
};
notice the export keyword.
And in your library file you can use import type {...} from '':
import type { SentenceObject } from '../interfaces/sentence';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With