logoalt Hacker News

ivanjermakovtoday at 1:36 PM4 repliesview on HN

Language is not mentioned in a title, so my first thought was about TypeScript type wizardry. Turns out it's as simple as `Exclude<string, "">`.

https://www.typescriptlang.org/docs/handbook/utility-types.h...

Edit: nevermind, LLM fooled me.


Replies

antipuristtoday at 1:41 PM

It's simple, and it doesn't work as `Exclude` only applies to union types. For type `string` it just returns the same type `string`.

show 1 reply
ralferootoday at 1:39 PM

It is very much mentioned in the article title and the first sentence. It's just HN that's truncated the title.

Cthulhu_today at 2:29 PM

Speaking of TS, there's stuff in there for typing strings / string formats: https://www.typescriptlang.org/docs/handbook/2/template-lite...

nvme0n1p1today at 2:35 PM

Daily reminder that TypeScript's type checker is not sound.

https://www.typescriptlang.org/play/?#code/C4TwDgpgBAcg9gOwK...

show 3 replies