musictheory / NilScript

Objective-C-style language superset of JavaScript with a tiny, simple runtime
Other
50 stars 5 forks source link

Support more arrow function annotations #161

Open iccir opened 5 years ago

iccir commented 5 years ago

As of #160, we support annotations on arrow function parameters when parentheses are used:

_.each(arr, (foo: Foo) => { … });

let foo = (a: Foo, b: Foo) => { … };

We don't support the following annotations:

_.each(arr, item: TheItem => { … }); // Parameter with no parentheses

let foo = (a, b): Foo => { … }; // Return value

Ideally, we'd match TypeScript's support and allow all of the above.

iccir commented 5 years ago

I investigated this when trying to fix #159 and #160, but failed to come up with a safe solution for all cases. JavaScript's use of cover grammars (see section 5.1.4) make this a complex task - it's likely not worth the effort, but I wanted to document the issue.