Skip to content

Commit

Permalink
Rename to tsd - fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren committed Mar 20, 2019
1 parent 8425861 commit 4ca7e4a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "tsd-check",
"name": "tsd",
"version": "0.6.0",
"description": "Check TypeScript type definitions",
"license": "MIT",
"repository": "SamVerschueren/tsd-check",
"repository": "SamVerschueren/tsd",
"author": {
"name": "Sam Verschueren",
"email": "sam.verschueren@gmail.com",
Expand Down
22 changes: 11 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# tsd-check [![Build Status](https://travis-ci.org/SamVerschueren/tsd-check.svg?branch=master)](https://travis-ci.org/SamVerschueren/tsd-check)
# tsd [![Build Status](https://travis-ci.org/SamVerschueren/tsd.svg?branch=master)](https://travis-ci.org/SamVerschueren/tsd)

> Check TypeScript type definitions

## Install

```
$ npm install tsd-check
$ npm install tsd
```


Expand All @@ -32,19 +32,19 @@ concat('foo', 'bar');
concat(1, 2);
```

Running `npx tsd-check` as a command will verify that the type definition works correctly.
Running `npx tsd` as a command will verify that the type definition works correctly.

Let's add some extra [assertions](#assertions). We can assert the return type of our function call to match a certain type.

```ts
import {expectType} from 'tsd-check';
import {expectType} from 'tsd';
import concat from '.';

expectType<string>(concat('foo', 'bar'));
expectType<string>(concat(1, 2));
```

The `tsd-check` command will succeed again.
The `tsd` command will succeed again.

We change our implementation and type definition to return a `number` when both inputs are of type `number`.

Expand All @@ -57,7 +57,7 @@ declare const concat: {
export default concat;
```

If we don't change the test file and we run the `tsd-check` command again, the test will fail.
If we don't change the test file and we run the `tsd` command again, the test will fail.

<img src="screenshot.png" width="1330">

Expand All @@ -66,7 +66,7 @@ If we don't change the test file and we run the `tsd-check` command again, the t
If your method returns a `Promise`, you can use top-level `await` to resolve the value instead of wrapping it in an `async` [IIFE](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).

```ts
import {expectType, expectError} from 'tsd-check';
import {expectType, expectError} from 'tsd';
import concat from '.';

expectType<Promise<string>>(concat('foo', 'bar'));
Expand All @@ -83,7 +83,7 @@ When you have spread your tests over multiple files, you can store all those fil
```json
{
"name": "my-module",
"tsd-check": {
"tsd": {
"directory": "my-test-dir"
}
}
Expand All @@ -93,7 +93,7 @@ Now you can put all your test files in the `my-test-dir` directory.

### Custom TypeScript config

By default, `tsd-check` applies the following configuration:
By default, `tsd` applies the following configuration:

```json5
{
Expand All @@ -106,14 +106,14 @@ By default, `tsd-check` applies the following configuration:
}
```

If you wish to override these options, you have the possibility to provide a custom TypeScript config to `tsd-check` by specifying it in `package.json`.
If you wish to override these options, you have the possibility to provide a custom TypeScript config to `tsd` by specifying it in `package.json`.

*Default options will still apply if you don't override them explicitly.* You can't override the `moduleResolution` and `skipLibCheck` options.

```json
{
"name": "my-module",
"tsd-check": {
"tsd": {
"compilerOptions": {
"strict": false
}
Expand Down
10 changes: 5 additions & 5 deletions source/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
import * as meow from 'meow';
import * as updateNotifier from 'update-notifier';
import formatter from './lib/formatter';
import tsdCheck from './lib';
import tsd from './lib';

const cli = meow(`
Usage
$ tsd-check [path]
$ tsd [path]
Examples
$ tsd-check /path/to/project
$ tsd /path/to/project
$ tsd-check
$ tsd
index.test-d.ts
✖ 10:20 Argument of type string is not assignable to parameter of type number.
Expand All @@ -23,7 +23,7 @@ const cli = meow(`
try {
const options = cli.input.length > 0 ? {cwd: cli.input[0]} : undefined;

const diagnostics = await tsdCheck(options);
const diagnostics = await tsd(options);

if (diagnostics.length > 0) {
throw new Error(formatter(diagnostics));
Expand Down
4 changes: 2 additions & 2 deletions source/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {Config} from './interfaces';
* @param pkg - The package.json object.
* @returns The config object.
*/
export default (pkg: {'tsd-check'?: Partial<Config>}): Config => {
const pkgConfig = pkg['tsd-check'] || {};
export default (pkg: {tsd?: Partial<Config>}): Config => {
const pkgConfig = pkg.tsd || {};

return {
directory: 'test-d',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foo",
"tsd-check": {
"tsd": {
"compilerOptions": {
"strict": false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foo",
"tsd-check": {
"tsd": {
"compilerOptions": {
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/test/fixtures/test-directory/custom/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "foo",
"tsd-check": {
"tsd": {
"directory": "test"
}
}

0 comments on commit 4ca7e4a

Please sign in to comment.