🔎 Search Terms
first type argument second type argument optional cannot be inferred
optional type argument wrongly inferred
when first type argument is passed, second one is not inferred
🕗 Version & Regression Information
Occurs on 5.4.0
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.4.0-dev.20240113#code/GYVwdgxgLglg9mABBATgUwIZTQeQEYBWa0APAFCKIAqiaAHtmACYDOiLUKMYA5ogLztO3HgBoKiHLQZpmbAErE4KJiSqjEACgCUAgHyIMYAJ4HBiiMtXqtu-gaOmyBzQGs0xlgC5qAbQC6GnCEPji6AN4S6FAgKEjBBGQAvmRklmAciOhsgqiY2PhE0Jq+AOTAcHClGqV4GCilgYiRlBVwPjr6iKUYLEzVEnUoHXYGPX2lydqpAPQzyAiZ2T6Rc5SIbSNdHFy8ANxka5RDW-ZCuzwHaylpi1BZaCwATALI6Fi4hMRQJOWVpYgAD7dIalPQlP5VGqgpotDaVU5jXr9cTHeqI7rIyZJaaHebpJaPJ4+CxWEgAIja5KBiHJQ3JGk6Z0ceiAA
💻 Code
functioncreateObject<Textendsstring=string,OextendsRecord<T,()=>any>=Record<T,()=>any>>(keys: T[],obj: O){returnobj}constres=createObject(['foo','bar'],{foo: ()=>'asd',bar: ()=>'asd'})// const res: {// foo: () => string;// bar: () => string;// }constres2=createObject<'foo'|'bar'>(['foo','bar'],{foo: ()=>'asd',bar: ()=>'asd'})// const res2: Record<"foo" | "bar", () => any>🙁 Actual behavior
When the first type argument is passed, the second one is not inferred properly.
🙂 Expected behavior
The inferrence of the two code examples should be identical.
Additional information about the issue
No response
🔎 Search Terms
first type argument second type argument optional cannot be inferred
optional type argument wrongly inferred
when first type argument is passed, second one is not inferred
🕗 Version & Regression Information
Occurs on 5.4.0
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.4.0-dev.20240113#code/GYVwdgxgLglg9mABBATgUwIZTQeQEYBWa0APAFCKIAqiaAHtmACYDOiLUKMYA5ogLztO3HgBoKiHLQZpmbAErE4KJiSqjEACgCUAgHyIMYAJ4HBiiMtXqtu-gaOmyBzQGs0xlgC5qAbQC6GnCEPji6AN4S6FAgKEjBBGQAvmRklmAciOhsgqiY2PhE0Jq+AOTAcHClGqV4GCilgYiRlBVwPjr6iKUYLEzVEnUoHXYGPX2lydqpAPQzyAiZ2T6Rc5SIbSNdHFy8ANxka5RDW-ZCuzwHaylpi1BZaCwATALI6Fi4hMRQJOWVpYgAD7dIalPQlP5VGqgpotDaVU5jXr9cTHeqI7rIyZJaaHebpJaPJ4+CxWEgAIja5KBiHJQ3JGk6Z0ceiAA
💻 Code
🙁 Actual behavior
When the first type argument is passed, the second one is not inferred properly.
🙂 Expected behavior
The inferrence of the two code examples should be identical.
Additional information about the issue
No response