Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

old-skull/ts-types-starter-kit

Repository files navigation

ts-types-starter-kit

Example of typescript types package.

How does it works?

To use our types as package we need to compile it to the .d.ts a.k.a declarations and then push it to the registry.

  1. Setup tsconfig.json

    • "declaration": true - activating declarations in our project.
    • "emitDeclarationOnly": true - allows to get only typings from our code.
    • "declarationDir": "./dist" - directory for declarations output
  2. Create index.ts outside src folder.

    Allows us to export all code from src.

  3. Build

    tsc

How to use it?

  1. Add .ts or .d.ts files to the src folder.
  2. Run build script from package.json or via command line with your package manager:
npm run build
yarn build
pnpm build
  1. Inspect compiled types declarations in the dist folder.

How to publish to the registry?

I added files for npm registry. You can safely delete it or replace.

  1. Login:
npm login
  1. Publish:
npm publish --access public

NOTE: Sometimes you need to provide login token or something similar. Remember to delete it from your project.

Links

About

Starter kit for Typescript types package.

Topics

Resources

License

Stars

Watchers

Forks