type Fields = { [P in "foo" | "bar"]?: number; // in the real code, this is [P in anArrayOfStrings] }; const field: Fields = { "foo&quo