-
Notifications
You must be signed in to change notification settings - Fork 0
guards.Function.isCtor
github-actions[bot] edited this page Jun 8, 2026
·
1 revision
@zenstone/ts-utils / guards / isCtor
isCtor<
T>(val):val is Constructor<T>
Defined in: src/guards/index.ts:306
检查值是否为可 new 调用的构造函数(class 或普通函数)
箭头函数没有 prototype,返回 false;class 和普通函数返回 true。
T = object
unknown
任意值
val is Constructor<T>
isCtor(class Foo {}) // true → val is Constructor<object>
isCtor<Foo>(class Foo {}) // true → val is Constructor<Foo>
isCtor(() => {}) // false
isCtor(null) // false