Live data from Hacker News

TypeScript please give us reflection/runtime types

github.com

21–30 of 287 posts

Re: TypeScript please give us reflection/runtime types

#21
post #9
post #5

There is a good reason for not doing this. Typescript would become some kind of runtime on top of JavaScript. A new language that compiles to JavaScript. Currently TS is only JavaScript with type annotations. There are many languages that compile to JavaScript. Pick one of them and use it! And I have the feeling, that people who want runtime typed Typescript would rather like to write Java/OOP style code instead of J…

You can use Kotlin and compile to JavaScript. It's type system is better and the standard library greater scnr

Exactly. Pick whatever language you like. There are many more options.

Re: TypeScript please give us reflection/runtime types

#22
post #5

There is a good reason for not doing this. Typescript would become some kind of runtime on top of JavaScript. A new language that compiles to JavaScript. Currently TS is only JavaScript with type annotations. There are many languages that compile to JavaScript. Pick one of them and use it! And I have the feeling, that people who want runtime typed Typescript would rather like to write Java/OOP style code instead of J…

ReasonML

Re: TypeScript please give us reflection/runtime types

#23
post #9
post #5

There is a good reason for not doing this. Typescript would become some kind of runtime on top of JavaScript. A new language that compiles to JavaScript. Currently TS is only JavaScript with type annotations. There are many languages that compile to JavaScript. Pick one of them and use it! And I have the feeling, that people who want runtime typed Typescript would rather like to write Java/OOP style code instead of J…

You can use Kotlin and compile to JavaScript. It's type system is better and the standard library greater scnr

This is the way. Best of both worlds although using js libraries is kind of a pain

Re: TypeScript please give us reflection/runtime types

#24
post #5

There is a good reason for not doing this. Typescript would become some kind of runtime on top of JavaScript. A new language that compiles to JavaScript. Currently TS is only JavaScript with type annotations. There are many languages that compile to JavaScript. Pick one of them and use it! And I have the feeling, that people who want runtime typed Typescript would rather like to write Java/OOP style code instead of J…

I'm misunderstanding your reasoning here. TS is already a new (superset) language which compiles to JS. Runtime types solve the problem of maintaining two duplicate, separate type systems -- one for compilation, one for validating data. I'm not seeing how that's related to OOP. For instance, my preferred workaround lib for this problem, `io-ts`, leans hard on functional programming.

Re: TypeScript please give us reflection/runtime types

#25
2¢, having non-runtime types makes code behavior easier to reason about, especially when aggressive type inference is present, and I'd hate to lose it

One of the things I don't love about Rust is how type inference affects program behavior in ways that can be really subtle. In Rust's case this is a necessary evil because it doesn't have a dynamic foundation, but TypeScript has done great without that compromise

Re: TypeScript please give us reflection/runtime types

#26
post #5

There is a good reason for not doing this. Typescript would become some kind of runtime on top of JavaScript. A new language that compiles to JavaScript. Currently TS is only JavaScript with type annotations. There are many languages that compile to JavaScript. Pick one of them and use it! And I have the feeling, that people who want runtime typed Typescript would rather like to write Java/OOP style code instead of J…

For any sufficiently large project, dynamically typed languages are not nice, they are a series of interweaved disasters consisting of constantly tripping over what you thought was your feet but is actually NaN and trying to fall forward rather than collapsing entirely. In every workflow I've seen, TypeScript is already a language that gets compiled to JS. It might as well take full advantage.

Typescript is not really compiled to JS, only the type annotations are removed.

To make dynamically typed languages nice for bigger projects we have typescript for type annotations (it's does not make it a statically typed language!). It is there, it is used, it scales and it works. If your type script project "collapses entirely", it's probably not the languages fault.

Re: TypeScript please give us reflection/runtime types

#27
post #5

There is a good reason for not doing this. Typescript would become some kind of runtime on top of JavaScript. A new language that compiles to JavaScript. Currently TS is only JavaScript with type annotations. There are many languages that compile to JavaScript. Pick one of them and use it! And I have the feeling, that people who want runtime typed Typescript would rather like to write Java/OOP style code instead of J…

ReasonML

[deleted]

Re: TypeScript please give us reflection/runtime types

#29
I’m not an expert or anything but I sincerely feel like this is barking up the wrong tree.

To anyone who works on typescript/JavaScript outside the context of a web browser, you DO NOT matter as far as I am concerned. If I was in control of JavaScript/typescript, I’d give zero attention to your demands. You are not my top priority. Go away.

I feel like we are losing focus here. Should JavaScript be an all purpose language? Yes. Should we focus on making a web browser context, also yes.

The reason I led with this is that I think it is up to the JavaScript folks and the web browser vendors to include support for this before typescript can change what it emits. Ideally, I’d say wait a couple of years after browser vendors include support to implement this in typescript.

Re: TypeScript please give us reflection/runtime types

#30
post #20
post #11

Earlier quoted context omitted.

typescript enums exist and are compiled to javascript (other than const enums)

And that's one of the features of typescript that really sucks. String union types work so much better.

Why does typescript enum really suck?
Post reply on HN