type-guards icon indicating copy to clipboard operation
type-guards copied to clipboard

Simple utility for runtime type checking which also assigns the correct type if used with TypeScript.

Results 23 type-guards issues
Sort by recently updated
recently updated
newest added

Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1. Changelog Sourced from y18n's changelog. Change Log All notable changes to this project will be documented in this file. See standard-version for commit guidelines....

dependencies

This adds the function `tg.optional` which takes a type guard as an argument and returns an optional version of that typegaurd. This allows `isOfShape` to handle optional properties. fix: #35...

For a majority of usecases, the following types are treated as equal: ```ts interface Type1 { x?: number } interface Type2 { x: number | undefined } ``` The difference...

help wanted
question

```ts import { isNumber, isOfShape, isOneOf, isUndefined } from 'type-guards'; const isFoo = isOfShape({ bar: isOneOf(isNumber, isUndefined), baz: isNumber }); // This is ok. console.log(isFoo({ bar: undefined, baz: 123 }));...

Instead of writing `tg.throwIf(tg.isNot(tg.isString))`, it would be nicer to write `tg.throwUnless(tg.isString)`.

enhancement
good first issue

https://stackoverflow.com/questions/18884249/checking-whether-something-is-iterable

enhancement
good first issue

From [here](https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-beta/): > ```ts > function assertIsString(val: any): asserts val is string { > if (typeof val !== "string") { > throw new AssertionError("Not a string!"); > } > }...

enhancement
question

```ts const isMorphRuleOfType = (type: TMorphType) => { return (rule: MorphRuleBase): rule is MorphRuleBase => { return rule.type === type } } ``` Think of a way to quickly create...

enhancement

Instead of writing ```ts export const isLanguageCode = tg.isEnum(...enumValues(LanguageCode)) ``` where `enumValues` is a function defied as follows ```ts export function enumValues (enumeration: T): Array { return objectKeys(enumeration) .filter(k =>...

enhancement

The lib currently exports `Guard` with only one generic argument: `(x: any) => x is T`, but I found that in code I often need `(x: V) => x is...

enhancement
good first issue