Closed
Description
Is there any reason shorthand property names ({ a }
, etc.) don't allow type casting around the names? It would be a mildly useful feature.
Code
The following object literals are all intended to compile to { foo: foo }
:
function take(arg: { foo: string }) { }
let foo: string;
// Allowed
take({ foo });
take({ foo: foo });
take({ foo: foo as string });
take({ foo: <string>foo });
// Syntax errors
take({ <string>foo });
take({ foo as string });
Expected behavior:
These should all compile to the same thing.
Actual behavior:
The lines with type casting in the names are syntax errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment