Basics
Challenges
Classes
Debugging
Events
External Files
Flow Control
Forms
Functions
Html Elements
Installation
Interfaces
Keywords
Modules
Namespaces
Operators
Reference Files
String
Types
Union Types allow you to assign more than one type to a variable and as long as it's in the list, it will be accepted
let someValue: string | number;
let someValue: string | number;
someValue = "Hello";
someValue = 42;
// notice how this won't work
//someValue = true;
let basicString: string;
basicString = "foo";
// basicString = null; <-- nope
let basicString2: string | null;
basicString2=null;
let basicString3: string | number;
//basicString3 = null; <-- nope
basicString3=42;