generic-type-guard
Advanced tools
Comparing version 3.7.0 to 3.7.1
{ | ||
"workbench.colorCustomizations": { | ||
"activityBar.activeBackground": "#b0d867", | ||
"activityBar.activeBorder": "#3496cb", | ||
"activityBar.background": "#b0d867", | ||
"activityBar.foreground": "#15202b", | ||
"activityBar.inactiveForeground": "#15202b99", | ||
"activityBarBadge.background": "#3496cb", | ||
"activityBarBadge.foreground": "#e7e7e7", | ||
"sash.hoverBorder": "#b0d867", | ||
"titleBar.activeBackground": "#9bce3e", | ||
"titleBar.activeForeground": "#15202b", | ||
"titleBar.inactiveBackground": "#9bce3e99", | ||
"titleBar.inactiveForeground": "#15202b99" | ||
}, | ||
"peacock.color": "#9bce3e" | ||
"workbench.colorCustomizations": { | ||
"activityBar.activeBackground": "#fb75a3", | ||
"activityBar.background": "#fb75a3", | ||
"activityBar.foreground": "#15202b", | ||
"activityBar.inactiveForeground": "#15202b99", | ||
"activityBarBadge.background": "#2d7c04", | ||
"activityBarBadge.foreground": "#e7e7e7", | ||
"commandCenter.border": "#15202b99", | ||
"sash.hoverBorder": "#fb75a3", | ||
"titleBar.activeBackground": "#f94482", | ||
"titleBar.activeForeground": "#15202b", | ||
"titleBar.inactiveBackground": "#f9448299", | ||
"titleBar.inactiveForeground": "#15202b99" | ||
}, | ||
"peacock.color": "#f94482" | ||
} |
@@ -274,3 +274,3 @@ /** | ||
*/ | ||
export declare const isInstance: <T extends object>(klass: new (...args: unknown[]) => T) => TypeGuard<T>; | ||
export declare const isInstance: <T extends object>(klass: new (...args: never[]) => T) => TypeGuard<T>; | ||
@@ -277,0 +277,0 @@ /** |
@@ -106,3 +106,3 @@ ## API Report File for "generic-type-guard" | ||
// @public | ||
export const isInstance: <T extends object>(klass: new (...args: unknown[]) => T) => TypeGuard<T>; | ||
export const isInstance: <T extends object>(klass: new (...args: never[]) => T) => TypeGuard<T>; | ||
@@ -109,0 +109,0 @@ // @public |
{ | ||
"name": "generic-type-guard", | ||
"version": "3.7.0", | ||
"version": "3.7.1", | ||
"description": "Generic type guards for TypeScript", | ||
@@ -73,22 +73,22 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@microsoft/api-extractor": "7.23.0", | ||
"@mscharley/eslint-config": "1.8.4", | ||
"@mscharley/prettier-config": "1.2.3", | ||
"@stryker-mutator/core": "5.6.1", | ||
"@stryker-mutator/mocha-runner": "5.6.1", | ||
"@stryker-mutator/typescript-checker": "5.6.1", | ||
"@types/chai": "4.3.1", | ||
"@microsoft/api-extractor": "7.33.7", | ||
"@mscharley/eslint-config": "1.8.5", | ||
"@mscharley/prettier-config": "1.2.4", | ||
"@stryker-mutator/core": "6.3.1", | ||
"@stryker-mutator/mocha-runner": "6.3.1", | ||
"@stryker-mutator/typescript-checker": "6.3.1", | ||
"@types/chai": "4.3.4", | ||
"@types/mocha": "9.1.1", | ||
"@types/node": "16.11.27", | ||
"chai": "4.3.6", | ||
"@types/node": "16.18.11", | ||
"chai": "4.3.7", | ||
"codecov": "3.8.3", | ||
"mocha": "9.2.2", | ||
"nodemon": "2.0.15", | ||
"mocha": "10.0.0", | ||
"nodemon": "2.0.20", | ||
"nyc": "15.1.0", | ||
"rimraf": "3.0.2", | ||
"source-map-support": "0.5.21", | ||
"testdouble": "3.16.5", | ||
"ts-node": "10.7.0", | ||
"typescript": "4.6.3" | ||
"testdouble": "3.16.8", | ||
"ts-node": "10.9.1", | ||
"typescript": "4.9.4" | ||
} | ||
} |
@@ -11,3 +11,3 @@ # generic-type-guard | ||
**Bugs/Support:** [Github Issues][gh-issues] | ||
**Copyright:** 2020 | ||
**Copyright:** 2022 | ||
**License:** [MIT license][license] | ||
@@ -18,3 +18,3 @@ **Status:** Active | ||
This library is an attempt to manage creating type guards in a sensible way, making them | ||
This library is an attempt to manage creating type guards in a sensible way, making them | ||
composable and reusable. | ||
@@ -28,3 +28,3 @@ | ||
The point of this library is to provide a suite of type guard expressions that are | ||
The point of this library is to provide a suite of type guard expressions that are | ||
themselves both type safe and composable in a type safe way. To that end we define two new | ||
@@ -38,3 +38,3 @@ types which are just aliases for the built-in type guard type: | ||
A `PartialTypeGuard` is a type guard which given a value of type `T` can prove it is | ||
A `PartialTypeGuard` is a type guard which given a value of type `T` can prove it is | ||
actually the specialised type `U`. A `TypeGuard` is a type guard that can prove any value | ||
@@ -58,13 +58,13 @@ to be of type `T`; it is a `PartialTypeGuard<unknown, T>`. | ||
// this fails. | ||
const isBrokenFoo: tg.TypeGuard<Foo> = | ||
tg.isRecord("foo", tg.isString); | ||
const isBrokenFoo: tg.TypeGuard<Foo> = tg.isRecord('foo', tg.isString); | ||
// this works. | ||
const isFoo: tg.TypeGuard<Foo> = | ||
new tg.IsInterface().withProperty("foo", tg.isString).withProperty("bar", tg.isNumber).get(); | ||
const isFoo: tg.TypeGuard<Foo> = new tg.IsInterface() | ||
.withProperty('foo', tg.isString) | ||
.withProperty('bar', tg.isNumber) | ||
.get(); | ||
// This works around the gotchas explained below but has other issues, especially with complex types. | ||
// All guarantees are void if you use this format. | ||
const isFoo = | ||
new tg.IsInterface().withProperty("foo", tg.isString).withProperty("bar", tg.isNumber).get(); | ||
const isFoo = new tg.IsInterface().withProperty('foo', tg.isString).withProperty('bar', tg.isNumber).get(); | ||
``` | ||
@@ -80,6 +80,6 @@ | ||
```typescript | ||
import * as tg from "generic-type-guard"; | ||
import * as tg from 'generic-type-guard'; | ||
export const isComplexInterface = | ||
new tg.IsInterface().withProperties({ | ||
export const isComplexInterface = new tg.IsInterface() | ||
.withProperties({ | ||
str: tg.isString, | ||
@@ -90,3 +90,4 @@ num: tg.isNumber, | ||
nullableString: tg.isNullable(tg.isString), | ||
}).get(); | ||
}) | ||
.get(); | ||
export type ComplexInterface = tg.GuardedType<typeof isComplexInterface>; | ||
@@ -101,3 +102,3 @@ ``` | ||
`generic-type-guard` works with the TypeScript type system. You are guaranteed that the type guards you write are *sufficient* to prove | ||
`generic-type-guard` works with the TypeScript type system. You are guaranteed that the type guards you write are _sufficient_ to prove | ||
that the thing provided to it conforms in one way or another to the type that the type guard checks for. But that doesn't necessarily mean | ||
@@ -110,10 +111,10 @@ that all valid values of that type will be allowed. Put another way, you are guaranteed to never get a false positive but you may get false | ||
```typescript | ||
import * as tg from "generic-type-guard"; | ||
import * as tg from 'generic-type-guard'; | ||
type FooBar = "foo" | "bar"; | ||
type FooBar = 'foo' | 'bar'; | ||
const isFooBar: tg.TypeGuard<FooBar> = tg.isSingletonString("foo"); | ||
const isFooBar: tg.TypeGuard<FooBar> = tg.isSingletonString('foo'); | ||
``` | ||
The above example checks for a single value `"foo"`. This *is* a FooBar and so the type system does not complain. But if you try to pass | ||
The above example checks for a single value `"foo"`. This _is_ a FooBar and so the type system does not complain. But if you try to pass | ||
`"bar"` into this type guard then it will return false. | ||
@@ -128,3 +129,3 @@ | ||
const isFoo: tg.TypeGuard<Foo> = tg.isRecord("foo", tg.isString); | ||
const isFoo: tg.TypeGuard<Foo> = tg.isRecord('foo', tg.isString); | ||
``` | ||
@@ -139,9 +140,9 @@ | ||
```typescript | ||
const isFoo = tg.isRecord("foo", tg.isOptional(tg.isString)); | ||
const isFoo = tg.isRecord('foo', tg.isOptional(tg.isString)); | ||
type Foo = tg.GuardedType<typeof isFoo>; | ||
``` | ||
[gh-contrib]: https://github.com/mscharley/generic-type-guard/graphs/contributors | ||
[gh-issues]: https://github.com/mscharley/generic-type-guard/issues | ||
[license]: https://github.com/mscharley/generic-type-guard/blob/master/LICENSE | ||
[example-usage]: https://github.com/mscharley/generic-type-guard/blob/master/packages/generic-type-guard/src/examples.spec.ts | ||
[gh-contrib]: https://github.com/mscharley/generic-type-guard/graphs/contributors | ||
[gh-issues]: https://github.com/mscharley/generic-type-guard/issues | ||
[license]: https://github.com/mscharley/generic-type-guard/blob/master/LICENSE | ||
[example-usage]: https://github.com/mscharley/generic-type-guard/blob/master/packages/generic-type-guard/src/examples.spec.ts |
@@ -106,3 +106,3 @@ ## API Report File for "generic-type-guard" | ||
// @public | ||
export const isInstance: <T extends object>(klass: new (...args: unknown[]) => T) => TypeGuard<T>; | ||
export const isInstance: <T extends object>(klass: new (...args: never[]) => T) => TypeGuard<T>; | ||
@@ -109,0 +109,0 @@ // @public |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
145083
138