News for hackers. Stuff that matters.
Re:Goodbye TypeScript, hello native typing for JavaScript by brundolf on Thursday January 05, 2023 @06:54PM (#34268798)
I say this as a huge proponent of TypeScript and static types in general: I'm fairly bearish on this proposal

1) TypeScript supports a huge set of syntax for describing types, and I would be surprised if the standard ever supports all or even most of that, which would mean you can't skip the build step for most real-world TS projects

2) Most front-end projects will continue to have a build step anyway because of things like JSX, minification, and bundling. And if you've got a build step already, stripping out types is one of the easier things to do as a part of it (and you would want to do it even with this proposal, as a part of minification)

3) On the back-end Deno and Bun run TypeScript natively without a build step. Node doesn't, and it won't be displaced overnight, and it may end up the biggest beneficiary of such a proposal. But even there, build tools like esbuild are fast and easy enough to use that you don't gain much by being able to avoid them (and if you're benefitting from static checking, you're setting up at least one tool already!)

I won't go so far as to say it's a bad thing, but I think it'll end up one of those standards that nobody really uses

Re:Goodbye TypeScript, hello native typing for JavaScript by adamredwoods on Thursday January 05, 2023 @07:22PM (#34269076)
Regarding point 2. Also, there's no way to run a build/compile step for running 'javascript' to catch these type errors before runtime. Would we bring Node into the CI just to catch those errors?

So you may be right, it seems typescript will still be around for enterprise at least.

Re:Goodbye TypeScript, hello native typing for JavaScript by brundolf on Thursday January 05, 2023 @07:34PM (#34269214)
> there's no way to run a build/compile step for running 'javascript' to catch these type errors before runtime

I don't think I follow what you mean here, can you clarify?

Re:Goodbye TypeScript, hello native typing for JavaScript by xsmasher on Thursday January 05, 2023 @11:40PM (#34271042)
Currently we run "tsc" to "compile" the code and tell us about type errors. "This method passes as string to something that expects a number" etc.

In a world where JS has type notation, we'd need a similar command that could analyze the code without running it.

Re:Goodbye TypeScript, hello native typing for JavaScript by brundolf on Thursday January 05, 2023 @11:48PM (#34271086)
tsc does that, but yes, you'd still have to run tsc which was part of my original point
Re:Goodbye TypeScript, hello native typing for JavaScript by Serenacula on Thursday January 05, 2023 @07:50PM (#34269394)
Even if they don't get further than the basic types and user-defined types, that would be enough to make my life dramatically easier. I honestly avoid making stuff in typescript, not because I don't love it, but because setting it up is such a pain in the ass.

If I could avoid that step and still have type annotations and tooling support, I would be a happier person.

Re:Goodbye TypeScript, hello native typing for JavaScript by hajile on Thursday January 05, 2023 @08:46PM (#34269878)
I'd also add that Typescript would be a very bad language choice anyway. If we're going to have a backward-incompatible change, we should do things the right way (after all, we're stuck with it forever).

Don't make a type system work around the really bad parts of JS. Instead, don't allow them in typed modules. Don't settle for an intentionally unsound (aka broken ) type system. Add an actually sound (probably hindley-milner based) type system that provides usable type info to the JIT so we can guarantee fast, safe code.

Re:Goodbye TypeScript, hello native typing for JavaScript by smt88 on Thursday January 05, 2023 @09:20PM (#34270129)
> If we're going to have a backward-incompatible change, we should do things the right way

It makes much more sense to use a good language (Kotlin, Rust, Java) and transpile to JavaScript. There's already great tooling for it.

Re:Goodbye TypeScript, hello native typing for JavaScript by genjii931 on Friday January 06, 2023 @06:18AM (#34273494)
Welcome to Nim.
Re:Goodbye TypeScript, hello native typing for JavaScript by jfengel on Friday January 06, 2023 @10:43AM (#34275928)
JavaScript seems an unlikely compiler target, forced on us out of the odd historical success of JS on the browser. I'd think that a better target would be to make a VM like WASM.
Re:Goodbye TypeScript, hello native typing for JavaScript by smt88 on Friday January 06, 2023 @05:47PM (#34282444)
If WASM were a viable target today, I'd agree, but it isn't yet.

Transpiling to JS is ready for production and widely compatible with all browsers already.