TypeScript - possibly undefined compilation error when throwing by iterator -


i'm keeping on train ts generators when annoying transpiler behaviour occurred. of course, use --strictnullchecks

function* generat(end: number) {   (let = 0; <= end; i++) {     try {       yield i;     } catch (e) {       console.log(e);     }   } }  let iterat = generat(5);  console.log(iterat.next()); console.log(iterat.next()); console.log(iterat.throw()); // error: object possibly 'undefined'. console.log(iterat.next()); console.log(iterat.next()); console.log(iterat.next()); 

anybody know smart solution? mean smart different in link: https://github.com/microsoft/typescript/issues/14431


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -