custom filter callback not inferred when rule applied
ssukienn opened this issue · comments
Szymon Sukiennik commented
Hi,
// you need to save/refresh page in playground to get rid of effect after (un)comment
// import '@total-typescript/ts-reset';
const isPropTruthy = <T, K extends keyof T>(propName: K) => {
return (item: T): item is T & Required<Pick<T, K>> => !!item[propName];
};
interface User {
id?: string,
//...
}
const client = {
deleteUser: (id: string) => {}
};
([] as User[])
.filter(isPropTruthy('id'))
.map((user) => client.deleteUser(user.id)); // inferred as User & Required<Pick<User, 'id'>
//no rule
// no errors
//with rule
// error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
// error TS2339: Property 'id' does not exist on type 'Required<Pick<unknown, never>>'.
Any idea what's causing inference to stop working?
Thank you!
tsc 5.3.2
Yoo Taejong commented
What rule? Can you link to the minimal reproduction repo with only ts-reset and typescript as dependency?
Szymon Sukiennik commented
Hi, apologies for the clumsy example. Edited the msg and added playground
I believe the rule is @total-typescript/ts-reset/filter
here