042: Comparing TypeScript and Elm's Type Systems episode artwork

EPISODE · Oct 25, 2021 · 1H 8M

042: Comparing TypeScript and Elm's Type Systems

from Elm Radio · host Dillon Kearns

TypeScript and Elm have different goalsSoundness is not a goal of the TypeScript type systemTypeScript Design Goals (and non-goals)TypeScript's any typeNominal vs structural typingTypeScript's any vs. Elm's Debug.todoTypeScript's any essentially "turns off" type checking in areas that any passes through.In Elm:You can get a type that could be anything with Debug.todo, but you can't build your app with --optimize if it has Debug.todo's in itYou will still get contradictions between inconsistent uses of a type that could be anything (see this Ellie example)This Ellie example (with compiler error as expected) and this TypeScript playground example (with no error) show the difference.any can not be used in places that take neverany vs unknownJSON.parse returns any, as do many core and published typingsio-ts lets you validate JSON similar to JSON decoders in ElmDefinitely Typed (published type definitions for NPM packages)Definitely Typed searchnoImplicitAnyTypeScript `strict mode in tsconfigDillon's post TypeScript's Blind SpotsJS semantics allow types that may not be intended (like adding a string + object, '' + {} === '[object Object]')Function parameters are inferred to be any regardless of implementation if they aren't given an explicit typeType narrowingTypeScript has untagged unions (just called Unions) - in Elm, there are only tagged unions (called Custom Types)Undefined vs nullTypeScript's Void typeTypeScript doesn't have checked exceptions like Java (there is a discussion about this on GitHub) - Elm only has explicit errors as data that must be handled exhaustively like other data typesDiscriminated unions vs Elm custom typesLiteral typesTypeScript allows number literal values, but arithemtic expressions return generic number values instead of literal typesEnumsBranded types in TypeScript vs opaque typesElm Radio Opaque Types episodeSwitch statements are not exhaustive - you can add an eslint rule to check that (or the never trick, assert unreachable)Key of operator in TypeScriptTypeScript's type system can do some cool things that Elm can't (for better and for worse)PrismaPrisma advanced TS meetup talksTuples in TypeScript are just arrays and use narrowing - Tuple in Elm is a specific typeelm-ts-interopTypeScript handbook on official site

TypeScript and Elm have very different type systems with different goals. We dive into the different features and the philosophy behind their different designs.

NOW PLAYING

042: Comparing TypeScript and Elm's Type Systems

0:00 1:08:57

No transcript for this episode yet

We transcribe on demand. Request one and we'll notify you when it's ready — usually under 10 minutes.

Frequently Asked Questions

How long is this episode of Elm Radio?

This episode is 1 hour and 8 minutes long.

When was this Elm Radio episode published?

This episode was published on October 25, 2021.

What is this episode about?

TypeScript and Elm have different goalsSoundness is not a goal of the TypeScript type systemTypeScript Design Goals (and non-goals)TypeScript's any typeNominal vs structural typingTypeScript's any vs. Elm's Debug.todoTypeScript's any essentially...

Can I download this Elm Radio episode?

Yes, you can download this episode by clicking the download button on the episode player, or subscribe to the podcast in your preferred podcast app for automatic downloads.
URL copied to clipboard!