144: Gary Bernhardt - TypeScript and Testing

Full Stack Radio

Episode | Podcast

Date: Wed, 05 Aug 2020 15:27:38 +0000

<p><strong>Topics include:</strong></p><ul> <li>Why Gary decided to write Execute Program as a full-stack TypeScript application instead of using a Ruby or Python backend like he may have traditionally</li> <li>Do you actually have to write less tests if you have a good type system?</li> <li>What does a good type system give you that tests can't give you?</li> <li>Using io-ts to type check incoming data</li> <li>How to think about structuring your code to best take advantage of the benefits your type system gives you and minimize the need to write tests</li> <li>Pushing conditional logic to the core of your system to reduce the number of tests you need to write at the edges</li> <li>The correlation between type errors and behavioral bugs, and how a type system can help you catch mistakes you don't think to test for</li> <li>Do type errors signal that you're missing a test?</li> <li>Structural vs. nominal type systems, and the benefits of structural type systems like used by TypeScript and Go</li> <li>Best practices for type-checking within a function in a structural type system like TypeScript</li> <li>The power of supporting literal types like true or "active" in addition to traditional types</li> </ul><p><strong>Links:</strong></p><ul> <li><a href="https://destroyallsoftware.com">Destroy All Software</a></li> <li><a href="https://executeprogram.com">Execute Program</a></li> <li><a href="https://www.typescriptlang.org/">TypeScript</a></li> <li><a href="https://www.executeprogram.com/blog/are-tests-necessary-in-typescript">"Are tests necessary in TypeScript?"</a></li> <li><a href="https://gcanti.github.io/io-ts/">io-ts</a></li> <li> <a href="https://www.executeprogram.com/courses/typescript">TypeScript course</a> on Execute Program</li> <li><a href="https://twitter.com/garybernhardt/status/1109196446257930240">Gary's tweet about unions with literal types</a></li> </ul><p><strong>Supporting the show:</strong><br />I decided to stop taking sponsors for the show because I think advertisements are annoying and no one wants to listen to them.</p><p>If you do want to support the show, the best way to do it is to purchase one of my products:</p><ul> <li> <a href="https://tailwindui.com">Tailwind UI</a>, a collection of professionally designed, fully responsive HTML components built with Tailwind CSS.</li> <li> <a href="https://refactoringui.com/book">Refactoring UI</a>, a book and video series I put together with Steve Schoger on designing beautiful user interfaces, without relying on a designer.</li> <li> <a href="https://adamwathan.me/advanced-vue-component-design">Advanced Vue Component Design</a>, a course on designing simpler, more flexible Vue components that are both more powerful and easier to maintain.</li> <li> <a href="https://course.testdrivenlaravel.com">Test-Driven Laravel</a>, a massive video course on designing robust Laravel applications with TDD. Learn how to build a real-world application from scratch without writing a single line of untested code.</li> <li> <a href="https://adamwathan.me/refactoring-to-collections">Refactoring to Collections</a>, a book and video course that teaches you how to apply functional programming principles to break down ugly, complex code into simple transformations — free of loops, complex conditionals, and temporary variables.</li> </ul>