npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ts

v0.2.2

Published

The CLI client that TypeScript deserves.

Downloads

10,916

Readme

ts

The CLI that TypeScript deserves.

✨ Simple project setup 📦 Modern defaults 🏷 Painless custom type declarations 🔍 Search for type packages on npm 👌 Selectively override options on the command line (yes, tsc does not allow that)

Installation

Locally:

$ npm install --save-dev typescript ts

Globally:

$ npm install --global typescript ts

Quick start

Run the TypeScript compiler with ts default best practice options:

npx ts --out-dir <path> <...entrypoint files>

Compiling using ts does not require a tsconfig.json file, but ts will act according to its options if found.

If your source files are in src/ and you want to write the output files to dist/, you don't even need to set anything:

npx ts

Run with --emit-tsconfig to create a tsconfig.json file.

# Write ts default options into tsconfig.json
npm ts --emit-tsconfig
# Options: create declaration files, target runtime ES2016
npm ts --declaration --emit-tsconfig --target es2016

Usage

Usage
  General usage
  $ ts <command> [<...options>]

  Compile project in current directory
  $ ts [build]

  Compile with altered options
  $ ts --target es2018 src/**/*.ts

  Create tsconfig.json
  $ ts --emit-tsconfig [<...options>]

  Show this help text
  $ ts --help

Commands
  build                 Compile a TypeScript project. Default command.
  compile               Alias of "build".
  search                Search for a type declarations package on npm.

General options
  --help                Print this help.
  --version             Print version.

See <https://github.com/andywer/ts> for details.

Monorepo support

Run ts with --monorepo or set the monorepo option in the package.json file (see below).

This will make TypeScript look for packages not only in ./node_modules/, but also in ../../node_modules/ (the monorepo root directory's node_modules). It will also look for type declaration packages and custom local type declarations in the monorepo root.

Custom type package support

By default ts will not only load type declaration from @types/* packages, but also from @<username>/types-*.

That allows you to easily publish your custom type declarations to npm under the scope of your npm user name without going through all the overhead of Definitely Typed.

Use the ts search command to find type declaration packages on npm:

$ ts search koa
# Will list all packages matching "@types/*" | "@*/types-*" and "koa"

Local type declarations

ts makes it particularly easy to use local typings for third party modules.

By default all typings/**/*.d.ts files will be loaded. Use the --typings-directory argument to change the search path from typings/ to something else.

Usage with other tools

Most users will also use tslint, maybe the webpack ts-loader or have an IDE that relies on knowing the TypeScript compiler options. You want them to behave the same way that ts does.

Easy: Just run ts --emit-tsconfig to write all the compiler options into a tsconfig.json file. Other tools will pick it up and use the same configuration.

Defaults

In contrast to tsc behavior, ts lets you override options set in the package.json or tsconfig.json selectively using command line arguments. Yes, you heard right, tsc will ignore your tsconfig.json once you set a single option via command line 🤦‍

This is a tsconfig.json that resembles the ts default options:

{
  "compilerOptions": {
    "esModuleInterop": true,
    "lib": ["es2015"],
    "module": "commonjs",
    "moduleResolution": "node",
    "newLine": "lf",
    "target": "es5",
    "outDir": "<output directory>",
    "strict": true
  },
  "include": [
    "<entrypoint file path>"
  ]
}

Configuration in package.json

You can also set all ts options and TypeScript compilerOptions in your package.json:

{
  "ts": {
    "compilerOptions": {
      /* Any compiler options */
    },
    "include": [
      /* Source files (entrypoints) */
    ],
    "monorepo": boolean,
    "transforms": [
      /* Transformations (package name or local path) */
    ],
    "typingsDirectory": "./typings"
  }
}

Experimental: Allows you to .gitignore your tsconfig.json file altogether.

License

MIT