expect-type
Advanced tools
Comparing version 0.5.3 to 0.5.4
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.5.4](https://github.com/mmkal/ts/compare/expect-type@0.5.3...expect-type@0.5.4) (2020-04-11) | ||
**Note:** Version bump only for package expect-type | ||
## [0.5.3](https://github.com/mmkal/ts/compare/expect-type@0.5.2...expect-type@0.5.3) (2020-04-11) | ||
@@ -8,0 +16,0 @@ |
{ | ||
"name": "expect-type", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"repository": "https://github.com/mmkal/ts", | ||
@@ -19,3 +19,3 @@ "homepage": "https://github.com/mmkal/ts/tree/master/packages/expect-type#readme", | ||
], | ||
"gitHead": "034a6dbc1fe9bf906e0eeb392b4b902445e99f9b" | ||
"gitHead": "4060601fc5a4294fa6b2a18a29f87dfb8ccd2bba" | ||
} |
@@ -5,23 +5,33 @@ # expect-type | ||
![Node CI](https://github.com/mmkal/ts/workflows/Node%20CI/badge.svg) | ||
![codecov](https://codecov.io/gh/mmkal/ts/branch/master/graph/badge.svg) | ||
<!-- codegen:start {preset: badges} --> | ||
[![Node CI](https://github.com/mmkal/ts/workflows/Node%20CI/badge.svg)](https://github.com/mmkal/ts/actions?query=workflow%3A%22Node+CI%22) | ||
[![codecov](https://codecov.io/gh/mmkal/ts/branch/master/graph/badge.svg)](https://codecov.io/gh/mmkal/ts/tree/master/packages/expect-type) | ||
[![npm version](https://badge.fury.io/js/expect-type.svg)](https://npmjs.com/package/expect-type) | ||
<!-- codegen:end --> | ||
<!-- codegen:start {preset: markdownFromJsdoc, source: src/index.ts, export: expectTypeOf} --> | ||
#### [expectTypeOf](https://github.com/mmkal/ts/tree/034a6db/packages/expect-type/src/index.ts#L71) | ||
Similar to Jest's `expect`, but with type-awareness. Gives you access to a number of type-matchers that let you make assertions about the form of a reference or generic type parameter. | ||
It can be used in your existing test files - or anywhere other type-checked file you'd like. | ||
##### Example | ||
```typescript | ||
expectTypeOf({a: 1}).toMatchTypeOf({a: 2}) | ||
expectTypeOf({a: 1}).toHaveProperty('a').toBeNumber() | ||
import {foo, bar} from '../foo' | ||
import {expectTypeOf} from 'expect-type' | ||
test('foo types', () => { | ||
// make sure `foo` has type {a: number} | ||
expectTypeOf(foo).toMatchTypeOf({a: 1}) | ||
expectTypeOf(foo).toHaveProperty('a').toBeNumber() | ||
// make sure `bar` is a function taking a string: | ||
expectTypeOf(bar).parameter(0).toBeString() | ||
expectTypeOf(bar).returns.not.toBeAny() | ||
}) | ||
``` | ||
See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples. | ||
<!-- codegen:end --> | ||
See the [documentation](#documentation) for lots more examples. | ||
## Contents | ||
<!-- codegen:start {preset: markdownTOC, minDepth: 2, maxDepth: 5} --> | ||
- [expectTypeOf](#expecttypeof) | ||
- [Contents](#contents) | ||
@@ -47,3 +57,3 @@ - [Installation and usage](#installation-and-usage) | ||
The `expectTypeOf` method takes a single argument, or a generic parameter. Neither it, nor the functions chained off its return value, have any meaninful runtime behaviour. The assertions you write will be _compile-time_ errors if they don't hold true. | ||
The `expectTypeOf` method takes a single argument, or a generic parameter. Neither it, nor the functions chained off its return value, have any meaningful runtime behaviour. The assertions you write will be _compile-time_ errors if they don't hold true. | ||
@@ -50,0 +60,0 @@ ### Features |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
209556
219