diff --git a/README.md b/README.md index bfbe78a..a625e24 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ Issues can be funded by anyone and the money will be transparently distributed t * [`$Shape`](#shapet) * [`$NonMaybeType`](#nonmaybetypet) * [`Class`](#classt) +* [`mixed`](#mixed) ## Deprecated API (use at own risk) * `getReturnOfExpression()` - from TS v2.0 it's better to use type-level `ReturnType` instead @@ -949,6 +950,13 @@ function makeStore(storeClass: Class): Store { [⇧ back to top](#flows-utility-types) +### mixed + +An arbitrary type that could be anything (same as `unknown`) +https://flow.org/en/docs/types/mixed + +[⇧ back to top](#table-of-contents) + --- MIT License diff --git a/src/__snapshots__/utility-types.spec.ts.snap b/src/__snapshots__/utility-types.spec.ts.snap index a1d3fe4..6082557 100644 --- a/src/__snapshots__/utility-types.spec.ts.snap +++ b/src/__snapshots__/utility-types.spec.ts.snap @@ -35,3 +35,5 @@ exports[`$Shape testType<$Shape>() 1`] = `"Partial"`; exports[`$Values testType<$Values>() 1`] = `"string | number | boolean"`; exports[`Class testType>() 1`] = `"Class"`; + +exports[`mixed testType() 1`] = `"unknown"`; diff --git a/src/utility-types.spec.snap.ts b/src/utility-types.spec.snap.ts index 1b5425f..36c7ea9 100644 --- a/src/utility-types.spec.snap.ts +++ b/src/utility-types.spec.snap.ts @@ -10,6 +10,7 @@ import { $Shape, $NonMaybeType, Class, + mixed, } from './utility-types'; import { _DeepReadonlyObject } from './mapped-types'; /** @@ -113,3 +114,9 @@ it('Class', () => { // @dts-jest:pass:snap -> Class testType>(); }); + +// @dts-jest:group mixed +it('mixed', () => { + // @dts-jest:pass:snap -> unknown + testType(); +}); diff --git a/src/utility-types.spec.ts b/src/utility-types.spec.ts index 8e2c2f4..75e2ffe 100644 --- a/src/utility-types.spec.ts +++ b/src/utility-types.spec.ts @@ -10,6 +10,7 @@ import { $Shape, $NonMaybeType, Class, + mixed, } from './utility-types'; import { _DeepReadonlyObject } from './mapped-types'; /** @@ -113,3 +114,9 @@ it('Class', () => { // @dts-jest:pass:snap testType>(); }); + +// @dts-jest:group mixed +it('mixed', () => { + // @dts-jest:pass:snap + testType(); +}); diff --git a/src/utility-types.ts b/src/utility-types.ts index c119b2c..7ccade1 100644 --- a/src/utility-types.ts +++ b/src/utility-types.ts @@ -156,3 +156,20 @@ export type $NonMaybeType = NonNullable; * } */ export type Class = new (...args: any[]) => T; + +/** + * mixed + * @desc An arbitrary type that could be anything + * @see https://flow.org/en/docs/types/mixed + * @example + * + * function stringify(value: mixed) { + * // ... + * } + * + * stringify("foo"); + * stringify(3.14); + * stringify(null); + * stringify({}); + */ +export type mixed = unknown;