I’ve found a scenario where I can reliably get the TypeScript compiler to fail with the error message: “Internal error: Unable to get value of the property ‘publicMembers’: object is null or undefined”
Here’s my Repro.ts file:
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.");
}
}
This may very well be a duplicate of TypeScript compiler crash: publicMembers is null or undefined, but the repro is significantly less complex, so I thought I’d go ahead and post it anyway.
Any thoughts?
I have added this to the bug over on Codeplex.
You should vote for that bug if you haven’t already to show that it is an issue for you too.
There isn’t much else to add to an answer as you are right – this is a bug in the compiler. We just need to wait for the fix.