Dan Vanderkam Profile
Dan Vanderkam

@danvdk

3,132
Followers
128
Following
88
Media
1,259
Statuses

Independent software developer, formerly @sidewalklabs and Google. Author of Effective TypeScript. Pre-order 2nd edition (May 2024):

Hudson Valley, NY
Joined February 2009
Don't wanna be here? Send us removal request.
Pinned Tweet
@danvdk
Dan Vanderkam
4 years
I wrote a book! Happy to announce that _Effective TypeScript: 62 Specific Ways to Improve Your TypeScript_ is now available for purchase. I learned a lot writing it and I hope you'll have the same experience reading it.
Tweet media one
9
12
107
@danvdk
Dan Vanderkam
4 years
Another use of @TypeScript 4.1's template literal types: extracting the URL parameters from an express route. Pretty amazing you can do this in the type system!
Tweet media one
24
172
652
@danvdk
Dan Vanderkam
2 months
Put up my second #TypeScript PR! It allows the type checker to infer "type predicates" when a function returns a boolean that's tied to a refinement on one of its parameters. I have no idea if it'll be accepted, but I sure learned a lot implementing it!
Tweet media one
8
22
244
@danvdk
Dan Vanderkam
2 years
New Effective #TypeScript blog post: a command to visualize what TypeScript is compiling using a treemap (the results may surprise you!). Or: how I found out I was compiling 80+ MB of types for Google APIs that I wasn't using.
Tweet media one
1
28
172
@danvdk
Dan Vanderkam
9 years
I’m excited to launch http://t.co/NFkT7kZRU1! Browse 40,000 mapped historic photos of #NYC from the @NYPL http://t.co/eH0R9AsbWb
Tweet media one
17
145
164
@danvdk
Dan Vanderkam
1 month
After using TypeScript for 8+ years, I had a mind-blowing realization: type inference is implemented completely backwards from how I think about it! Read on for the "missing manual" on Flow Nodes and TS type inference internals.
1
8
86
@danvdk
Dan Vanderkam
2 months
For my PR to infer type predicates, I needed to understand TypeScript's control flow graph. So I added a graph visualization to @DavidSherret 's amazing TypeScript AST Viewer. It's live now and very fun to play with! Edges go backwards in execution order.
Tweet media one
2
7
77
@danvdk
Dan Vanderkam
12 days
One of my goals this year was to become a TypeScript contributor. Over the past three months, I did just that! This post tells the story of how Type Predicate Inference came about and what I learned along the way.
3
8
60
@danvdk
Dan Vanderkam
2 years
Which of these would you rather show your users when they call a function in @TypeScript ? As a library writer, you do have some control! Read more about the strange world of type display in the latest Effective TypeScript blog post:
Tweet media one
1
4
40
@danvdk
Dan Vanderkam
6 months
A quibble with @mattpocockuk 's excellent writeup : I'd call the "implicit index signature" for type a bug and a good reason to use interface instead because it can lead to unsoundness:
1
7
38
@danvdk
Dan Vanderkam
2 years
Excited to get my copy of @LearningTSBook ! Congrats @JoshuaKGoldberg ! The cover looks great. Can you tell us more about your choice of the sun parakeet??
Tweet media one
2
2
32
@danvdk
Dan Vanderkam
4 years
Use @TypeScript ? Check out dtsearch, a tool search npm for just the packages that have types, whether bundled or on DefinitelyTyped. Thanks to @orta and @haroenv for all their help making this work!
1
7
31
@danvdk
Dan Vanderkam
3 years
I put together a small library for type-safe express routes using @typescript 4.1's new template literal types called crosswalk ("safe route", get it?). If you use Express and TypeScript, give it a try!
Tweet media one
2
10
27
@danvdk
Dan Vanderkam
1 month
Nice writeup of TypeScript's new ability to infer type predicates from @mattpocockuk . I'm 0% surprised that Matt beat me to writing a blog post about this :)
@mattpocockuk
Matt Pocock
1 month
I really can't believe they added it.
8
20
288
1
2
25
@danvdk
Dan Vanderkam
1 month
@mattpocockuk You and me both, @mattpocockuk ! I learned a ton writing this PR and it’s been amazing to see the reaction to it getting merged. I guess I wasn’t the only one who’s been wanting this!
1
0
21
@danvdk
Dan Vanderkam
2 years
Most of my @typescript bug reports are misunderstandings on my part, but this alternative never gets old!
Tweet media one
1
1
21
@danvdk
Dan Vanderkam
6 years
I just published “Testing Types: An Introduction to dtslint”
0
9
19
@danvdk
Dan Vanderkam
23 days
Excited to see that the new Flow Node Charts have at least one high-profile user. And may have even indirectly led to some TypeScript speedups! Visualizing something has a way of nudging you to make it better. @DavidSherret
@danvdk
Dan Vanderkam
2 months
For my PR to infer type predicates, I needed to understand TypeScript's control flow graph. So I added a graph visualization to @DavidSherret 's amazing TypeScript AST Viewer. It's live now and very fun to play with! Edges go backwards in execution order.
Tweet media one
2
7
77
1
0
17
@danvdk
Dan Vanderkam
4 years
The @typescript language is both coded and _designed_ in the open. You can keep up on their latest thinking through @drosenwasser 's weekly "Design Notes" issues. Here's an RSS feed for them!
1
5
15
@danvdk
Dan Vanderkam
6 months
Four years ago, I cut one item from Effective @TypeScript during the final stages of editing. Now it finally sees the light of day as a blog post! I'm curious how widely-known this is and if it's useful beyond typing _.chain.
0
3
14
@danvdk
Dan Vanderkam
3 years
Very excited to be speaking at #TSConf tomorrow! I'll be talking about what types are, with an assist from renaissance master Michelangelo Buonarroti. Should be fun!
3
0
14
@danvdk
Dan Vanderkam
2 years
Does anyone use @typescript twoslash as a test system? Basically I want to write the result of adding "// ^?" in code and have twoslash assert that what I wrote matches what it would show. I like that this would test how the types _display_ ala literate-ts @orta
Tweet media one
1
0
14
@danvdk
Dan Vanderkam
9 years
Today on danvk blog: extracting text from an image using the @ocropus library http://t.co/CulGEMRx4b (with pictures!) http://t.co/4m1LJQZtBA
Tweet media one
0
12
13
@danvdk
Dan Vanderkam
3 years
ts-mover is a small tool built using @dsherret 's ts-morph. You write a list of @typescript file moves and renames and it makes them happen. I've been doing some large-scale reorganizing recently and this has really helped!
0
3
13
@danvdk
Dan Vanderkam
2 months
@housecor I've thought about turning this into a typescript-eslint rule. Exceptions would be functions where the args have a canonical order (Math.pow) or the order doesn't matter (add, multiply).
1
0
13
@danvdk
Dan Vanderkam
3 years
@tannerlinsley @TkDodo @lukemorales @typescript The comment from @TkDodo is exactly right, TypeScript does refinement on the types of individual symbols. Once you split them apart, it can't keep track of the relationship any more. Doing this in general would be computationally hard. It can also be hard for people.
0
1
13
@danvdk
Dan Vanderkam
9 years
Last blog post in my OCR series: Training an Ocropus OCR model. Witness the triumph! http://t.co/suu7JJnPzB http://t.co/L6LjihooCT
Tweet media one
0
11
13
@danvdk
Dan Vanderkam
10 months
👀 Searched on the @TypeScript type-challenges repo to see if anyone had filed a solution using the built-in Extract helper and… wait a minute, what? Memory works in funny ways!
Tweet media one
1
0
13
@danvdk
Dan Vanderkam
7 years
I'm impressed that this works! In #TypeScript 2.1, you can pull a union of string literals tag type out of a tagged union type. #MappedTypes
Tweet media one
0
5
13
@danvdk
Dan Vanderkam
9 months
Hey @TitianCernicova @robpalmer2 was Bloomberg's "Dead Type Elimination" tool referenced in this post ever open sourced? Do you still use it? Is it too tied to Bloomberg's setup to be widely useful? I'm very curious about this topic!
1
1
13
@danvdk
Dan Vanderkam
4 years
I put together a small site for Effective TypeScript: . Subscribe via RSS or follow on Twitter to get sample items and TypeScript tips & tricks!
1
4
12
@danvdk
Dan Vanderkam
2 years
@typescript This error message in the TS 4.7 beta is on point. Nice!!
Tweet media one
0
0
11
@danvdk
Dan Vanderkam
4 years
literate-ts is a tool I built while writing Effective TypeScript to bring static analysis to books and blog posts. It proved invaluable but not in the ways I expected! Thanks to @haxor and @DonKnuth for the inspiration
1
3
11
@danvdk
Dan Vanderkam
2 months
Type guards are really having a moment! @Flowtype launched user-defined type guards today: Very similar to TypeScript's. They also have "if and only if" semantics. Unlike TypeScript's, they are checked. But evidently only in the "true" case:
Tweet media one
2
0
12
@danvdk
Dan Vanderkam
3 years
"strings that are actually numbers" wasn't a thing I ever expected @TypeScript 's type system to accurately model. Kudos on the TS 4.4 beta! Now there's some things in my book that I need to rewrite… :)
Tweet media one
@typescript
TypeScript
3 years
TypeScript 4.4 Beta is ready to try! We want your feedback on our new analyses, strictness flags, symbol/pattern indexers, --help menu revamp, perf improvements, and more, so read up on what's new and give it a shot!
6
165
553
3
1
11
@danvdk
Dan Vanderkam
9 years
What an amazing response to http://t.co/NFkT7kZRU1. Millions of image views and improved text transcriptions on nearly 6,000 photos! @nypl
3
7
10
@danvdk
Dan Vanderkam
8 years
Read about this 1931 Chrysler building photo, taken from the ground AND a blimp! @nypl_labs
Tweet media one
0
13
9
@danvdk
Dan Vanderkam
2 years
@JoshuaKGoldberg If this works, it's going to set a very dangerous precedent!
1
0
10
@danvdk
Dan Vanderkam
3 years
The @typescript 4.1 RC breaks exactly one example in Effective TypeScript, in Item 23: Create Objects All at Once. The inferred type that "comes as a surprise" now does exactly what you'd intuitively expect!
Tweet media one
2
1
10
@danvdk
Dan Vanderkam
4 years
Is this the simplest way to implement numeric addition in @typescript 's type system? Pretty nice how it works with unions of numbers. @JoshuaKGoldberg
Tweet media one
2
4
10
@danvdk
Dan Vanderkam
2 years
My #TSConf 2021 presentation is now on YouTube!
@TypeScriptConf
TSConf
2 years
Delve into @danvdk 's #TSConf presentation - #TypeScript Types: The First 500 Years. Learn type theory with some help from Michelangelo:
Tweet media one
0
1
13
2
0
10
@danvdk
Dan Vanderkam
4 years
Excited to publicly announce the project I've been working on at Sidewalk Labs! In case any of the @typescript crowd were curious why there were so many Mapbox and GeoJSON examples in _Effective TypeScript_ :)
@sidewalklabs
Sidewalk Labs
4 years
In an ideal world, developers, architects, and urban planners could explore endless options to design sustainable and affordable neighborhoods. But the traditional urban development process only produces a few options, leaving potentially better designs untapped.
3
13
74
0
0
10
@danvdk
Dan Vanderkam
2 months
@sebastienlorber @mattpocockuk filter(Boolean) scares me because you almost always want to be checking for null/undefined, not 0. They're only equivalent for object types. You can actually tell TS to only allow it in that situation by specializing on "this":
Tweet media one
1
0
7
@danvdk
Dan Vanderkam
3 years
@ddprrt nice post on React children types! small nit: {} means anything but null/undefined, not any object. (It includes number and string.) Then ReactNode adds null | undefined, so it really is anything!
2
1
9
@danvdk
Dan Vanderkam
10 years
The about the odyssey that led to jss, my new JSON manipulation command line tool:
0
5
9
@danvdk
Dan Vanderkam
2 years
Glad you noticed! :)
@johnny_reilly
John Reilly ❤️🌻 fosstodon.org/@johnny_reilly
2 years
Awesome talk by @danvdk at #TSCongress - nicely placed copy of "Effective TypeScript" in the background 😅♥️
Tweet media one
0
0
16
0
0
9
@danvdk
Dan Vanderkam
8 years
A few of my takeaways from #NIPS2015
0
0
9
@danvdk
Dan Vanderkam
2 years
Very excited to see type annotations coming to JS! “No build step” was always the Closure Compiler’s central dogma. Now we have a path to the same with @typescript . Nice work @drosenwasser and @robpalmer2 ! 🙌
1
2
9
@danvdk
Dan Vanderkam
8 months
TypeScript and SQL: Six Ways to Bridge the Divide. The video of my talk at TS Congress is up, along with a companion blog post. I have my favorite way to combine TypeScript and SQL. How do you like to do it?
Tweet media one
1
1
9
@danvdk
Dan Vanderkam
9 years
Nice writeup of http://t.co/NFkT7kZRU1 on The Guardian! http://t.co/GBStFmSRRC
0
9
7
@danvdk
Dan Vanderkam
4 years
TIL @TypeScript 's mapped types work just as well on array and tuple types as they do on more typical object types:
Tweet media one
1
1
8
@danvdk
Dan Vanderkam
3 years
Very excited to be speaking again at #tsconf !
@TypeScriptConf
TSConf
3 years
You may remember them from #TSConf 2019...it's Dan Vanderkam! Author of Effective TypeScript & Principal Software Engineer at @sidewalklabs , we can't wait to hear about the first 500 years of TypeScript Types at #TSConf 2021! Welcome back @danvdk !
Tweet media one
1
6
21
0
1
8
@danvdk
Dan Vanderkam
9 years
Here's a roundup of the video, slides and tools from yesterday's #PyCon2015 talk on Screenshot Tests & Visual Diffs: http://t.co/HWOzTHeyej
0
1
8
@danvdk
Dan Vanderkam
7 months
Great talk @TitianCernicova ! So satisfying to see those dependencies go away and your parallelism soar.
@TechAtBloomberg
Tech At Bloomberg
7 months
In his "Speeding up #TypeScript builds" presentation during @ts_congress today (11:55 AM EDT), @TitianCernicova will explore isolated declarations, a new feature of @typescript we've been working on in collaboration with @Google & @Microsoft
0
3
6
0
2
8
@danvdk
Dan Vanderkam
2 months
Now available on a TS Playground so you can try it yourself!
0
0
8
@danvdk
Dan Vanderkam
1 year
@AdamRackis @ThePrimeagen @t3dotgg Glad to hear you're a fan of the Effective series! This item is available free online. Here's they key quote: "Ideal TypeScript code includes type annotations for function/method signatures but not for the local variables created in their bodies."
1
1
8
@danvdk
Dan Vanderkam
2 years
Excited to be talking Types Syntax with @orta at #TSCongress
1
3
6
@danvdk
Dan Vanderkam
9 months
Funny enough, I got really into birding _after_ putting a bird on my book. The Oxpecker is a visual play on the cover of JavaScript: The Definitive Guide. Read the Colophon and see if you can figure it out!
@mattpocockuk
Matt Pocock
9 months
Learning TypeScript by @JoshuaKGoldberg Effective TypeScript by @danvdk
0
0
25
1
0
7
@danvdk
Dan Vanderkam
3 years
TypeScript splits the atom! This post looks at @typescript 4.1's template literal types, why they're a particularly "TypeScripty" construct, and what I think tasteful use of them will eventually look like.
0
1
7
@danvdk
Dan Vanderkam
1 month
@mattpocockuk I’m especially happy that TS team went with the simplest, most maximal version of this change. It’s not just for arrow functions. It’s not just for contextually-typed functions. It works for all functions. No special cases. The clearest version, but also the scariest!
2
0
7
@danvdk
Dan Vanderkam
12 years
Really like http://t.co/amWpsgJH, the Manhattan grid extended to cover the entire world!
1
10
7
@danvdk
Dan Vanderkam
2 years
Tune in tomorrow for my Twitch debut! I’m a little nervous, but mostly just excited to talk @typescript and open source with @JoshuaKGoldberg
@JoshuaKGoldberg
Josh Goldberg 💖
2 years
📣 My Twitch open source coding stream resumes tomorrow! @danvdk and I will go over Dan's PR adding "twoslash" support to eslint-plugin-expect-type! 🙌 * What is twoslash? * What is eslint-plugin-expect-type? Find out tomorrow!
5
1
11
0
1
6
@danvdk
Dan Vanderkam
11 years
Just launched, NCAA March Madness brackets on Google: http://t.co/iHFC0ivnx4. Super-proud of my team for putting this together!
4
10
6
@danvdk
Dan Vanderkam
11 months
Don’t Repeat Type Information in Documentation! This item from Effective @TypeScript has always been one of my favorites because it's so easy to apply its advice in code reviews. Now available as a free sample item:
1
0
6
@danvdk
Dan Vanderkam
3 years
@TAbrodi @tannerlinsley If what you really want is named (not positional) generics, you can improvise something using conditional types:
0
0
6
@danvdk
Dan Vanderkam
1 month
@mattpocockuk The TypeScript playground is the best way to hammer this home. TypeScript on the left, JavaScript on the right.
2
0
6
@danvdk
Dan Vanderkam
7 years
Really enjoyed the @uglywalks through the Gowanus on Saturday! Maximum ugliness!
Tweet media one
0
1
4
@danvdk
Dan Vanderkam
8 months
Sometimes @typescript still surprises me! readonly modifiers don't seem to affect assignability. This seems like a bug, but these usually wind up being concessions to convenience. Does anyone know more about why this is allowed?
Tweet media one
2
1
5
@danvdk
Dan Vanderkam
4 years
@yawaramin @typescript In practice TypeScript would infer the string literal for you. No repetition necessary. Here's a playground showing that in action:
1
0
5
@danvdk
Dan Vanderkam
2 years
@mpocock1 Or put another way… if dropping type annotations saves you time, imagine how much more time you can save by dropping all your tests! :)
0
0
5
@danvdk
Dan Vanderkam
8 years
I'm excited to see my first peer-reviewed scientific publication make it online! @hammer_lab
0
2
4