I teach devs for a living. Author of Total TypeScript and AI Hero. Ex-@vercel. Used to be a voice coach.
6 subscribers
Apr 9 • 5 tweets • 2 min read
I've just been reading the Agent2Agent technical docs - Google's new protocol for agent to agent communication.
You know what that means. Let's diagram them:
Agents can be discovered by a public 'card' they expose via http.
Apr 9 • 8 tweets • 2 min read
Some notes on Cursor vs VSCode's new agent mode:
I'm currently working on a course where each lesson is a prompt, and you build a complex application from ~50 prompts.
This gives me a pretty gnarly eval for testing agent mode.
I've been using Cursor to build the course, but I tried VSCode instead.
How did it do?
Mar 25 • 7 tweets • 1 min read
Ohhhhhh I think I've found an AI writing flow I'm happy with
Need to iterate on it before I write about it more, but it's really working.
Essentials are:
1. Create a big multi-step plan for the article, including checkboxes. On the current article I'm working on, it's 16+ steps. 2. For each step, ask it for 3 different plans for how to write the section. Give the section a target word count.
Mar 7 • 7 tweets • 2 min read
MCP has ALREADY become an overloaded term.
Let's break it down into clients, servers and protocols:
MCP is built out of three ideas.
You have a client, a server, and a protocol to connect them together. Let's define each of them in turn.
Mar 6 • 6 tweets • 2 min read
Lots of folks feeling FOMO about MCP.
Here's the problem it solves:
If you want to get your LLM to do useful things in the world, you will quickly hit a problem.
All the useful things in the world, like Slack, GitHub, or even your local filesystem, provide their own unique API to access them.
Oct 1, 2024 • 7 tweets • 2 min read
z.strict() fixed a nasty bug for me this morning.
You should probably be using it on most of the schemas that handle outside data.
Here's the bug 🧵
I had a form where I was marking the date a post was posted. I was expecting a key of `postedAt`, with an optional datetime.
Aug 20, 2024 • 13 tweets • 3 min read
Narrowing down the types of values is key knowledge for any TypeScript dev.
Here's 11 different ways you can do it. I bet you won't know 2 or 3 of them!
🧵
Narrowing with typeof:
Aug 8, 2024 • 10 tweets • 3 min read
So many folks don't know about structuredClone.
It's awesome, built-in, and supported in all major browsers.
Let's learn 🧵
A common pattern in JavaScript is to create an immutable clone of an object. This is useful when you want to make mutations to it without changing the original.
For that, you'll often see code using the spread operator: `{ ...obj }`.
Aug 7, 2024 • 4 tweets • 1 min read
I'm starting to think that library types in TypeScript are all wrong.
Instead of top-level types, they should be available right on the functions that use them.
Brief thread 🧵
How is this possible? Well, it's due to a trick in the way namespaces work in TypeScript.
When you export a namespace with the same name as a function, TypeScript combines the two:
Aug 5, 2024 • 11 tweets • 4 min read
I've changed my mind on .d.ts files.
If you're writing application code, you should NEVER use them.
Let me explain 🧵
Declaration files are files that only contain types.
They've got two purposes - providing types for JavaScript files, and augmenting types in the global scope.
After all the chat about typing event handlers in React, I figured I'd write down all the suggestions folks gave.
Quick 🧵
The most popular solution is to hover the onChange attribute in the JSX, then use that to type your handler.
But this creates an astonishingly long type - very intimidating for newbies.
Sep 4, 2023 • 4 tweets • 2 min read
How should you type React Props?
You've got three options. type, interface or an inline object literal.
Inline object literals might be fast to write, but it means you can't extract the type out for use elsewhere in your codebase:
This makes them hard to recommend.
So, interface vs type again. As I've said before, I prefer type.
But let's say you're building an input that needs to take all the props of 'input', but with an extra label.
For those cases, you must use interfaces:
Using an intersection here will slow down TypeScript on the scale of a large codebase. interface extends is the way to go.
This means that it's a good idea to get into the habit of using interfaces for each prop declaration.
I recommend using a code snippet to declare the interface for you:
All the speed of an object literal, but all the reusability and TS performance of an interface.
Want to share outside of X? Head to Total TypeScript:
Anyone know if it's possible to detect a QR code (or even just a fiducial) from a video using ffmpeg?
I'm asking for a slightly hilarious reason.
I use ffmpeg for automatically editing my videos. When I screw up a take, I want to be able to hold up a QR code on a paddle to tell my editing software to discard that take.
Mar 6, 2023 • 20 tweets • 7 min read
Why any's happen, how to stop them, and why unknown isn't necessarily a better solution 🧵
Any 'any' in a codebase is a cause for concern. That's because it disables typechecking on the thing it's assigned to.
Pass it to a function parameter? You then can't guarantee anything about that function parameter.
Mar 3, 2023 • 5 tweets • 2 min read
Working with mocks in TS sucks.
The only way you can make it work is by slapping 'as' on everything - which can make the tests hard to maintain.
What if you had a simple set of functions that could let you pass whatever you wanted, but with perfect autocomplete?
This feels pretty simple on the surface - many of you might have tried to make these kinds of abstractions before.
But it's harder than you think - you need a bit of wizardry. Let's take partial().
Why isn't the code below working?
Mar 2, 2023 • 18 tweets • 6 min read
satisfies in TypeScript has been out for a little while now.
Overall, it's been a success - but it's starting to cause some confusion.
Let's clear it up.
satisfies has added yet another tool to the TypeScript user's toolkit.
There are now _three_ ways to assign types to values.
Total TypeScript is ready.
🧙 Hundreds of videos over three modules
🔥 The deepest exploration of Generics on the market
❤️ Interactive editors, transcripts, and thousands of words of accompanying articles
🪄 Perfect if you've used TS for a while, but want to achieve mastery