-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
TypeScript Version: 3.7.0-dev.20190815 (there are same errors in playground even in 2.x)
Search Terms: Identifier expected , arrow function in object
Code
test.js
const value = 1;
const a = {
b: () => false
}
const test = () => ({
// "Identifier expected." error on "!" and two "Duplicate identifier '(Missing)'." errors on space.
prop: !value, // remove ! to see that errors will be gone
run: () => { //replace arrow function with regular function to see that errors will be gone
// comment next line or remove "()" to see that errors will be gone
if(!a.b()) { return 'special'; }
return 'default';
}
});
There are no look-alike Unicode characters.
There are no problems if you switch order of prop
and run
.
Error is reproducible even when I write
const test = ({
prop: !value
run: () => {
if(!a.b()) { return 'special'; }
return 'default';
},
});
But works as expected if I remove parentheses around object or replace arrow function with regular one.
Expected behavior: No errors (code is valid and produces expected results in browsers)
Actual behavior: A lot of errors, most notably Identifier expected.
on !
character in line prop: !value
UPD. Object properties are actually parsed as arrow function parameters:
Playground Link: Example (I disabled noImplicitAny
to remove noise)
Related Issues: Not found