The lib files (es2015.iterable, es2015.generator, es2018.asyncgenerator) define a small ladder of types:
Iterable<T>: has[Symbol.iterator](). It is whatfor...of, spread, destructuring andArray.fromaccept, so use it for parameters.Iterator<T, TReturn, TNext>: thenext()protocol.nextreturnsIteratorResult<T, TReturn>, a discriminated union:{ done?: false; value: T } | { done: true; value: TReturn }. Checkdonebefore trustingvalue.IteratorObject<T, TReturn, TNext>(TS 5.6): an iterator that is also iterable and models the built-in iterator prototype. Withlibes2025 it carries the iterator helpers (map,filter,take,toArray). Built-ins return subtypes such asArrayIterator,SetIteratorandMapIterator.Generator<T, TReturn, TNext>: what afunction*returns.Tis eachyielded value,TReturnthereturnvalue, andTNextthe argument ofnext(x), which is also the value of theyieldexpression. Async versions:AsyncIterable,AsyncIterator,AsyncGenerator, consumed byfor await.
Unannotated generators are inferred. function* g() { yield 1; return "done"; } is Generator<number, string, unknown>; TNext comes from how yield results are used (const x: string = yield gives string), else unknown.
Choose the annotation by what callers may do: Generator<…> when they drive it with next, Iterable<T> when they should only iterate. Iterator<T> alone cannot be used in for...of (TS2488).
Two strict checks catch real bugs, identically on 6.0.3 and 7.0.2. for...of, spread and destructuring call next() with no argument, so iterating a generator whose TNext excludes undefined is an error (TS2763, TS2764, TS2765). And strictBuiltinIteratorReturn (part of --strict since 5.6) sets the intrinsic BuiltinIteratorReturn to undefined instead of any, so set.values().next().value is T | undefined.