π Search Terms
noinfer first type argument
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
β― Playground Link
https://tsplay.dev/weGogm
π» Code
type Something<A extends object = object, B extends object = object> = {
a(): A;
b(name: string): B;
test(something: NoInfer<B>): void;
}
function test<const A extends object = object, const B extends object = object>(something: Something<A, B>) { }
test({
test(something) {
// this should a inferred by the return type of b() but it's actually inferred as object
// if you switch from NoInfer<B> to NoInfer<A> in Something it's correctly inferred from
// the return type of a();
something;
},
a() {
return {
type: "a",
value: 43,
};
},
b(name) {
return {
type: "b",
something: true,
name
}
},
});
π Actual behavior
The second type argument in this situation is still inferred as object instead of being the return type of b(). More importantly, if I change NoInfer<B> to NoInfer<A> the argument is correctly inferred from the return type of a()
π Expected behavior
It should correctly infer the second generic argument.
Additional information about the issue
No response
π Search Terms
noinfer first type argument
π Version & Regression Information
β― Playground Link
https://tsplay.dev/weGogm
π» Code
π Actual behavior
The second type argument in this situation is still inferred as
objectinstead of being the return type ofb(). More importantly, if I changeNoInfer<B>toNoInfer<A>the argument is correctly inferred from the return type ofa()π Expected behavior
It should correctly infer the second generic argument.
Additional information about the issue
No response