Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Arrow Function improvement and Variable Destructuring #198

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Milly
Copy link
Contributor

@Milly Milly commented Jul 29, 2020

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 Milly changed the title Arrow Function improvement Arrow Function improvement and Variable Destructuring Jul 29, 2020
@HerringtonDarkholme
Copy link
Owner

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!

@Milly
Copy link
Contributor Author

Milly commented Jul 29, 2020

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

@Milly Milly changed the title Arrow Function improvement and Variable Destructuring WIP: Arrow Function improvement and Variable Destructuring Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants