TypeScript | Type Annotation and Inference in TypeScript | Question9

Last Updated :
Discuss
Comments

How can you explicitly define a variable with multiple possible types?

let value: multiple<number, string> = 42;

let value = number | string = 42;

let value: number | string = 42;

let value: any = 42 | "hello";

Share your thoughts in the comments