Extract nessessary types from type-fest
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
parent
8dd3a34bed
commit
1507a6db56
3 changed files with 48 additions and 4 deletions
|
|
@ -46,9 +46,6 @@
|
||||||
"typeguards",
|
"typeguards",
|
||||||
"types"
|
"types"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
|
||||||
"type-fest": "^0.16.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sindresorhus/tsconfig": "^0.7.0",
|
"@sindresorhus/tsconfig": "^0.7.0",
|
||||||
"@types/jsdom": "^16.1.0",
|
"@types/jsdom": "^16.1.0",
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
/// <reference lib="dom"/>
|
/// <reference lib="dom"/>
|
||||||
/// <reference types="node"/>
|
/// <reference types="node"/>
|
||||||
|
|
||||||
import {Class, TypedArray, ObservableLike, Primitive} from 'type-fest';
|
import {Class, TypedArray, ObservableLike, Primitive} from './types';
|
||||||
|
|
||||||
const typedArrayTypeNames = [
|
const typedArrayTypeNames = [
|
||||||
'Int8Array',
|
'Int8Array',
|
||||||
|
|
|
||||||
47
source/types.ts
Normal file
47
source/types.ts
Normal file
|
|
@ -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<T = unknown, Arguments extends any[] = any[]> = 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;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue