Open
Description
openedon Mar 2, 2017
TypeScript Version: 2.2.1
Code
class Person {
firstName: string;
lastName: string;
get fullName?() {
return this.firstName + ' ' + this.lastName;
}
}
Expected behavior:
Since fullName
is optional the following should work:
const Me: Person = {
firstName: 'Foo',
lastName: 'Bar'
}
Actual behavior:
A syntax error occurs on this line get fullName?() {
I'm not sure if omitting the ability to optionalize getters was by design or not. If it was by design, I'd love to know the reasoning behind it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment