} function multiply(x: number, y: number) { return x * y; } function square(x: number) { return x * x; } const x = square(multiply(sum(2, 3), 2)); number
}; function sendEmail(email: string) { … } const eli: User = { name: 'Eli', username: 'eliperkins', email: null, }; sendEmail(eli.email); Error: This type is incompatible
}; class UserComponent extends React.Component<Props> { ... } <UserComponent id={123} name={"Eli"} />; Error: property `email` not found in props of React element `UserComponent`
types of values. 9| case primary of 10| Red -> 11| "red" 12| 13| Green -> 14| "green" 15| 16| Blue -> 17|> False The 2nd branch has this type: String But the 3rd is: Bool
causing a type mismatch. 3| ["Alice"] == [True] ^^^^^^ (==) is expecting the right side to be a: List String But the right side is: List Bool Hint: With operators like (==) I always check the left side first. If it seems fine, I assume it is correct and check the right side. So the problem may be in how the left and right arguments interact.
let greeting stranger => switch stranger { | Teacher => "Hey professor!" | Director => "Hello director.” }; Warning 6: this pattern-matching is not exhaustive. Here is an example of a value that is not matched: Student
let greeting stranger => switch stranger { | Teacher => "Hey professor!" | Director => "Hello director.” }; Warning 6: this pattern-matching is not exhaustive. Here is an example of a value that is not matched: Student
Dan Grossman, Programming Languages course: https://www.coursera.org/learn/ programming-languages Brandon Williams - Proof in Functions: https:// vimeo.com/121953811