【发布时间】:2012-11-01 10:14:36
【问题描述】:
我发现了一种情况,我可以可靠地使 TypeScript 编译器失败并显示错误消息:“内部错误:无法获取属性 'publicMembers' 的值:对象为 null 或未定义”
这是我的 Repro.ts 文件:
interface Callback { (data: any): void; }
class EventSource1 {
addEventHandler(callback: Callback): void { }
}
class EventSource2 {
onSomeEvent: Callback;
}
export class Controller {
constructor () {
var eventSource = new EventSource1();
// Commenting the next line will allow it to compile.
eventSource.addEventHandler(msg => this.handleEventFromSource1(msg));
}
private handleEventFromSource1(signalState) {
console.log('Handle event from source 1');
var eventSource2 = new EventSource2();
// Commenting the next line will allow it to compile.
eventSource2.onSomeEvent = msg => this.handleEventFromSource2(msg);
}
private handleEventFromSource2(event) {
console.log("Handling event from source 2.");
}
}
这很可能是 TypeScript compiler crash: publicMembers is null or undefined 的复制品,但复制品的复杂性要低得多,所以我想我还是会继续发布它。
有什么想法吗?
【问题讨论】:
标签: typescript tsc