-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed as not planned
Closed as not planned
Copy link
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
π Search Terms
inference intersection function
inference intersection
π Version & Regression Information
- This changed between versions 3.3.3 and 3.5.1
β― Playground Link
π» Code
function prop<T, K extends keyof T>(_key: K): (input: T) => T[K] {
throw new Error("Not implemented");
}
function pipe<A, B>(input: A, f1: (input: A) => B): B;
function pipe<A, B, C>(input: A, f1: (input: A) => B, f2: (input: B) => C): C;
function pipe(..._args: unknown[]): unknown {
throw new Error("Not implemented");
}
type Decorated1<T, U> = {
(arg: T): U;
dummy: string;
};
type Decorated2<T, U> = {
(arg: T): U;
} & {
dummy: string;
};
function map1<T, U>(_callbackfn: (value: T) => U): Decorated1<T[], U[]> {
throw new Error("Not implemented");
}
function map2<T, U>(_callbackfn: (value: T) => U): Decorated2<T[], U[]> {
throw new Error("Not implemented");
}
pipe(
{ inner: [1, 2, 3] },
prop("inner"),
map1((x) => x * 10),
);
pipe(
{ inner: [1, 2, 3] },
prop("inner"),
map2((x) => x * 10),
);π Actual behavior
Type inference fails when using map2.
π Expected behavior
Type inference succeeds for both map1 and map2.
Additional information about the issue
Using the & operator to add members to a function type breaks type inference, but using a single record type works as expected.
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created