alangpierce/sucrase

Constructor return type annotations produce invalid JS syntax

rtsao opened this issue · 1 comments

rtsao commented

Source:

class Foo {
  constructor(): Foo {
    return this;
  }
}

Transformed (actual):

class Foo {
  constructor():  {
    return this;
  }
}

Transformed (expected):

class Foo {
  constructor()  {
    return this;
  }
}

Reproductions:

Hi @rtsao , sorry for the delay, and thanks for reporting! That syntax is actually invalid in both TypeScript and Flow, so I'd normally call it out of scope for Sucrase, but I understand the error is pretty confusing, and it's easy to fix in Sucrase, so I'll put up a PR to fix.