generator-typings
v1.0.13
Published
Create typings repository for `typings` (https://github.com/typings/typings)
Downloads
18
Maintainers
Readme
generator-typings
Yeoman generator for typings (next-gen of tsd/DefinitelyTyped) project
Upgrade from previous version? Make sure you check the upgrade doc
Features
- [x] Basic scaffolding
- Source delivery mechanisms
- [x] npm
- [ ] bower
- [ ] github
- [ ] jspm
- Source hostings providers
- [x] github
- [ ] bitbucket
- [ ] gitlab
- [ ] custom
- [x] Install target source automatically
- [x] Add source as submodule
- Install supporting utilities and settings
- Test harness
- npm commands
- [x] watch: Build typings for testing automatically
- [ ] publish: Create PR to
typings/registry
- individual commands
- [x] build: Build typings for testing
- [x] lint: Run tslint
- [x] test: Run tests
- [x] source-test: Run tests transferred from source
Installation
First, install Yeoman and generator-typings using npm.
npm install -g yo
npm install -g generator-typings
Usage
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
How to write 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
About writing tests for typings
Simply shape test (like those in DefinitlyType) 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.
License
MIT © unional