When working with TypeScript, I encountered a strange issue. Can you help me understand why this code fails?
export class MyClass {
x:string = null //shows IDE warning (type 'null' is not assignable to 'String')
}
However, when I change it to this, it works fine:
export class MyClass {
x:string = null!
}
I'm puzzled by the use of null!
. Is it some kind of guaranteed-to-be-not-null null?