@@ -9,28 +9,29 @@ TypeScript does not allow decorator properties that are protected or private.
99Example Usage:
1010
1111``` ts
12- import { CreateDestroyStartStop , ready } from ' @matrixai/async-init/dist/CreateDestroyStartStop' ;
12+ import {
13+ CreateDestroyStartStop ,
14+ ready ,
15+ } from ' @matrixai/async-init/dist/CreateDestroyStartStop' ;
1316
1417// this hack is necessary to ensure that X's type is decorated
15- interface X extends CreateDestroyStartStop {};
18+ interface X extends CreateDestroyStartStop {}
1619@CreateDestroyStartStop (new Error (' Running' ), new Error (' Destroyed' ))
1720class X {
1821 protected y: Y ;
1922
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 ());
2829 const x = new this ({ y });
2930 await x .start ();
3031 return x ;
3132 }
3233
33- public constructor ({ y }: { y: Y }) {
34+ public constructor ({ y }: { y: Y }) {
3435 this .y = y ;
3536 }
3637
@@ -57,15 +58,14 @@ class X {
5758}
5859
5960// this hack is necessary to ensure that Y's type is decorated
60- interface Y extends CreateDestroyStartStop {};
61+ interface Y extends CreateDestroyStartStop {}
6162@CreateDestroyStartStop (new Error (' Running' ), new Error (' Destroyed' ))
6263class Y {
6364 public static async createY() {
6465 return new this ();
6566 }
6667
67- public constructor () {
68- }
68+ public constructor () {}
6969
7070 public async destroy(): Promise <void > {
7171 console .log (' Y destroyed' );
@@ -77,7 +77,7 @@ class Y {
7777 }
7878}
7979
80- async function main () {
80+ async function main() {
8181 const x = await X .createX ();
8282 await x .doSomething ();
8383 await x .stop ();
0 commit comments