-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
TypeScript Version: any, including 4.0.2 and v4.1.0-dev.20201008
Search Terms: typescript generic break filter after spreading object in map? O_o
Code
interface Success {
isSuccess: true;
}
interface Fail {
isSuccess: false;
}
type Item =
| Success
| Fail
// ok
function foo(a: Array<Item>): void {
a
.map((item) => ({...item}))
.filter((value) => {
console.log(value);
});
}
// error
function bar<T extends any>(a: Array<Item>): void {
a
.map((item) => ({...item}))
.filter((value) => {
console.log(value);
});
}
Expected behavior:
adding generic to function does not break the code
Actual behavior:
.filter((value) => {
after .map((item) => ({...item}))
when it inside function with generic trigger error.
andrewbranch
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue