Live data from Hacker News

HypeScript: Simplified TypeScript type system in TypeScript's own type system

github.com

21–30 of 84 posts

Re: HypeScript: Simplified TypeScript type system in TypeScript's own type system

#21
post #4

Oh thank God. There aren't nearly enough ways to write javascript.

There's no Javascript (or any other runtime) code in this at all. It all happens at compile-time.

But you probably are going to be running this as JS eventually

Re: HypeScript: Simplified TypeScript type system in TypeScript's own type system

#22
post #14

“I'm not about to start using it for real projects, it's really just a thought experiment about how nice JavaScript could be with an alternative syntax.” - jashkenas 2009 https://news.ycombinator.com/item?id=1014225

Man, I know this wasn't really the intention of the comment, but I just read through that thread and got a little nostalgic. Crazy that was like 13 years ago. Sheesh.

Re: HypeScript: Simplified TypeScript type system in TypeScript's own type system

#24
post #4

Earlier quoted context omitted.

There's no Javascript (or any other runtime) code in this at all. It all happens at compile-time.

But you probably are going to be running this as JS eventually

If you transpile it to js, you'll get empty file.

Re: HypeScript: Simplified TypeScript type system in TypeScript's own type system

#28
post #10

Am I the only one that feels uncomfortable with all that usage of strings in TS’s type system? Why not use pure literals instead of string literals? This is a genuine question, I’m trying to find out what the pros and cons where in the decision making process.

As others have pointed out, they're not really "strings" per se, or at least can be a lot stricter than a string might seem when used right. We use that constantly for useful things.

The bigger reason why it is this way is to ensure you can write type annotations for stringly-typed Javascript. While Typescript is it's own thing really at this point, it still is very focused on making it possible to type-annotate JS code.

    type Event = 'onClick' | 'onHover'

    // some stringly typed javascript can now be nicely typed
    something.triggerEvent('onClick', someData)
It lets you do some really nice things, and is quite strongly typed despite how it looks at first glace, while still letting me write some strongly-typed definitions for existing Javascript code that was very much __not__ written with types in mind.

Re: HypeScript: Simplified TypeScript type system in TypeScript's own type system

#29
This is insanely cool voodoo. But... I may be lacking in imagination here... I'm trying to think of how I'd actually use it. Maybe it'll come to me in the middle of the night 8)

I do really wish TS had actual inbuilt reflective type checking along the lines of this: https://github.com/Hookyns/tst-reflect ...I can hazily see some kind of monstrosity that could come from linking these things together hah

Re: HypeScript: Simplified TypeScript type system in TypeScript's own type system

#30
post #4

Earlier quoted context omitted.

There's no Javascript (or any other runtime) code in this at all. It all happens at compile-time.

But you probably are going to be running this as JS eventually

There's literally nothing to run. The source file is just a bunch of type declarations.
Post reply on HN