Which detached method does TypeScript catch, and what does this log?
Three methods are taken off a Counter and called on their own. Name the type each ^? line points at, every error TypeScript reports, and what the code logs when you run it with its types removed.
class Counter { count = 0; increment() { this.count += 1; return this.count; } decrement(this: Counter) { this.count -= 1; return this.count; } reset = () => { this.count = 0; return this.count; };} const counter = new Counter();const increment = counter.increment;// ^?const decrement = counter.decrement;// ^?const reset = counter.reset; console.log(reset());console.log(increment());console.log(decrement());Work it out first: the compiler shows every error and type.
The answer
Work out every error TypeScript reports and every type it shows, line by line. Then check.
Checking your sign-in…