1// the "last" property is optional and can be undefined
2function printName(obj: { first: string; last?: string }) { // ...}// Both OKprintName({ first: "Bob" });printName({ first: "Alice", last: "Alisson" });Try
1// Writing ! after any expression is effectively a type assertion
2// that the value isn’t null or undefined
3function liveDangerously(x?: number | null) { // No error console.log(x!.toFixed());}Try