Skip to content

Commit fec1912

Browse files
committed
docs(decorator): fixed example #140
1 parent 07830d2 commit fec1912

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

docs/decorator.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,14 +357,16 @@ class C {
357357
如果方法装饰器返回一个新的函数,就会替代所装饰的原始函数。
358358

359359
```typescript
360-
function replaceMethod() {
361-
return function () {
360+
function replaceMethod(value:any, context:ClassMethodDecoratorContext) {
361+
return function (this:Person) {
362362
return `How are you, ${this.name}?`;
363363
}
364364
}
365365

366366
class Person {
367-
constructor(name) {
367+
name: string;
368+
369+
constructor(name:string) {
368370
this.name = name;
369371
}
370372

0 commit comments

Comments
 (0)