Found while implementing #456. The Iterator/IterableIterator arm added there accepts the lib's defaulted type-parameter range (Iterator<T, TReturn = any, TNext = any>, 1–3 args). The pre-existing Generator / AsyncGenerator arms in ResolveGenericType (TypeChecker.Generics.cs) still require exactly 1 type argument, so they reject the lib spelling.
Repro
function* gen(): Generator<number, void, unknown> { yield 1; }
// ^ Type Error: Generator requires exactly 1 type argument, got 3.
The lib signatures are Generator<T = unknown, TReturn = any, TNext = unknown> and AsyncGenerator<T = unknown, TReturn = any, TNext = unknown>.
Fix shape
In ResolveGenericType, change the Generator / AsyncGenerator arms to accept 1–3 arguments and keep only the first (the yield type), dropping TReturn/TNext — exactly like the Iterator / IterableIterator arm added in #456. Out-of-range should be TS2707 ("requires between 1 and 3 type arguments"), the code tsc uses for a defaulted range, matching the Iterator arm.
Found while implementing #456. The
Iterator/IterableIteratorarm added there accepts the lib's defaulted type-parameter range (Iterator<T, TReturn = any, TNext = any>, 1–3 args). The pre-existingGenerator/AsyncGeneratorarms inResolveGenericType(TypeChecker.Generics.cs) still require exactly 1 type argument, so they reject the lib spelling.Repro
The lib signatures are
Generator<T = unknown, TReturn = any, TNext = unknown>andAsyncGenerator<T = unknown, TReturn = any, TNext = unknown>.Fix shape
In
ResolveGenericType, change theGenerator/AsyncGeneratorarms to accept 1–3 arguments and keep only the first (the yield type), droppingTReturn/TNext— exactly like theIterator/IterableIteratorarm added in #456. Out-of-range should be TS2707 ("requires between 1 and 3 type arguments"), the codetscuses for a defaulted range, matching the Iterator arm.