Convex
Posts by Cory House
How I handled React state over 10 years:
2014: Class state
2016: Redux
2018: useState, useReducer, useContext
2020: React query
2021: Zustand for globals
2024: useOptimistic, useTransition, useFormStatus, useActionState, RSC
2025: Tanstack DB or sync engine (Zero, Electric, Convex)
TypeScript syntax is often inspired by JavaScript.
In some cases, TS even uses the exact same syntax as JS for a different purpose.
The difference?
JS features focus on values.
TS features focus on types.
Here's a few examples.
Are TypeScript types worth testing?
Sometimes.
Here's when, and how.
www.youtube.com/shorts/Uv7r-...
Problem: I want to enforce a string format at compile time.
Solution: Use a template literal type.
Full "TypeScript: Deep Dive" course: dometrain.com/course/deep-...
Problem: I want to ensure my switch statement handles all potential cases.
Solution: Use TypeScript's never type.
Here's how:
Full course: dometrain.com/course/deep-...
Problem: You have complex logic for narrowing a TypeScript type that you'd like to reuse in a few spots.
Solution: Consider an assertion function.
20% off the full course: dometrain.com/course/deep-...
It’s live!
“TypeScript: Deep Dive” explores advanced TS concepts:
- Utility types
- Generics
- Mapped types
- Conditional types
- Template literal types
- Runtime validation
- Decorators
- tsconfig techniques
And over 250+ examples!
Get 20% off at launch here: dometrain.com/course/deep-...
LLMs are handy when working with the command line.
I wanted a count of all the exercise files in my new course.
ChatGPT provided the correct Bash command immediately.
It’s done!
I’ve been heads down for 3 months creating my most ambitious course yet:
“TypeScript: Deep Dive”
Just recorded the final clip. This course is 7 hours of advanced features, tips, patterns, and tricks to level up your TS skills.
Publishing this week on Dometrain!
Tesla paid back the loan, and did so early. Implying they survived merely because of a loan is reductive.
SpaceX survives because, like Tesla, they're profitable. They're able to do things cheaper than alternatives, because they innovated and created reusable rockets.
Many current and former Tesla employees received stock options and are now quite wealthy.
Tesla is an obvious American success story. Without Tesla, EVs would likely still be rare.
What system do you propose to avoid successful entrepreneurs getting too wealthy for your taste?
With 2, we may never bother becoming stricter. And any new code is held to a low standard, which creates "type debt".
With 1, new code is held to a strict standard, and existing code can selectively have looser typing rules via nested tsconfigs, or by disabling TS in spots if necessary.
When migrating a codebase from JS to TS, there are two schools of thought:
1. Start strict, and loosen in spots as needed.
2. Start loose, and migrate to stricter rules over time.
I prefer 1. It's safer.
Default strict. Loosen when necessary.
import { assertType, expectTypeOf } from 'vitest' import { mount } from './mount.js' test('my types work properly', () => { expectTypeOf(mount).toBeFunction() expectTypeOf(mount).parameter(0).toMatchTypeOf<{ name: string }>() // @ts-expect-error name is a string assertType(mount({ name: 42 })) })
Just realized Vitest now has built in support for testing TypeScript types.
How? It includes expect-type now by default. Handy.
Example:
How? Because he helped build multiple extremely valuable companies.
His wealth primarily stems from *equity* in those companies, and he funded them in hard times despite many near bankruptcies. Both SpaceX and Tesla would likely have went under without his financial support.
I'm saying it's good...but it's important to know how to code so one can debug and validate the results
Vibe coding is the modern version of copy/pasting code you don’t understand from Stack Overflow.
It seems fine at first, but at some point you need to understand how to code.
Example: The Dropbox team used this pattern to test many OS and file system edge cases quickly on CI.
Result: Now we can code and test against a mocked implementation in non-prod environments. The mocked implementation can be deterministic and fast, and thus allow quickly testing our business logic against many scenarios. In prod, the wrapper implementation merely forwards to the real APIs.
Problem: Some interfaces like dates, times, localStorage, the URL, and the file system are “globals” that may change at any time. This makes it difficult to set up complex edge cases and hampers testing.
Solution: Instead of coding against these APIs directly, wrap access in an interface.
Still early so can’t say
Problem:
When I correct an LLM it “forgets” and makes the mistake again later.
Solution:
1. Create a llm-learning file.
2. Tell the LLM to write to that file each time I correct it. (I use copilot-instruction.md to instruct Copilot)
Now it “learns” over time!
Oooof wow
Tried using Zod for that?
I validate all my runtime inputs:
-Cookies
-Local storage
-URL params
-API responses
-Form values
-Environment variables
I use Zod to validate runtime inputs. So, I don’t need to worry if the input is malformed.
I show how I work with Zod in detail in TypeScript: Deep Dive”.
Publishing in May!
Sad but true!
Claim: "Those who can't do, teach".
Reality: "To go deeper, teach."
For example, I've worked successfully in TypeScript for years. But now that I'm writing a deep dive course, I'm finding edge cases that I hadn't naturally explored as a practitioner.
Teaching forces me to grow.
I'm reviewing a TypeScript codebase that's filled with type assertions like this.
return fieldErrors as { [key: string]: { errors: string[] } }
Type assertions are NOT safe.
It's saying "Trust me TypeScript, it's fine."
Instead, validate. Consider Zod, ArkType, etc.