main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
560 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import { Class } from './Class';
|
---|
| 2 | /**
|
---|
| 3 | * Get the instance type of a `class` from a class object
|
---|
| 4 | * @param C * *typeof** class
|
---|
| 5 | * @returns [[Object]]
|
---|
| 6 | * @example
|
---|
| 7 | * ```ts
|
---|
| 8 | * import {C} from 'ts-toolbelt'
|
---|
| 9 | *
|
---|
| 10 | * /// `create` takes an instance constructor and creates an instance of it
|
---|
| 11 | * declare function create<C extends (new (...args: any[]) => any)>(c: C): C.InstanceOf<C>
|
---|
| 12 | *
|
---|
| 13 | * class A {}
|
---|
| 14 | * class B {}
|
---|
| 15 | *
|
---|
| 16 | * let a = create(A) // A
|
---|
| 17 | * let b = create(B) // B
|
---|
| 18 | * ```
|
---|
| 19 | */
|
---|
| 20 | export declare type Instance<C extends Class> = C extends Class<any[], infer R> ? R : any;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.