yats.vim
yats.vim copied to clipboard
WIP: Arrow Function improvement and Variable Destructuring
Improvement to parse Arrow Function.
- Add
typescriptDestructurings
that parses Object or Array destructuring.- Referenced by
typescriptVariableDeclarations
andtypescriptParameterList
.
- Referenced by
- Fix
typescriptArrowFuncDef
so that it can correctly parse Object or Array destructuring. - Fix
typescriptFuncType
so that it can contained in Return Type oftypescriptArrowFuncDef
.
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' };
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!
Sorry existing tests are failed. I will fix it later. So change this PR to WIP in current.