News for hackers. Stuff that matters.
Re:Building a hybrid native application with Gleam and Tauri by superice on Monday February 19, 2024 @08:16PM (#39436915)
Oh that’s easy to fake with type narrowing:

function expectType<A, B extends A>() {}

expectType<never, typeof yourUnion>();

The function call will fail at compile time if yourUnion is anything more than never, which you can use in your else case of if statements that narrow the discriminated union.

There are no comments on this comment yet.