You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exporttypeIt=Iterator<[string,number],[string,number]>;function*it(): It{yield['',0];// this works βοΈreturn['',0];// this fails β}
π Actual behavior
The return statement does not constraint the array literal to the right type. Instead, it takes its... I dont know how to put it... its "natural" type ?
π Expected behavior
Both yield & return statements should compile.
π Workaround: Force the array to be correctly typed via return ['', 0] as const.
The text was updated successfully, but these errors were encountered:
oguimbal
changed the title
Iterator return type not constraining typed arrays
Iterator return type not constraining typed arrays literals
Oct 22, 2021
Bug Report
π Version & Regression Information
It has always been there. (tested with every Typescript version available in the playground since the support or typing for iterator return types)
β― Playground Link
π Reproduction link in playground
π» Code
π Actual behavior
The return statement does not constraint the array literal to the right type. Instead, it takes its... I dont know how to put it... its "natural" type ?
π Expected behavior
Both yield & return statements should compile.
π Workaround: Force the array to be correctly typed via
return ['', 0] as const
.The text was updated successfully, but these errors were encountered: