Skip to content

Commit f33b53a

Browse files
committed
docs: add instructions on how to temporary type a property added by a decorator
1 parent 3b4e777 commit f33b53a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,19 @@
44
![Codecov](https://img.shields.io/codecov/c/github/devsheva/simplelog)
55

66
A simple logger decorator amplify like
7+
8+
## Important
9+
10+
**Experimental decorators** are used for this package implementation and since experimental it has some bugs like unsafe typing.
11+
TypeScript compiler complains when it finds out a property used inside a class that calls a decorator cause it cannot infer it, so as a temporary workaround simply declare an interface
12+
13+
```ts
14+
interface Example {logger: any}
15+
16+
@Logger()
17+
class Example {
18+
hello() {
19+
this.logger.debug() // THIS IS VALID
20+
}
21+
}
22+
```

0 commit comments

Comments
 (0)