Appearance
What's that thing in Typescript called?
or: Typescript vocabulary that is impossible to google
"triple-slash directives" = the thing you put at the top of a js file to load types
"type narrowing" = Why putting something into a function parameter behaves differently than if you put it into a variable, and then into a function parameter
as const
can usually fix it
tsfunction fn(a: { b: 'c' }) {} fn({b: 'c'}) // uses type narrowing const var1 = {b: 'c'} // doesn't fn(var1) // err const var2 = {b: 'c'} as const fn(var2)
Function that affects parameter's type
- "type predicates" (used to be called "type guards"): returns boolean
- "assertion functions": throws
"tsm": That thing that is better than ts-node
- Update: there are multiple Node.js TypeScript runtimes now: https://github.com/privatenumber/ts-runtime-comparison