microsoft / microsoft/TypeScript
Cannot Optionalize Class Getters
未关闭
还没有人认领这个 Issue。
In Discussion
Suggestion
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
该 issue 没有指出源文件或测试。先使用 TypeScript 2.2.1 示例复现语法错误,并查看关于可选 getter 的现有讨论。完成条件是确定 get fullName?() 的行为,并进行与该决定相符的验证。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100