babel-plugin-flow-to-typescript icon indicating copy to clipboard operation
babel-plugin-flow-to-typescript copied to clipboard

Error on FunctionType Conversion

Open TomPridham opened this issue 5 years ago • 3 comments

i'm getting the following error: TypeError: Property parameters expected type of array but got object when trying to convert some flow files. i've narrowed it down to the following code

// @flow

export type RolesProps = {
  roles: Array<Role>,
  activeRoles: Array<string>,
  accountGuid: string,
  setError: (string) => void,
  setTooltip: (string) => void,
}

i think it is related to this line in the plugin: https://github.com/Kiikurage/babel-plugin-flow-to-typescript/blob/master/src/converters/convert_flow_type.ts#L330

commenting out those two function definitions results in a successful compilation

TomPridham avatar Aug 16 '19 18:08 TomPridham

Hi @TomPridham

it looks issue is already fixed in master, but the version in npm is outdated

as a workaround, you can try using my fork @zxbodya/babel-plugin-flow-to-typescript (latest version there should be the same as current master)

@Kiikurage can you publish a new version to npm?

zxbodya avatar Aug 17 '19 19:08 zxbodya

great, that worked. thanks! should i close this or wait until a new version has been published?

TomPridham avatar Aug 19 '19 15:08 TomPridham

I ran into the same problem today with this test code:

type xType = {|
  data: number,
  onClick: (e: string) => void // this is the problem line
|}

chrisdopuch avatar Oct 10 '19 21:10 chrisdopuch