|
|
|
|
|
by TomMarius
3036 days ago
|
|
This is in no way equal to having a 'class A { ... }' that you'd instantiate with 'new A()'. In module b, the const a will not be of 'type A', but a plain object with signature of '{ a: string }' for which A is an alias. That's very different because a plain object is not an instance - you can't use instanceof, try to console.log() it and an instance of a class and you'll see the difference. |
|
By "constructor function" I meant a function that constructs an object with a given shape, not a "class instance" or prototyped object. Sorry about not being clear. So no `instanceof`, but you are guaranteed to get correct type checking.
See here [1] for example, if you hover `a` it will tell you it is an `A` not a `{a:string}`.
[1]: https://www.typescriptlang.org/play/#src=type%20MapToProps%3...