Make argument type more specific for isOfType
This commit is contained in:
parent
9c7de4f5af
commit
7e8eeb96c2
1 changed files with 4 additions and 2 deletions
|
|
@ -93,10 +93,12 @@ function isPrimitiveTypeName(name: unknown): name is PrimitiveTypeName {
|
|||
|
||||
export type TypeName = ObjectTypeName | PrimitiveTypeName;
|
||||
|
||||
const {toString} = Object.prototype;
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
const isOfType = <T extends Function | Primitive>(type: string) => (value: unknown): value is T => typeof value === type;
|
||||
function isOfType<T extends Primitive | Function>(type: PrimitiveTypeName | 'function') {
|
||||
return (value: unknown): value is T => typeof value === type;
|
||||
}
|
||||
|
||||
const {toString} = Object.prototype;
|
||||
const getObjectType = (value: unknown): ObjectTypeName | undefined => {
|
||||
const objectName = toString.call(value).slice(8, -1);
|
||||
if (objectName) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue