Microsoft/TypeScript
Ver no GitHubPredicates break arbitrarily when intersected with some types. (Probably when the predicate is generic).
Open
#60.048 aberto em 24 de set. de 2024
BugDomain: IntersectionHelp Wanted
Métricas do repositório
- Stars
- (48.455 stars)
- Métricas de merge de PR
- (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)
Description
🔎 Search Terms
predicate intersection
🕗 Version & Regression Information
latest version v5.6.2
⏯ Playground Link
💻 Code
interface TruthyPredicate {
<T>(o: T): o is T & {};
}
interface EmptyInterface {
}
type ConstructorSignagure = {
new (...args: any[]): any;
};
declare const arr: (string | undefined)[];
declare const predicate1: TruthyPredicate;
const filtered1 = arr.filter(predicate1); // works string[]
declare const predicate2: TruthyPredicate & EmptyInterface;
const filtered2 = arr.filter(predicate2); // doesn't work
declare const predicate3: TruthyPredicate & {} /* Empty object type instead of interface */;
const filtered3 = arr.filter(predicate3); // works string[]
declare const predicate4: TruthyPredicate & ConstructorSignagure;
const filtered4 = arr.filter(predicate4); // doesn't work
🙁 Actual behavior
Predicate stops working
🙂 Expected behavior
Predicate works
Additional information about the issue
I tried other scenarios