danvk / effective-typescript

Effective TypeScript 2nd Edition: 83 Specific Ways to Improve Your TypeScript
https://effectivetypescript.com
Other
1.53k stars 226 forks source link

Item 41: Understand Evolving any #8

Open danvk opened 2 years ago

danvk commented 2 years ago

Item 41: Understand Evolving any

https://effectivetypescript.com/2020/03/09/evolving-any/

danvk commented 2 years ago

_Comment by disqus_0l6QhEp9JS on 2020-11-28 03:11:_

"A final case that triggers this "evolving any" behavior is if a variable is initially null. This often comes up when you set a value in a try/catch block:" This seems out of place - it's in the middle of a different case - and it's obviously missing at least an example piece of code, if not more...

"This behavior can be confusing to follow in your editor since the type is only "evolved" after you assign or push an element. Inspecting the type on the line with the assignment will still show any or any[]." Shouldn't this paragraph be somewhere else as well?

Asking because I'm interested in the missing example :)

danvk commented 2 years ago

Comment by danvdk on 2020-11-28 10:02:

Gah, should be fixed now, thanks for the heads up. (This broke along with a few other things as a result of incorporating literate-ts into the blog.)

danvk commented 2 years ago

_Comment by disqus_0l6QhEp9JS on 2020-11-29 07:02:_

No problem! Looking forward to reading the book now :)