Repository: TypeScript
Issue: Unable to infer method property but able to infer arrow function property
Labels: Needs Investigation,Rescheduled

# Bug Report

<!--
  Please fill in each section completely. Thank you!
-->

### 🔎 Search Terms

This issue came from StackOverflow [question](https://stackoverflow.com/questions/67373548/typescript-error-when-an-object-literal-has-functions)

### 🕗 Version & Regression Information

Since `Object.fromEntries`


### ⏯ Playground Link

<!--
  A link to a TypeScript Playground "Share" link which shows this behavior

  The TypeScript Workbench can be used for more complex setups, try
  https://www.typescriptlang.org/dev/bug-workbench/

  As a last resort, you can link to a repo, but these will be slower for us to investigate.
-->
[Playground link with relevant code](https://www.typescriptlang.org/play?target=99&ts=4.2.3#code/MYewdgzgLgBAlgExgXhgHgCoBoB8AKADwC4YMBKEjFHGAgKDtElgGsBTATwhOgCc4wAcwDaAXRQwxDJtHhQ2vCey4A6ALYBDAA54W1SXRhGYLLIeOI8AbxjzoeMjBsBfGM8cB6DzBAs6osgYPACpgw2CYABEAeQBRAGUYADloqgB1aIAlAGlwj0ZwWQAzDTgAGwgJaIAjACs2YCgVIt4QNViwKH42CF1OCHVtXX1hcyNTMfgEa1seqAcnNzdPbzQAWg3NmFjMzKz-MkCg0PCYDJy8guYfOoBGKrqGppa2jq64Hrw4eV4jq9lEJkegBXMqwVCWGx2eaOFzLf6wEB1ABMD3qjWarXanW6vWUA00Oj0yBoo2MJjM5MBILBBz+MkRdQAzGinpjXjiPnj+oMiSNJhMqdMoXMSAsSYtXO4YF4fH4AvTCozagAWVkYl7Y96fAU8wloYR8ASCLCLaEOEgANxAiDconwukcEuEpimM3NsKW7gCdDIAG4GHQrJMBD8SsA2DAALJsKAACxASGD5PJFpg1sQAfJzkmDKmEkwMDYBHkYAQlRswi0rS0PHeQlEJBj8cTbnwxFITpoBADuaVJn6df4QjEEjEvfJeaRtXVzyxb1xfVUhLwjpGrshs3snqlZAVfpl3l8DBzQcmUA4WkjAEFeK0AO4ABRrEnFNA0YA4WeMedtqELxaluWixVjWQ7Go2MC3g+z4gFobaEJQXa0L2fbXNOs7slqi74ryq4sMhLqmpuHqSss+50KeyY-v2iAAPoFrBWimlQgFsGWlRAqAvAIGgRpCKaTE4O2SH6D2kyyvsk60Ug-6sSW7HAdOTwiZ2YnfkYU4ophmoLlyS4EkMa7OhuwpbjCZHeocAbOEAA)

### 💻 Code

<!-- Please post the relevant code sample here as well-->
```ts
const id = <T,>(x: T): T => x

const keys: string[] = []

/**
 * TS is unable to infer T generic argument of  fromEntries
 */
const fails = Object.fromEntries(keys.map(k => [
    k,
    id({ test() { } }) // <------ ERROR
]))

```

### 🙁 Actual behavior

```ts
const result: {
    [k: string]: T;
}
```
### 🙂 Expected behavior

```ts
const result: {
    [k: string]: {
        test(): void;
    };
}
```

I thought that it  has smth to do with excess property checking,  but it works if you replace `id({ test() { } })` with `id({ test:()=> { } })` 
Full list of workarounds:
```ts

/**
 * WORK
 */
const iter = keys.map(k => [
    k,
    id({ test() { } }) // ok
])
const obj1 = Object.fromEntries(iter)


const idResult = id({ test() { } })
const obj2 = Object.fromEntries(keys.map(k => [
    k,
    idResult
]))


const obj3 = Object.fromEntries(keys.map(k => [
    k,
    id({ test: () => { } }) // ok
]))


const obj4 = Object.fromEntries(
    keys.map<[string, { test(): void }]>((k) => [k, id({ test() { } })])
);


{
    interface Method {
        (): void;
    }
    const id = <T extends { [prop: string]: Method }>(x: T) => x;

    const keys: string[] = [];

    const obj = Object.fromEntries(keys.map((k) => [k, id({ test() { } })])); // ok

}

{
    type ArrowProp = () => any;
    const id = <T extends { [prop: string]: ArrowProp }>(x: T) => x;


    const obj = Object.fromEntries(keys.map((k) => [k, id({ test() { } })]));
}

{
    const id_ = <Prop, T extends Record<string, Prop>>(x: T) => x;
    // OR
    const id = <T extends object>(x: T) => x;
    const obj2 = Object.fromEntries(keys.map((k) => [k, id({ test() { } })]));
}
```
[Playground](https://www.typescriptlang.org/play?target=99&ts=4.2.3#code/MYewdgzgLgBAlgExgXhgHgCoBoB8AKADwC4YMBKEjFHGAgKDtElgGsBTATwhOgCc4wAcwDaAXRQwxDAPQAqWXRiyYAEQDyAUQDKMAHJqqAdTUAlANKLZ0xuGgwAZgEM4AGwgS1AIwBWbYFAA6e14QAFsNMCh+Ngg8di4A0McABzjqSUUYLJYsTKzEPABvGCgYqDwyGGKAXxhqyulpdABaVraYDRMTUzpRMjIGGXlLGGNzS2smOzhS3gl4iESUtOQaYTyYHI2C4tLoCqq6uoamkBZeganYEB8ARg8fP0DgsIiouBi8GbZeAYYr+AIEwxACuLlgqB2JTKBxqxxszBgN28ACYHr5-EEQuFItFYgslqkWOl1llsrkyYDgRAwVALn8EXZkQBmdFPLGvXEffGcRZJIkkjZbSlQvZQEgHVaHWr1GCNJHnPoMgHIgAsbMxLxx70+Qt5hLQwj4AkEWEOYoqJAAbiBEHVRPg4pUpcIcoCitD9pU4fU+nQyABuQaFbaRH5OYBsGAAWTYUAAFiAkCHKZTLTAbYgg5TqhsAXbUJgYGwCKUwAh3MVhMkQskeO8hKISLGE0m6vhiKRnTQCEG87ZWLz6-whGIJGI+5SVT4Nc9sW88XF9fy8E6SW7RTDvUdff0A3LTuc6Lm6CmyVAOMkowBBXghADuAAVaxJJTRHGAONmyfmkIWqCWZYVoc1a1sOJpNjAt4Ps+IDJO2hCUN2tB9v2iLIrOHLaouBIrmuLobggHoWtuMpkEqQYnmeWS-gA+hIaCwckZoAaWbDlu4wKgLwCBoMaQhmkxOAdkh6S9hs8o9FOA6AgxrFAe4yJPCJXZid+NEyciaKoF4GJzpyOo8gkeEsMhrpmpuXrSscFHHkAA)

If I'm wrong and it is not a bug, could you please explain why TS is unable to infer method property?

I know that methods are bivariant, but I'm not sure if it has smth to do with current case