Quiz: Three Biggest Features in TypeScript 5.0

Test yourself on what you’ve learned about the biggest features of TypeScript 5.0 in this chapter.

1

What does the context parameter represent in the @deprecated decorator?

const deprecated = <This, Arguments extends any[], ReturnValue>(
  target: (this: This, ...args: Arguments) => ReturnValue,
  context: ClassMethodDecoratorContext<
    This,
    (this: This, ...args: Arguments) => ReturnValue
  >,
) => {
  const methodName = String(context.name);

  function replacementMethod(this: This, ...args: Arguments): ReturnValue { 
    console.warn(`Warning: '${methodName}' is deprecated.`);
    return target.call(this, ...args);
  }
  
  return replacementMethod;
};
A)

The replacement method for the decorated function

B)

Metadata about the decorated method

C)

The target method being decorated

D)

The current instance of the class

Question 1 of 90 attempted

Get hands-on with 1400+ tech skills courses.