Bekobiii
Bekobiii

Reputation: 55

Decorator can't be called

I've started learning Typescript and now I'm learning about decorators but for some reason it just won't work even with the example code from the official website. I'll share you my code, maybe you can help me out here.

function Frozen(constructor: Function) {
    Object.freeze(constructor);
}



@Frozen
class Sample {
    id: number;

    constructor(id: number) {
        this.id = id;
    }
}

I do get the following error:

The runtime will invoke the decorator with 2 arguments, but the decorator expects 1.

7 @Frozen

Upvotes: 2

Views: 115

Answers (0)

Related Questions