Profile avatar
housecor.com
Courses: http://pluralsight.com YouTube: http://youtube.com/@housecor Consulting: http://reactjsconsulting.com ⚛️
134 posts 2,077 followers 61 following
Prolific Poster
Conversation Starter

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!

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.

Just realized Vitest now has built in support for testing TypeScript types. How? It includes expect-type now by default. Handy. Example:

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.

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.

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!

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!

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.

There are many JS runtimes - Node, Deno, Bun, etc. Just learned about a new one: Bare. Bare is unique: - Light (runs on mobile) - No server (great for P2P apps) - Not tied to a specific JS engine. - Separate modules (Upgrade modules when desired. Install what you need) More: bare.pears.com

“We don’t have time to write tests” isn’t a valid excuse anymore. I'm presenting "Creating Automated Tests with AI" April 23 at 11AM ET. In this webinar I'll show how to quickly generate tests using ChatGPT, Copilot, and Applitools Autonomous. Sign up: applitools.info/8y6

TypeScript has around 20 utility types. There are 100's of handy 3rd-party utility types too. Here are the top 4 I found while researching "TypeScript: Deep Dive" (publishing soon). github.com/millsp/ts-to... github.com/piotrwitek/u... github.com/andnp/Simply... github.com/sindresorhus...

React Server Components have gotten a lot of hate recently. I'm not saying they're perfect, but this short comparison shows why I still think they're compelling. youtu.be/LdFPUzkaiCA

I've heard people say "spelling mistakes in code are harmless". I disagree. Spelling mistakes slow reading, create confusion, and can lead to bugs. Solution: Run cspell as part of your CI process. Here's an example cspell just found - a misspelled style that wasn't applying.

PSA 📢: This isn’t error handling. .catch((e) => console.log(e)) It's error swallowing. The user isn’t watching the console. Solution: Show the user a friendly non-technical message like "Sorry, an error occurred. Please try again later."

TypeScript radically improved my frontend code. Here are 7 reasons I use TypeScript instead of JavaScript. youtube.com/shorts/fQaC0...

Problem: Unused npm dependencies. They make package.json harder to read, bloat node_modules, waste our time updating packages we don’t use, and create confusion about what our project requires. Solution: npx depcheck It lists unused dependencies.

Problem: I want to see a list of the settings I've changed in VS Code. Solution: Search for @modified. This displays a list of modified settings. I used this today because I recently changed a setting that I wanted to revert, and couldn't recall the setting's name.

A React RSC payload includes 3 things: 1. The rendered server component. 2. Client component placeholders, with a reference to the JS chunk containing the client code. 3. Props passed from server components to client components. 3 is the place to watch for needless bloat.

In TypeScript, there are at least 4 ways to implement immutability. Here's how I choose between them. youtube.com/shorts/pwtKr...

Now that Node, Bun, and Deno can run TS files directly without compilation, using JSDoc syntax to declare TypeScript types is even harder to justify. JSDoc syntax is more verbose, lacks full feature support, and is harder to read. Look at this comparison. Easy choice.

In TypeScript, Interfaces and Types are often interchangeable. But these six features only work with types. youtube.com/shorts/tR8ps...

Learn TypeScript in 60 seconds.

TypeScript is great. But it has 3 features that you should probably avoid. Here's what I suggest using instead. Clip from "TypeScript: Getting Started" on Dometrain youtube.com/shorts/tr39p...