🔎 Search Terms
generic generator static
🕗 Version & Regression Information
- I was unable to test this on prior versions because there is still no online version of every-ts bisect
⏯ Playground Link
Link
💻 Code
classBase{static*[Symbol.iterator]<T>(this: T){yieldthis;}}classChildextendsBase{}consttest=function*(){yield*Child};constvalue=[...test()][0];// Tconsole.log(value);// Child🙁 Actual behavior
The result is typed as T, whatever generic parameter outside of generic code means.
🙂 Expected behavior
T should be instantiated with Child during a call to [Symbol.iterator]
Additional information about the issue
For regular static method calls it works as expected, by instantiating T
classBase{staticfoo<T>(this: T){returnthis;}}classChildextendsBase{}constvalue=Child.foo();// Childconsole.log(value);// ChildOn the other hand, this is a nice way to create unique types for opaque type implementation! 🙃
🔎 Search Terms
generic generator static
🕗 Version & Regression Information
⏯ Playground Link
Link
💻 Code
🙁 Actual behavior
The result is typed as T, whatever generic parameter outside of generic code means.
🙂 Expected behavior
T should be instantiated with Child during a call to
[Symbol.iterator]Additional information about the issue
For regular static method calls it works as expected, by instantiating T
On the other hand, this is a nice way to create unique types for opaque type implementation! 🙃