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 -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -