alangpierce/sucrase

Failure to parse some usages of Flow $Call (Unexpected token, expected ",")

zipang opened this issue · 2 comments

Sucrase fails to parse some usages of the type helper $Call inside Flow code :

Example of code failing :

// @flow

type Account = $PropertyType<
  $Call<<T>($ReadOnlyArray<T>) => T>,
  'account'
>

Demo :

Thanks for reporting! I think the bug here is that << being mis-tokenized as a left-shift operator. There are already some special cases to get >> working (based off of similar special cases in Babel), and at least one << case was handled recently in https://github.com/alangpierce/sucrase/pull/716/files#diff-0221cac4ed46c5209e9fe0f67d5f903e3f2069287eedc8a8502f3906f504ac2c , but looks like this is a case that was missed.

Thxx a lot ! :)