mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 20:37:46 -05:00
Improve type checking and inference for Generators and Async Generators (#30790)
* Improve typing for Generators and Async Generators * Add TReturn and TNext to Iterator, IterableIterator, etc. * Update ts internal Iterator to be assignable from global Iterator * Make 'done' optional in IteratorYieldResult * Revert Iterable and IterableIterator to simpler versions plus other fixes * Add additional inference tests * Added additional tests * PR cleanup and minor async iteration type fix * Updated diagnostics message and added non-strict tests * Fix expected arity of Iterator/AsyncIterator
This commit is contained in:
@@ -40,6 +40,7 @@ namespace ts {
|
||||
["es2017.string", "lib.es2017.string.d.ts"],
|
||||
["es2017.intl", "lib.es2017.intl.d.ts"],
|
||||
["es2017.typedarrays", "lib.es2017.typedarrays.d.ts"],
|
||||
["es2018.asyncgenerator", "lib.es2018.asyncgenerator.d.ts"],
|
||||
["es2018.asynciterable", "lib.es2018.asynciterable.d.ts"],
|
||||
["es2018.intl", "lib.es2018.intl.d.ts"],
|
||||
["es2018.promise", "lib.es2018.promise.d.ts"],
|
||||
@@ -1899,7 +1900,9 @@ namespace ts {
|
||||
case "object":
|
||||
return {};
|
||||
default:
|
||||
return option.type.keys().next().value;
|
||||
const iterResult = option.type.keys().next();
|
||||
if (!iterResult.done) return iterResult.value;
|
||||
return Debug.fail("Expected 'option.type' to have entries.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user