const map = new Map<string, number>();
map.set('foo', 20);
map.set('bar', 22);
const foo = map.get('foo');
const bar = map.get('bar');
assertDefined(foo);
assertDefined(bar);
console.log(`Answer to the Ultimate Question of Life, the Universe, and Everything is ${foo + bar}`);
Ensures that the given value is not undefined. Useful to validate that value gotten from an array or record object is defined. Pay attention, it will throw an error only if the value is undefined. null will not throw an error. If you need it to throw an error for null, use
assertDefinedNotNullinstead.