Advertisement · 728 × 90

Posts by Cory House

Convex

7 months ago 2 0 0 0

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)

7 months ago 13 0 1 0
Video

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.

10 months ago 5 0 0 0
Should I test my TypeScript types? #coding #programming
Should I test my TypeScript types? #coding #programming YouTube video by Cory House

Are TypeScript types worth testing?

Sometimes.

Here's when, and how.

www.youtube.com/shorts/Uv7r-...

10 months ago 2 0 0 0
Video

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-...

10 months ago 0 0 0 0
Video

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-...

10 months ago 4 0 0 0
Video

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-...

10 months ago 5 0 1 0
Video

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-...

10 months ago 5 1 0 0
Post image

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.

10 months ago 5 0 2 0
Advertisement

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!

10 months ago 5 0 0 0

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.

10 months ago 1 0 1 0

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?

10 months ago 1 0 1 0

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.

10 months ago 6 0 2 0

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.

10 months ago 10 2 1 0
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 }))
})

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:

10 months ago 8 1 1 0

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.

10 months ago 2 0 2 0

I'm saying it's good...but it's important to know how to code so one can debug and validate the results

10 months ago 3 0 0 0

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.

10 months ago 16 2 2 1
Advertisement

Example: The Dropbox team used this pattern to test many OS and file system edge cases quickly on CI.

11 months ago 2 0 0 0

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.

11 months ago 2 0 1 0

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.

11 months ago 6 0 1 0

Still early so can’t say

11 months ago 1 0 0 0

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!

11 months ago 9 1 2 0

Oooof wow

11 months ago 2 0 0 0
Rule: no-object-literal-type-assertion TSLint documentation. A linter for the TypeScript language.

Could use linting

palantir.github.io/tslint/rules...

11 months ago 3 0 0 0

Tried using Zod for that?

11 months ago 1 0 1 0
Advertisement

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!

11 months ago 14 0 0 0

Sad but true!

11 months ago 3 0 0 0

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.

11 months ago 41 2 3 0

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.

11 months ago 12 0 3 0