I am having problems when defining a lambda function that accepts an optional parameter. The strange part is that if I use the full “function” syntax the anonymous function works, but the lambda shorthand/arrow syntax produces errors such as the following:
- The name ‘a’ does not exist in the current scope
- Supplied parameters do not match any signature of call target
- Expected ‘)’
Example:
(function (a, b?) => { console.log(a, b); })("a"); // OK
((a, b?) => { console.log(a, b); })("a", "b"); // Errors
((a, b) => { console.log(a, b); })("a", "b"); // OK
This is a bug in the compiler and is getting fixed right now [v0.8]. Lambdas currently give error messages with optional and rest parameters. Please use the long function syntax if this is a blocking issue.