Taking this course:
React & TypeScript - The Practical Guide
What we’ve learnt:
Type checking, type inference, explicit type annotations.
Primitive types: string
, number
, boolean
. No int
nor float
or their signed/unsigned and floating point accuracy variants distinction?
Compiling ts code: tsx tsc app.ts
→returns app.js
, with let
→ var
. Not used a lot.
Union of types.
object
type.
Array
type.
Cannot reassign value to a const
.
functions.
void
type for functions that dont return a value.
for functions that will be passes as an argument to another function, use function type definition/signature. example: calcFn: (a: number, b: number) => number
or we can define a custom type, by using type
, for example:
type AddFn: (a: number, b: number) => number;
so in the other functions that use that function as parameter, the type of the parameter inside the function definition will be like this: calcFn: AddFn
we can also define custom type for any composite types, such as
type StringOrNum = string | number
i will skip interface
, too much brain memory load.