filmov
tv
Inferred Type Predicates - TypeScript 5.5's top new feature

Показать описание
This has has been a top wishlist features for so many people for so many years. Dan tells the story of how he cracked it, then we do a deep dive on the code itself. Although this was a pretty technical conversation there ended up also being quite a lot of great conversation on staying motivated and thinking through all the aspects of the problem from side-effects to performance implications.
Links:
Dan Vanderkam is an independent software developer, formerly at Google and Sidewalk Labs. He is the author of numerous open source JavaScript/TypeScript libraries, including the dygraphs charting library, source-map-explorer, literate-ts, pg-to-ts and crosswalk. He is the author of "Effective TypeScript: 83 Specific Ways to Improve Your TypeScript" (O'Reilly 2024) and has spoken at numerous TS conferences. When he's not writing about TypeScript, Dan enjoys hiking, rock climbing and birding.
00:00:00 in this episode
00:02:06 the Recurse Center (deciding to tackle this issue)
00:03:53 first issue: numeric literal separators in ES2021
00:07:36 rediscovering this old issue
00:08:28 explaining the fundamentals of the feature
00:13:43 the idea for the first approach to solving the issue
00:16:24 wrong assumptions about how the compiler handles inference
00:17:59 what is a "Flow Node" in the compiler
00:21:46 about the TypeScript AST Viewer
00:22:18 second attempt: using Flow Nodes
00:23:26 digging into the code for the actual implementation
00:28:03 what most people don't understand about how type predicates actually work
00:30:21 are MiTS viewers interested in blog post readings (WITH the author)?
00:31:33 looking deeper than a type predicate goes
00:33:23 working with TypeScript's exhaustive test suite
00:36:03 dealing with outlier falsey types (like empty string, NaN, etc.)
00:38:27 what about `[].filter(Boolean)` (array filter with the Boolean constructor)
00:39:14 type guards now flow between functions
00:40:35 sage-tier advice from Anders Hejlsberg
00:41:20 building the courage to submit the PR
00:43:59 a scary moment where it looked like the solution might not actually work
00:46:37 a solution to the setback after going for a walk
00:50:29 a totally unique approach within the TypeScript compiler codebase
00:53:12 the process for getting it reviewed and approved and merged
00:54:36 performance optimization work
00:56:42 playing around with the end result
00:57:24 playing with truthiness checks
00:59:15 revisiting: why you shouldn't use .filter(Boolean)
01:01:57 about teaching these concepts
01:02:52 how ts-reset handles filter(Boolean)
01:05:51 wrapping up
01:07:49 after it all: it turns out this could have been done years ago
Links:
Dan Vanderkam is an independent software developer, formerly at Google and Sidewalk Labs. He is the author of numerous open source JavaScript/TypeScript libraries, including the dygraphs charting library, source-map-explorer, literate-ts, pg-to-ts and crosswalk. He is the author of "Effective TypeScript: 83 Specific Ways to Improve Your TypeScript" (O'Reilly 2024) and has spoken at numerous TS conferences. When he's not writing about TypeScript, Dan enjoys hiking, rock climbing and birding.
00:00:00 in this episode
00:02:06 the Recurse Center (deciding to tackle this issue)
00:03:53 first issue: numeric literal separators in ES2021
00:07:36 rediscovering this old issue
00:08:28 explaining the fundamentals of the feature
00:13:43 the idea for the first approach to solving the issue
00:16:24 wrong assumptions about how the compiler handles inference
00:17:59 what is a "Flow Node" in the compiler
00:21:46 about the TypeScript AST Viewer
00:22:18 second attempt: using Flow Nodes
00:23:26 digging into the code for the actual implementation
00:28:03 what most people don't understand about how type predicates actually work
00:30:21 are MiTS viewers interested in blog post readings (WITH the author)?
00:31:33 looking deeper than a type predicate goes
00:33:23 working with TypeScript's exhaustive test suite
00:36:03 dealing with outlier falsey types (like empty string, NaN, etc.)
00:38:27 what about `[].filter(Boolean)` (array filter with the Boolean constructor)
00:39:14 type guards now flow between functions
00:40:35 sage-tier advice from Anders Hejlsberg
00:41:20 building the courage to submit the PR
00:43:59 a scary moment where it looked like the solution might not actually work
00:46:37 a solution to the setback after going for a walk
00:50:29 a totally unique approach within the TypeScript compiler codebase
00:53:12 the process for getting it reviewed and approved and merged
00:54:36 performance optimization work
00:56:42 playing around with the end result
00:57:24 playing with truthiness checks
00:59:15 revisiting: why you shouldn't use .filter(Boolean)
01:01:57 about teaching these concepts
01:02:52 how ts-reset handles filter(Boolean)
01:05:51 wrapping up
01:07:49 after it all: it turns out this could have been done years ago
Комментарии