Skip to content

Commit

Permalink
Merge pull request #66 from NilSet/is-type-constraints
Browse files Browse the repository at this point in the history
Add necessary constraints to is-function types for typescript to assert instanceof
  • Loading branch information
dmonad committed May 27, 2023
2 parents be45fd5 + 281dca2 commit cbf869f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions function.js
Expand Up @@ -167,15 +167,15 @@ export const isString = (s) => s && s.constructor === String
export const isNumber = n => n != null && n.constructor === Number

/**
* @template TYPE
* @template {abstract new (...args: any) => any} TYPE
* @param {any} n
* @param {TYPE} T
* @return {n is InstanceType<TYPE>}
*/
export const is = (n, T) => n && n.constructor === T

/**
* @template TYPE
* @template {abstract new (...args: any) => any} TYPE
* @param {TYPE} T
*/
export const isTemplate = (T) =>
Expand Down

0 comments on commit cbf869f

Please sign in to comment.