kungfooman / RuntimeTypeInspector.js

Checking JSDoc types at runtime for high-quality types - Trust is good, control is better.
MIT License
8 stars 0 forks source link

Implement `{type: 'new'}` validation #163

Closed kungfooman closed 3 months ago

kungfooman commented 3 months ago

Example:

class ObjectPool {
  /**
   * @param {new (...args: any[]) => any} constructorFunc - The constructor function for the
   * objects in the pool.
   */
  constructor(constructorFunc) {
    this._constructor = constructorFunc;
  }
}
const objectPool = new ObjectPool(Float32Array);

Error:

ObjectPool#constructor> The 'constructorFunc' argument has an invalid type. unchecked

image