Matt Pocock(@mattpocockuk) 's Twitter Profileg
Matt Pocock

@mattpocockuk

Full-time TypeScript educator. Ex-@vercel, @statelyai. Used to be a voice coach. He/him. Author of Total TypeScript 🧙 Hire me to teach your team TypeScript!

ID:346640777

linkhttps://totaltypescript.com calendar_today01-08-2011 16:08:26

18,1K Tweets

127,9K Followers

570 Following

Follow People
Matt Pocock(@mattpocockuk) 's Twitter Profile Photo

Imagine if there was a type like __filename, which gave you the file you were currently in as a string.

Sounds like a small thing, but it would be INCREDIBLE for type-safe filesystem routers.

account_circle
Matt Pocock(@mattpocockuk) 's Twitter Profile Photo

I'm away from my laptop, so can someone explain to Kory why Object.keys and for (const key in obj) isn't typed narrowly?

account_circle
Matt Pocock(@mattpocockuk) 's Twitter Profile Photo

Whenever I post an advanced TypeScript tip, nearly every answer is some combination of 'but why?'.

I know my answer, but I want to hear yours. Why should someone learn advanced TypeScript?

account_circle
Zubin Khavarian(@zkMake) 's Twitter Profile Photo

Dealing with verbose errors? 🤔 Imagine them as a 'legal case' built against your code. Start with specifics, but the real issue is often revealed at the end, like the climax of a trial. To make errors more readable, try using inline objects or precise type…

account_circle
Matt Pocock(@mattpocockuk) 's Twitter Profile Photo

An under-explored genre of post by me is comparing TS DX across different frontend frameworks.

I.e. how accessing HTML elements work in Svelte, React, Solid, Vue etc.

Got any examples that would make for good comparisons?

account_circle
Matt Pocock(@mattpocockuk) 's Twitter Profile Photo

> doesn't add feature
> 'garbage, half-baked. basic features not present'
> adds feature
> 'bloated, messy. too many ways to do the same thing'

account_circle
Matt Pocock(@mattpocockuk) 's Twitter Profile Photo

If your new year's resolution was to learn TypeScript, I've got a surprise for you.

I've shipped a whole new free tutorial - Solving TypeScript Errors 🤯

That takes the total number of free TT exercises up to 59. Time to get started.

totaltypescript.com/tutorials/solv…

account_circle
Matt Pocock(@mattpocockuk) 's Twitter Profile Photo

TypeScript isn't always great at checking your code when you have syntactical errors.

'Expression expected'. What the hell do you mean?

This tool is much better at these sorts of error messages.

account_circle
Mateusz Burzyński(@AndaristRake) 's Twitter Profile Photo

Reverse mapped types are just so super elegant for certain use cases...

Here we have an equivalent of `Promise.allSettled` that retains positional information for each item in the input

typescriptlang.org/play?ts=5.3.2#…

Reverse mapped types are just so super elegant for certain use cases... Here we have an equivalent of `Promise.allSettled` that retains positional information for each item in the input typescriptlang.org/play?ts=5.3.2#…
account_circle
David K 🎹(@DavidKPiano) 's Twitter Profile Photo

TypeScript tip: use undefined explicitly instead of making a property optional, when applicable.

⚠️ email?: string
✅ email: string | undefined

Why? It's too easy to forget to specify a property, especially in large codebases or refactors. You can make it optional later.

TypeScript tip: use undefined explicitly instead of making a property optional, when applicable. ⚠️ email?: string ✅ email: string | undefined Why? It's too easy to forget to specify a property, especially in large codebases or refactors. You can make it optional later.
account_circle
Matt Pocock(@mattpocockuk) 's Twitter Profile Photo

Plans for 2024:

- Publish my TypeScript book
- Become a new daddy
- Learn to juggle four balls at once
- Bake a sourdough successfully
- Fill my board game bookcase

Happy new year to all!

account_circle
Matt Pocock(@mattpocockuk) 's Twitter Profile Photo

Ever been pissed off at TypeScript not preserving type narrowing into new closures? (like into .map or .filter functions)

Well, this PR fixes a good chunk of those cases. LOVE IT.

account_circle