mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
28 lines
1.2 KiB
Plaintext
28 lines
1.2 KiB
Plaintext
awaitUsingDeclarationsWithIteratorObject.ts(20,23): error TS2851: The initializer of an 'await using' declaration must be either an object with a '[Symbol.asyncDispose]()' or '[Symbol.dispose]()' method, or be 'null' or 'undefined'.
|
|
|
|
|
|
==== awaitUsingDeclarationsWithIteratorObject.ts (1 errors) ====
|
|
declare const i: Iterator<string, undefined>;
|
|
declare const io: IteratorObject<string, undefined, unknown>;
|
|
declare const g: Generator<string, void>;
|
|
|
|
class MyIterator extends Iterator<string> {
|
|
next() { return { done: true, value: undefined }; }
|
|
}
|
|
|
|
async function f() {
|
|
// should pass
|
|
await using it0 = io;
|
|
await using it1 = g;
|
|
await using it2 = Iterator.from(i)
|
|
await using it3 = new MyIterator();
|
|
await using it4 = [].values();
|
|
await using it5 = new Map<string, string>().entries();
|
|
await using it6 = new Set<string>().keys();
|
|
|
|
// should fail
|
|
await using it7 = i;
|
|
~
|
|
!!! error TS2851: The initializer of an 'await using' declaration must be either an object with a '[Symbol.asyncDispose]()' or '[Symbol.dispose]()' method, or be 'null' or 'undefined'.
|
|
}
|
|
|