docs(decorator): fix example

This commit is contained in:
ruanyf
2023-12-07 10:34:26 +08:00
parent 780059c443
commit d8b2606434

View File

@@ -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 cant 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'
```