Disallow unused options object properties in Typescript

Viewed 94

Say we have a function like this:

function foo(input: {
  a: number;
  b: string; // unused property
}): number {
  return input.a * input.a;
}

I want eslint or typescript compiler to show a warning about property b as being unused. It is possible to accomplish this using destructuring as follows:

function foo({a, b}: {
  a: number;
  b: string; // unused property
}): number {
  return a * a;
}

But destructuring is too verbose, especially when you have a large number of properties on the input object.

Is it possible to accomplish this without destructuring the parameter?

0 Answers
Related