Refactor to use type-fest

Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
Richie Bendall 2020-07-19 20:19:00 +12:00
parent 4b35ad5bec
commit 8dd3a34bed
No known key found for this signature in database
GPG key ID: 94AE1ACB662A2A6D
2 changed files with 4 additions and 28 deletions

View file

@ -46,6 +46,9 @@
"typeguards",
"types"
],
"dependencies": {
"type-fest": "^0.16.0"
},
"devDependencies": {
"@sindresorhus/tsconfig": "^0.7.0",
"@types/jsdom": "^16.1.0",

View file

@ -2,7 +2,7 @@
/// <reference lib="dom"/>
/// <reference types="node"/>
export type Class<T = unknown> = new (...args: any[]) => T;
import {Class, TypedArray, ObservableLike, Primitive} from 'type-fest';
const typedArrayTypeNames = [
'Int8Array',
@ -18,19 +18,6 @@ const typedArrayTypeNames = [
'BigUint64Array'
] as const;
export type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array
| BigInt64Array
| BigUint64Array;
type TypedArrayTypeName = typeof typedArrayTypeNames[number];
function isTypedArrayName(name: unknown): name is TypedArrayTypeName {
@ -80,15 +67,6 @@ const primitiveTypeNames = [
'symbol'
] as const;
export type Primitive =
| null
| undefined
| string
| number
| bigint
| boolean
| symbol;
type PrimitiveTypeName = typeof primitiveTypeNames[number];
function isPrimitiveTypeName(name: unknown): name is PrimitiveTypeName {
@ -319,11 +297,6 @@ is.domElement = (value: unknown): value is HTMLElement => {
DOM_PROPERTIES_TO_CHECK.every(property => property in value);
};
export interface ObservableLike {
subscribe(observer: (value: unknown) => void): void;
[Symbol.observable](): ObservableLike;
}
is.observable = (value: unknown): value is ObservableLike => {
if (!value) {
return false;