yats.vim icon indicating copy to clipboard operation
yats.vim copied to clipboard

WIP: Arrow Function improvement and Variable Destructuring

Open Milly opened this issue 4 years ago • 2 comments

Improvement to parse Arrow Function.

  • Add typescriptDestructurings that parses Object or Array destructuring.
    • Referenced by typescriptVariableDeclarations and typescriptParameterList.
  • Fix typescriptArrowFuncDef so that it can correctly parse Object or Array destructuring.
  • Fix typescriptFuncType so that it can contained in Return Type of typescriptArrowFuncDef.

This can be parsed correctly.

const func = <
  C extends Readonly<Partial<{ foo: any, bar: any[] }>>
>(
  { foo, bar: [ baz, { 'qu qux': quux } ] }: C
) : <T>(foobar: T) => () => { barbaz: T } => {
  const { a, b: [ c, d, ...e ] } = foo;
  let f, g, h;
  ({ f, x: [ g, ...h ] } = quux);
  return <T>( foobar: T, ...ququx: any[] ): ( ) => { barbaz: T } => ( ) => ( { barbaz: ququx[0] } );
};

TODO

  • Can not parse Parenthesized Type contained in Return Type of Arrow Func Def.

Ex.

const F = (): ('foo' | 'bar') => { return 'foo' };

Milly avatar Jul 29 '20 11:07 Milly

Hi @Milly ! Thank you for your tremendous contribution!

I notice this change will be huge. So please kindly be patient, I will take some time to review it! Also, could you please add some test cases for arrow function? I would be necessary for yats not having highlight broken.

Thanks again for your help!

HerringtonDarkholme avatar Jul 29 '20 11:07 HerringtonDarkholme

Sorry existing tests are failed. I will fix it later. So change this PR to WIP in current.

Milly avatar Jul 29 '20 12:07 Milly