From d8b2606434740847951c9ee3ff5497203e6c575f Mon Sep 17 00:00:00 2001 From: ruanyf Date: Thu, 7 Dec 2023 10:34:26 +0800 Subject: [PATCH] docs(decorator): fix example --- docs/decorator.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/decorator.md b/docs/decorator.md index 8aea41c..821a988 100644 --- a/docs/decorator.md +++ b/docs/decorator.md @@ -251,10 +251,10 @@ inst1.count // 1 ```typescript function functionCallable( - value as any, {kind} as any -) { + value:any, {kind}:any +):any { if (kind === 'class') { - return function (...args) { + return function (...args:any) { if (new.target !== undefined) { throw new TypeError('This function can’t be new-invoked'); } @@ -265,10 +265,13 @@ function functionCallable( @functionCallable class Person { - constructor(name) { + name:string; + constructor(name:string) { this.name = name; } } + +// @ts-ignore const robin = Person('Robin'); robin.name // 'Robin' ```