Skip to content

mulekick/typescript-launchpad

Repository files navigation

Typescript launchpad

Ready to use typescript environment.

Table of contents

  1. Available commands
  2. Explore code samples
  3. Typescript configuration details
  4. Footnotes

Available commands

# clone the repository using degit
npx degit https://github.com/mulekick/typescript-launchpad.git my-awesome-typescript-project

# cd into your project
cd my-awesome-typescript-project

# clean install dependencies
npm ci

# list project types
npm run list

# validate project types
npm run typecheck

# lint project files
npm run lint

# run your code using tsx
npx tsx src/my-awesome-code.ts

# build declaration files
npm run types:build

# build executable files
npm run build

# build documentation
npm run docs:build

Caution : ambient modules and handwritten *.d.ts files are not included in the build by default.

Explore code samples

This repo ships with code samples that illustrate concepts from the typescript handbook :

Module Description
src/compiler-checks Built-in compiler checks.
src/basic-types Basic types.
src/composed-types Composed types.
src/code-narrowing Code narrowing.
src/typed-functions Typed functions.
src/generic-types Generic types.
src/advanced-features Advanced features.
src/conditional-types Conditional types.
src/functional-programming Functional programming.
src/namespaces Namespaces.
src/declaration Sample declaration file.
src/implementation Sample implementation file.
src/ambient Ambient module declaration.

Typescript configuration details

tsconfig.json is the reference for up to date, fine tuned typescript configuration.

The following compilerOptions keys need special attention :

Footnotes

  • I personally opt to separate declarations from implementations as much as possible for clarity.
  • When things get complicated, it's better to separate concerns by coding raw JS and typing it afterwards.
  • As opposed to ECMA, typescript maintainers sometimes have a tendency to overengineer things.
  • Another striking example of that tendency can be found here.
  • The remedy to that is to stick to useful features and use tried and tested coding patterns.
  • Pro tip : when types created from a generic type serve almost identical implementations, the generic type probably shouldn't exist.

About

Ready to use typescript environment.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published