@@ -9,28 +9,29 @@ TypeScript does not allow decorator properties that are protected or private.
9
9
Example Usage:
10
10
11
11
``` ts
12
- import { CreateDestroyStartStop , ready } from ' @matrixai/async-init/dist/CreateDestroyStartStop' ;
12
+ import {
13
+ CreateDestroyStartStop ,
14
+ ready ,
15
+ } from ' @matrixai/async-init/dist/CreateDestroyStartStop' ;
13
16
14
17
// this hack is necessary to ensure that X's type is decorated
15
- interface X extends CreateDestroyStartStop {};
18
+ interface X extends CreateDestroyStartStop {}
16
19
@CreateDestroyStartStop (new Error (' Running' ), new Error (' Destroyed' ))
17
20
class X {
18
21
protected y: Y ;
19
22
20
- public static async createX(
21
- {
22
- y
23
- }: {
24
- y? : Y
25
- } = {}
26
- ) {
27
- y = y ?? await Y .createY ();
23
+ public static async createX({
24
+ y ,
25
+ }: {
26
+ y? : Y ;
27
+ } = {}) {
28
+ y = y ?? (await Y .createY ());
28
29
const x = new this ({ y });
29
30
await x .start ();
30
31
return x ;
31
32
}
32
33
33
- public constructor ({ y }: { y: Y }) {
34
+ public constructor ({ y }: { y: Y }) {
34
35
this .y = y ;
35
36
}
36
37
@@ -57,15 +58,14 @@ class X {
57
58
}
58
59
59
60
// this hack is necessary to ensure that Y's type is decorated
60
- interface Y extends CreateDestroyStartStop {};
61
+ interface Y extends CreateDestroyStartStop {}
61
62
@CreateDestroyStartStop (new Error (' Running' ), new Error (' Destroyed' ))
62
63
class Y {
63
64
public static async createY() {
64
65
return new this ();
65
66
}
66
67
67
- public constructor () {
68
- }
68
+ public constructor () {}
69
69
70
70
public async destroy(): Promise <void > {
71
71
console .log (' Y destroyed' );
@@ -77,7 +77,7 @@ class Y {
77
77
}
78
78
}
79
79
80
- async function main () {
80
+ async function main() {
81
81
const x = await X .createX ();
82
82
await x .doSomething ();
83
83
await x .stop ();
0 commit comments