zzzgoo
zzzgoo

Reputation: 2235

how to set a field for an function object in typescript?

enter image description here

enter image description here

I want to set a field which is called __times of a Function object. But I got an error in vs-code.

Please tell me what is the appropriate way to do that?

Upvotes: 1

Views: 55

Answers (1)

basarat
basarat

Reputation: 275847

But I got an error in vs-code.

Simplest way I can think of removing the error, add & {__times?:number}

Complete example

let getCountableWrapper = (func: Function & {__times?:number}) => {
  return func.__times = 0;
}

Upvotes: 2

Related Questions