Reachability analysis of never
for yield*
is unchecked
#58582
Labels
Needs Investigation
This issue needs a team member to investigate its status.
Milestone
π Search Terms
reachability never
π Version & Regression Information
It's observed in all TS versions.
β― Playground Link
https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mAVAAjAUwG5oE4AoCUAXMgOJrrYCGUc2APOANZhwDuYANOltgHzIBvAFDJkUABbY2yAOTccMgNxCAvkKGhIsBCgC2lGGAKCRY7AE8To0eZhoANgBMU8vPmWiVyYIcr37lsLWyBAIAM5w9mgAdPZwAOa4Mj5gfgEy7qZqoqFgEVGxCUksUMjYaJQQ4pQARlEZympAA
π» Code
π Actual behavior
No error reported.
π Expected behavior
There should be an error
Unreachable code detected.(7027)
at line 11console.log('not reachable');
.Additional information about the issue
Reachability analysis is working for normal function: https://www.typescriptlang.org/play/?#code/GYVwdgxgLglg9mABGApgNxQJwBQEoBcy6WiA3gFCKJQAWmcA7ogOSoabMDc5AvueaEiwEiALYBDGGDxlK1TAE9ZVKmyx5uVHomBTxAG31KKKxBAQBnOPpQA6fXADm2ZrrAGjzXJsR8q5sCsbeycXMDgoREwUcQgacQAjGy9uPiA
It's broken for Promise and we have another issue tracking that one: #34955
Generator functions are being used as coroutine in libraries like co.js, Effect.js, redux-saga, Effection, and more. It's common to write a coroutine operator that suspend the thread forever, thus taking
function never(): Generator<Instruction, never>
signature. It would benefit users if the TypeScript control analysis can infer unreachability afteryield* never()
.The text was updated successfully, but these errors were encountered: