This produces a similar error ("Type 5 is not assignable to type 'string'") when compiled with TS:
var s: string = "Dog";
s = 5;
The difference is that it's a compile-time error, while in PowerShell it's a run-time check. But what's the difference in this case? Either way, it tells you.