The type system isn't strong enough to constrain idKey to keys for which T has a number value, but you can get around this by instead using a generic parameter K for the type of idKey and constraining the list elements to objects that have a number value for that key K.
const updateList = <K extends PropertyKey>(
idKey: K,
list: Record<K, number>[],
id: number
) => {
const listItem = list.find(x => x[idKey] === id)
// ..
}
The builtin type PropertyKey is equal to string | number | symbol (i.e. any valid property key type), and Record<K, number> (see docs) stands for {[P in K]: number}. Basically, the type signature enforces that the list parameter is assignable to an array of singleton objects with an idKey number property, which also allows passing an array of objects with additional properties, as long as idKey has a number value.
Calls to updateList will now only type check correctly:
const list = [{a: 8, b: 'x'}]
updateList('a', list, 0)
updateList('b', list, 0) // Error
Note that since the key parameter is leading the type inference, the error will be on the list parameter rather than on 'b', but that shouldn't be a problem.
TypeScript playground
numbervalues for the list elements, you can kind of achieve what you want: tsplay.dev/m0AYqW. I can turn it into an answer if this works for you.PropertyKeyandRecordare that would be amazing thank you