Dhruv Tailor
Dhruv Tailor

Reputation: 2751

How to declare flow type for named exports?

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.

Upvotes: 0

Views: 100

Answers (1)

Ricola
Ricola

Reputation: 2922

This should work:

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

Upvotes: 1

Related Questions