Pick generic interface property based on result of function
08:18 16 Feb 2026

I got an interface of a React Component that looks like this:

interface SomeReactComponentProps {
    resources: Resource[];
    selectName: (resource: Resource) => string;
}

The selectName callback is used to define the specific name property of the resource, which might be resource1.name, resource2.foo, resource3.bar etc.

I now want the type of the resources to be a partial of the Resource-generic, that at least contains the identified name-property from the selectName-function plus (optionally) any additional properties of the generic.

Does anyone have an idea how to do this in Typescript, so that I get type safety for the resources depending on the selectName-function?

Thanks in advance :)

typescript types typescript-generics