TypeScript Version: 2.8.3
Search Terms:
Code
interface Foo {
enum: string;
}
function bar({ enum }: Foo) {
if (enum) {
//
}
}
Expected behavior:
Code compiles without issue.
Actual behavior:
Error at 5: Enum declarations can only merge with namespace or other enum declarations.
Error at 5: ':' expected.
Error at 6: Enum declarations can only merge with namespace or other enum declarations.
Error at 6: Expression expected.
Error at 6: Identifier expected.
Playground Link:
Playground
function bar({ enum }) {} doesn't work in the node.js console either.
Illegal code but we should issue a better parse error here
I was scratching my head, because the following is valid:
function bar({ enum: e }) {}
But then I remembered that enum is a reserved word in ECMAScript these days...
related #11648
Most helpful comment
Illegal code but we should issue a better parse error here