A personal journey learning TypeScript through hands-on examples with a chai/tea theme.
- Basic greeting function with typed params (
index.ts)
- Type inference with
letandconst(basics/variables.ts) - Literal types (
basics/literals.ts) - Union types (
basics/unions.ts) anyvsunknown(basics/any-unknown.ts)- Type assertions (
basics/type-assertions.ts) - Object types, structural typing, and excess property checks (
basics/object-types.ts) - Object arrays,
readonly, andreduce(basics/order-calculation.ts)
- Array types, tuples, and enums (
arrays/arrays.ts)
- Function parameters, return types, and
void(functions/function.ts) typeoftype narrowing (functions/typeof-narrowing.ts)instanceoftype narrowing (functions/instanceof-narrowing.ts)- Literal type narrowing (
functions/literal-narrowing.ts) - Optional parameters (
functions/optional-params.ts) - User-defined type predicates (
functions/type-predicates.ts) nevertype and exhaustiveness checking (functions/never-type.ts)
- Basic generics (
generics/first-item.ts) - Generic
wrapInArrayfunction (generics/wrap-in-array.ts) - Multiple type parameters with
pair(generics/pair.ts) - Generic interfaces (
generics/generic-interface.ts) - Generic
fetchDatawithPromise<T>(generics/generic-fetch.ts) keyofconstraint (generics/keyof-constraint.ts)Omitutility type (generics/omit-utility.ts)Partialutility type (generics/partial-utility.ts)Pickutility type (generics/pick-utility.ts)
- Basic, callable, method and index signatures (
interface/basic.ts) - Declaration merging (
interface/declaration-merging.ts) - Interface
extends(interface/extends.ts)
- Classes and inheritance (
oop/classes.ts) - Interfaces and
implements(oop/interfaces.ts) - Object type aliases (
oop/type-aliases.ts) - Intersection types (
oop/intersection-types.ts) - Optional and
readonlyproperties (oop/optional-readonly.ts) - Discriminated unions (
oop/discriminated-unions.ts) inoperator narrowing (oop/in-operator.ts)- Error handling with try/catch (
oop/try-catch.ts)
- Fetch API with typed response (
webRequest/fetchRequest.ts) - Axios with typed response and error handling (
webRequest/axiosRequest.ts)
- React project with Vite (
react-ts/) - components, hooks, typed props
npm install
npx tsc- Arun Neupane - arunneupane.netlify.app
- GitHub: @arundada9000