Skip to content

Commit b1a4ef1

Browse files
committed
fix: ensure abstraction type declaration is preserved
1 parent d6bd7e3 commit b1a4ef1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changeset/kind-singers-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@webiny/di": patch
3+
---
4+
5+
ensure generic type is preserved in Abstraction.d.ts when built

src/Abstraction.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@ type Implementation<A extends Abstraction<any>, I extends Constructor> = I & {
99

1010
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1111
export class Abstraction<T> {
12-
// If the generic type is not used in any way, TS simply ignores it, thus breaking the desired type checking.
13-
private readonly __type?: T;
12+
/**
13+
* If the generic type is not used in any way, TS simply ignores it, thus breaking the desired type checking.
14+
* We must set this to `protected` to prevent TSC from stripping the type away.
15+
* @internal
16+
*/
17+
protected readonly __type!: T;
18+
1419
public readonly token: symbol;
1520

1621
constructor(name: string) {

0 commit comments

Comments
 (0)