const names: string[] = [];
const names = [] as string[];
In TypeScript, is there a semantic difference between the above two statements? If so, when would we prefer one over the other?
It's simple as:
as keyword) if you want to tell the compiler that some
expression has some specific type (even if it doesn't really).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With