I am using Angular 2 with TypeScript 2.
When I use
let labels: string[] | number[] = [];
// let labels: Array<number> | Array<string> = [];
labels.push(1);
it gives me error:
error TS2349: Cannot invoke an expression whose type lacks a call signature.
Changing
let labels: string[] | number[] = [];
to either of these
let labels: (string | number)[] = [];
let labels: Array<number|string> = [];
will solve the issue.
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