SelectionMap with nested objects

Hi, I'm trying to re-create the db.query({ with: {} }) but it's not working with nested objects because I don't know the type.

For example:

// Note the "any", which should be the type I'm missing.
type SelectionMap<T extends ProductSelect> = {
  [K in keyof T]: T[K] extends true ? { [key: string]: any } : {};
};

export namespace ProductSearchService {
  function getSelect<T extends ProductSelect>(select: T): SelectionMap<T> {
    return {
      ...(select.test
        ? {
            testA: {
              id: testTable.id,
              name: testTable.name,
            },
            testB: {
              id: testTable2.id,
              name: testTable2.name,
            },
          }
        : {}),


the product.testA will work, but product.testA.id will not, which is what I'm trying to fix.
I imagine there is a helper for this?
Was this page helpful?