diff --git a/package.json b/package.json index 718909d..9e7b3d3 100644 --- a/package.json +++ b/package.json @@ -46,9 +46,6 @@ "typeguards", "types" ], - "dependencies": { - "type-fest": "^0.16.0" - }, "devDependencies": { "@sindresorhus/tsconfig": "^0.7.0", "@types/jsdom": "^16.1.0", diff --git a/source/index.ts b/source/index.ts index 86ba271..f8c4e6f 100644 --- a/source/index.ts +++ b/source/index.ts @@ -2,7 +2,7 @@ /// /// -import {Class, TypedArray, ObservableLike, Primitive} from 'type-fest'; +import {Class, TypedArray, ObservableLike, Primitive} from './types'; const typedArrayTypeNames = [ 'Int8Array', diff --git a/source/types.ts b/source/types.ts new file mode 100644 index 0000000..dcae015 --- /dev/null +++ b/source/types.ts @@ -0,0 +1,47 @@ +/** +Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive). +*/ +export type Primitive = + | null + | undefined + | string + | number + | boolean + | symbol + | bigint; + +// TODO: Remove the `= unknown` sometime in the future when most users are on TS 3.5 as it's now the default +/** +Matches a [`class` constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes). +*/ +export type Class = new (...arguments_: Arguments) => T; + +/** +Matches any [typed array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray), like `Uint8Array` or `Float64Array`. +*/ +export type TypedArray = + | Int8Array + | Uint8Array + | Uint8ClampedArray + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + | Float32Array + | Float64Array + | BigInt64Array + | BigUint64Array; + +declare global { + interface SymbolConstructor { + readonly observable: symbol; + } +} + +/** +Matches a value that is like an [Observable](https://github.com/tc39/proposal-observable). +*/ +export interface ObservableLike { + subscribe(observer: (value: unknown) => void): void; + [Symbol.observable](): ObservableLike; +}