Yeoman generator for typings (next-gen of tsd/DefinitelyTyped) project
Upgrade from previous version? Make sure you check the upgrade doc
- Basic scaffolding
- Source delivery mechanisms
- npm
- bower
- github
- jspm
- Source hostings providers
- github
- bitbucket
- gitlab
- custom
- Install target source automatically
- Add source as submodule
- Install supporting utilities and settings
- Test harness
- npm commands
- watch: Build typings for testing automatically
- publish: Create PR to
typings/registry
- individual commands
- build: Build typings for testing
- lint: Run tslint
- test: Run tests
- source-test: Run tests transferred from source
First, install Yeoman and generator-typings using npm.
npm install -g yo
npm install -g generator-typings
There are several ways to create your typings repository:
Here are examples to create npm-noop2
# create the github repo from github website
# under your organization folder (e.g. /somewhere/typed-typings/)
yo typings npm-noop2
# Once it is done,
cd npm-noop2
# create the github repo from github website
# clone it locally to your machine (e.g. into /somewhere/typed-typings/npm-noop2/)
# in that directory:
yo typings
# create the github repo from github website
# under your organization folder (e.g. /somewhere/typed-typings/)
mkdir npm-noop2 && cd npm-noop2
yo typings
- https://github.com/typings/typings
- https://github.com/typings/typings/blob/master/docs/faq.md
- https://github.com/typings/typings/blob/master/docs/examples.md
- https://github.com/unional/typescript/tree/master/pages/typings
Simply shape test (like those in DefinitelyTyped) is not sufficient. Since there is no type in javascript, even if you create a wrong signature, you won't detect it until runtime.
e.g.
// source code
function foo(something) {
return something++;
}
The source code expects something
to be a number. If you write your typings as:
function foo(something: string): string;
It won't fail until you use it. i.e.
// consumer program
import foo ....somehow
let x = "abc";
foo(x);
Because your typings provide guidance to the consumer, they will write their code that way and will fail when they run it.
tsc
will compile fine.
MIT © unional