-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow type casts around shorthand property names #13035
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Comments
mhegazy
added
Suggestion
An idea for TypeScript
In Discussion
Not yet reached consensus
labels
Dec 19, 2016
RyanCavanaugh
added
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
and removed
In Discussion
Not yet reached consensus
labels
Jan 24, 2017
JoshuaKGoldberg
pushed a commit
to JoshuaKGoldberg/TypeScript
that referenced
this issue
Feb 10, 2018
This PR adds a `type?: TypeNode` property to the `ShorthandPropertyAssignment` interface, and adds it to the allowed tokens for shorthand property assignments in parsing. In checking, if a member type is declared on a shorthand assignment, it is used instead of the name. Fixes microsoft#13035
3 tasks
I've found variants of try {
return {
data: riskyOperation(),
succeeded: true,
};
} catch (error) {
return {
error: error as Error,
succeeded: false
};
} |
Somewhat wurprised at the lack of feedback here, but in practice this isn't a huge annoyance for me when I encounter it so maybe that makes sense. I think we want to stay well-clear of this syntactic space to keep room for future TC39. |
5 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
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 }
:Expected behavior:
These should all compile to the same thing.
Actual behavior:
The lines with type casting in the names are syntax errors.
The text was updated successfully, but these errors were encountered: