mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Preserve generics in contextual types for rest arguments (#44122)
* Move all getIndexedAccessType flags to AccessFlags enum * Preserve generics in contextual types for rest arguments * Add regression test
This commit is contained in:
@@ -129,3 +129,13 @@ function get<K extends keyof A>(key: K, obj: A): number {
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
// Repro from #44093
|
||||
|
||||
class EventEmitter<ET> {
|
||||
off<K extends keyof ET>(...args: [K, number] | [unknown, string]):void {}
|
||||
}
|
||||
function once<ET, T extends EventEmitter<ET>>(emittingObject: T, eventName: keyof ET): void {
|
||||
emittingObject.off(eventName, 0);
|
||||
emittingObject.off(eventName as typeof eventName, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user