正在加载视频...

视频加载失败

TIL that TypeScript can detect 'break' clauses in while (true) loops. Pretty freaking cool.

54,548 次观看 • 1 年前 •via X (Twitter)

10 条评论

Erik 的头像
Erik1 年前

Wow they solved the halting problem

Sahaj Jain 的头像
Sahaj Jain1 年前

TIL that TypeScript also supports break with labelNames

ᴛᴏʟʟʏ ( ͡° ͜ʖ ͡°) 的头像
ᴛᴏʟʟʏ ( ͡° ͜ʖ ͡°)1 年前

what if you change 0.5 to 1?

0xAlice (e/tard) 的头像
0xAlice (e/tard)1 年前

😭😭😭

Matt Pocock 的头像
Matt Pocock1 年前

?

Tiger Abrodi 的头像
Tiger Abrodi1 年前

I kind of expected this though What would be interesting is if it can narrow down e.g. based on a value, so in a while loop, if we I don't know, hit the value 5, then we return Otherwise we continue If it knows that That'd be even more badass

Samual Norman 🦋 @samual.uk 的头像
Samual Norman 🦋 @samual.uk1 年前

TypeScript's control flow analysis is the best I've seen in any language

Prasenjit 的头像
Prasenjit1 年前

That's a pretty cool trick for sure, thanks for sharing about it. it's going to help a lot.

Jaid 的头像
Jaid1 年前

How much effort does it put into determining whether the break statement itself is reachable?

0xAlice (e/tard) 的头像
0xAlice (e/tard)1 年前

this is like, the whole idea behind the never type. man oh man ...

相关视频