1

Running the latest version of Typescript (4.6.4) when my interface has an index signature Omit doesn't work as expected. Not sure if this is expected behavior or I am misunderstanding something with index signatures.

interface Test1 {
  a: number;
  b: number;
}

// 'Property 'b' is missing in type '{}' but required in type 'Omit<Test1, "a">''
const test1: Omit<Test1, 'a'> = {};

interface Test2 {
  [key: string]: number;
  a: number;
  b: number;
}

// no issues
const test2: Omit<Test2, 'a'> = {};

I would expect that test2 would have the same error as test1.

Luke Belbina
  • 5,708
  • 12
  • 52
  • 75

0 Answers0