# timeout(n)
Create a promise that resolves after some time
Parameters
Name | Types | Description |
---|---|---|
n |
|
number of milliseconds before promise resolves |
# dd()
(12) You can use the optional operator (?) to indicate that something may or may not be there
# zz()
(7) we could improve this situation by providing a type annotation when we declare our variable
# AbstractContact()
(5) TypeScript even allows for abstract classes, which have a partial implementation
# Contact()
(1) Classes work similarly to what you're used to seeing in JS - They can "implement" interfaces
# ParamPropContact()
(3) Access modifier keywords - "who can access this thing" - public - everyone - protected - me and subclasses - private - only me
# Array.filter()
(2) Type parameters can have default types - just like function parameters can have default values
# resolveOrTimeout()
(3) You don't have to use exactly your type parameter as an arg - things that are based on your type parameter are fine too
# aa()
(6) Dealing with multiple unknowns - We kind of lose some of the benefits of structural typing when using unknown
. - Look how we can get mixed up below
# logWhenResolved()
(2) When to use any
Anys are good for areas of our programs where we want maximum flexibility Example: sometimes a Promise
# myUnknown.split()
(3) When to use unknown
Unknowns are good for "private" values that we don't want to expose through a public API. They can still hold any value, we just must narrow the type before we're able to use it. We'll do htis with a type guard.
# UnreachableError()
(9) We can use this to our advantage to create exhaustive conditionals and switches
# foo()
(1) "identifiers" (i.e., a variable, class, function, interface) - can be associated with three things: value, type and namespace
# xx()
(2) Functions and variables are purely values. - Their types may only be extracted using type queries