-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
It would seem like this is a (common?) bug that the compiler could catch for us.
Given this example class:
class Foo {
bar: number;
}
let a: Foo;
a.bar = 1;
At runtime I will get an error 'Cannot set property 'bar' of undefined because I never actually initialized the object. (i.e. let a: Foo = new Foo();
or let a = new Foo();
)
This seems to me like it could probably be a pretty common developer mistake given the ability to provide types (: Foo), especially since editors will give you full Intellisense on the object just by naming the type of it without initialization. I'm curious if it's something that the Compiler could catch? (variable a is undefined; declared, but never initialized)
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code