On this page
InstanceType
Prev: `ConstructorParameters` | Up: function_and_promise | Next: `ThisParameterType`
Rel: function_and_promise, Conditional & Mapped Types
Ref: TypeScript Docs — Utility Types
Tags: #public #web #typescript #utility-types #function_and_promise #tier/specialized
Syntax & Overview
InstanceType<Ctor>
Extracts the instance type constructed by a class constructor type.
Notes & Pitfalls
- Extracts the instance type of a constructor type: Useful in generic mixins and DI containers.
Example
class Client {
ping() { return "pong"; }
}
type ClientInstance = InstanceType<typeof Client>; // Client
Linked from
Related notes
- tuts/typescript/utility_types/function_and_promise/ConstructorParameters Linked here; links to this page; shared tags: #tier, #typescript, #web
- tuts/typescript/utility_types/function_and_promise/ThisParameterType Linked here; links to this page; shared tags: #tier, #typescript, #web
- tuts/typescript/utility_types/function_and_promise Linked here; links to this page; shared tags: #typescript, #web
- tuts/typescript/type_system/conditional_and_mapped_types Linked here; shared tags: #typescript, #web
- tuts/typescript/builtins/any shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/as_const shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/asserts shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/enum shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/infer shared tags: #tier, #typescript, #web
- tuts/typescript/builtins/is shared tags: #tier, #typescript, #web