If I have a class of this form:
class MyClass {
a: string
}
and then I define a variable:
let obj: MyClass = { a: 2 }
I'm getting a Typescript error, as expected, because 2 is not a string. However, if MyClass contains a constructor:
class MyClass {
constructor(a: string) {
}
}
Then Typescript remains silent after the same variable declaration. Is there a way to use a constructor and still use the class as interface? Thanks.