Back to News
Advertisement
Advertisement

⚡ Community Insights

Discussion Sentiment

100% Positive

Analyzed from 164 words in the discussion.

Trending Topics

#type#string#https#www#typescriptlang#org#turns#title#simple#language

Discussion (9 Comments)Read Original on HackerNews

muglugabout 1 hour ago
Very cool that the language allows specification of a type in this way.

I added a similar type — “non-empty-string” to a typechecker for PHP, and it’s been adopted widely in the PHP ecosystem. It turns out to be pretty handy, especially when there’s a full type system to support it.

IshKebababout 1 hour ago
"Huh never heard of Bellroy... I wonder what they're using Haskell for..."

Turns out it's some kind of bags and accessories brand!

qbaneabout 1 hour ago
I pondered for a while, it IS the company I used to know
ivanjermakovabout 1 hour ago
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...

antipuristabout 1 hour ago
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`.
phpnode27 minutes ago
yup, it's not possible to do it safely with a simple unparameterised type: https://www.typescriptlang.org/play/?#code/C4TwDgpgBAcg9gOwK...
Cthulhu_31 minutes ago
Speaking of TS, there's stuff in there for typing strings / string formats: https://www.typescriptlang.org/docs/handbook/2/template-lite...
ralferooabout 1 hour ago
It is very much mentioned in the article title and the first sentence. It's just HN that's truncated the title.
nvme0n1p125 minutes ago
Daily reminder that TypeScript's type checker is not sound.

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