News for hackers. Stuff that matters.
Re:Announcing TypeScript 2.0 by jeremiep on Thursday September 22, 2016 @04:38PM (#12560170)
How so? That type would be a glorified string at best.

Types can't check the ranges of their values in most languages. And definitely can't do so at runtime.

Re:Announcing TypeScript 2.0 by rpeden on Thursday September 22, 2016 @06:06PM (#12560729)
I can see it working in a statically types language with macros - maybe Scala or Template Haskell? I'm not 100% sure if their metaprogramming is capable of this. Ideally, you could define a type like FileNameString to be a string that has to match a certain regex. Though if you wanted to use the new type throughout your program, I suppose you'd need a String -> FileNameString function somewhere to handle instance of file names generated at runtime.

I agree that the type systems in most mainstream languages fall somewhere short of awesome. I was putting together a small web app in Elm last week, and it was nice to work with a type system that felt like it was helping me design and write better code. That, plus it has the most helpful errors message I've ever seen from a compiler.

Re:Announcing TypeScript 2.0 by Too on Friday September 23, 2016 @12:45PM (#12565971)
Actually it's quite common. For example in .net you have a Uri class and a DirectoryInfo class which are basically just wrappers on top of strings with some validation and helper functions.