How to declare flow type for named exports?

95 Views Asked by At

I have a file with a default export and some other named exports.

  module.exports = function1;
  exports.names= [];
  exports.getStrings = getStrings;

function1 and getString functions are defined.

Now, in the .flow file i want to declare the types of these variables.

declare module.function1: (param: ?(string | number)) => null | number;
declare exports.names: $ReadOnlyArray<string>;
declare exports.getStrings: () => {[string]: string};

This is giving flow parse error. I have referred to the flow documentation but couldn’t find anything.

1

There are 1 best solutions below

3
Ricola On BEST ANSWER

This should work:

declare export default {
  (param: ?(string | number)): null | number,
  names: $ReadOnlyArray<string>,
  getStrings: () => {[string]: string},
};