Skip to content

Commit

Permalink
Merge pull request #1 from JakeSidSmith/readme-updates
Browse files Browse the repository at this point in the history
Readme updates
  • Loading branch information
JakeSidSmith authored Jan 5, 2020
2 parents 73ee6c6 + ccac2c2 commit 26d8f11
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
50 changes: 28 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,42 @@

[![CircleCI](https://circleci.com/gh/JakeSidSmith/tsassert.svg?style=svg)](https://circleci.com/gh/JakeSidSmith/tsassert)

## About

This library provides an easy way for library publishers (and anyone else that wants) to assert the output types of their APIs, and ensure that these do not regress over time.

I would recommend adding a tsassert command to your tests and or continuous integration pipeline.

## Requirements

You must be using a reasonable recent version of node. Guaranteed to work with node 12. May work with older versions.
You must be using a reasonably recent version of node. Guaranteed to work with node 12. May work with older versions.

You must be using TypeScript `3.7` or above. This is a peer dependency.

## The syntax

Simply add a comment with the following structure to the end of any variable declaration:

```ts
// @type: ExpectedTypeHere
```

Example in tests:

```ts
describe('my getter', () => {
it('should return undefined if any values in the path are nullable', () => {
const result = get(obj, ['a', 'b', 'c']); // @type: string | undefined

expect(result).toBe(undefined);
});
});
```

## Install

```shell
npm i tsassert -D
npm i @jakesidsmith/tsassert -D
```

`-D` (`--save-dev`) will automatically add this to your `package.json` and `package-lock.json`.
Expand Down Expand Up @@ -48,23 +74,3 @@ The `project` option defaults to `./tsconfig.json`.
If you don't specify a file or pattern tsassert will use the `includes` from your `tsconfig.json`.

Run `tsassert --help` for a full list of options.

## The syntax

Simply add a comment with the following structure to the end of any variable declaration:

```ts
// @type: ExpectedTypeHere
```

Example in tests:

```ts
describe('my getter', () => {
it('should return undefined if any values in the path are nullable', () => {
const result = get(obj, ['a', 'b', 'c']); // @type: string | undefined

expect(result).toBe(undefined);
});
});
```
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jakesidsmith/tsassert",
"version": "0.1.0",
"version": "0.1.1",
"description": "Check TypeScript types against assertion comments",
"bin": {
"tsassert": "dist/cli.js"
Expand Down

0 comments on commit 26d8f11

Please sign in to comment.