Readit News logoReadit News
dimitropoulos · 3 years ago
Without Angular, we may very well not have TypeScript today.

The top thing listed in this release (TypeScript doesn't follow semver, btw) is about Decorators. I find the whole story about Angular's role in TypeScript early days to be very fascinating because I don't hear people talk about it anymore (just search "AtScript TypeScript" if you weren't around at the time). It was the Angular team that forced Decorators to be added when it was still stage 0. In exchange, they forfeited continued work on their would-be competitor to TypeScript.

Even without the Decorators thing, Angular was intensely popular and it made a big impact how they went "all in" on TypeScript, pushing a lot of early adoption. I know lots of people that first started with TypeScript because of work on an Angular project.

I think a lot of people don't seem to know/remember how touch-and-go TypeScript was in the very early days. There were many large projects that were all-in on FlowType, and others still that were pushing for Elm, etc. For example, it took quite a while for you to be able to do JSX _at all_.

Today, we just have TypeScript. Well. I do know one company that uses ReasonML (or isn't it called Rescript now?)

---

Historical stuff aside, I'm extremely happy we ended up with TypeScript over the others because the team is so incredibly awesome and dedicated. It's rare you see such a large project so well shepherded by such a talented set of individuals. It speaks volumes that the average tenure on that team is so high. We've seen some public apologies from the Flow team on this topic so I don't feel like I'm talking behind anyone's back if I say they ended up truly not being up to the task of being what TypeScript is today.

JamesSwift · 3 years ago
One of my most regretted decisions was evaluating Flow vs Typescript and going with Flow. Years later I had the opportunity to use Typescript and it was so nice comparatively. I've enjoyed it ever since. Of course, that was with years of development in its belt so maybe the experience wouldn't have been as nice if I went with it originally.
tomduncalf · 3 years ago
It’s hard to imagine if you weren’t in the React community at the time, but I feel like most people were pushing Flow at the time and choosing TS was quite controversial. I think it was the combination of Flow being from Facebook, and the “no build step/its just JS with annotations” thing which people made a big deal out of, but I never saw as a big differentiator.

I had a hard time convincing a couple of places I worked to use TS rather than Flow for greenfield projects, but I’d tried them both out and concluded Flow just felt too unstable - the server would consume all my memory and crash and it just didn’t feel like a good dev experience. I managed to convince them by showing them how you could strip out Typescript types in much the same way as Flow if TS did turn out to be a dead end. I also recall having vigorous debates at React meetups where I was the only person in favour of TS haha.

How times changed - you definitely can’t be blamed for choosing Flow at the time though as TS was the outsider. Also MS weren’t such a trusted brand for developers, people still associated them with proprietary stuff like .net/full fat Visual Studio and I think a few people had burned out in the MS ecosystem before and didn’t want to touch their stuff again!

brundolf · 3 years ago
I made the same mistake, though our transition to TypeScript was actually very smooth. We just set up Babel to handle both, then converted one file at a time. Flow files functionally became untyped JS files until they were converted. And the syntax/semantics were close enough that converting code was really easy
dimitropoulos · 3 years ago
Same. I spent the next few years doing major refactors from Flow to TypeScript (the largest that's public was for Insomnia: https://github.com/Kong/insomnia/discussions/3654).
devmunchies · 3 years ago
Interestingly, both flow and typescript have roots in OCaml/F# respectively. Flow was written in OCaml and the creator of Typescript was on the F# team at Microsoft.
beaugunderson · 3 years ago
we started with Flow and moved to TypeScript a few years ago; converted 100k lines of code primarily with sed via regular expression find/replace; even then TypeScript was better but 80% of the better part was the library of available typings--Flow's support for lodash types was awful in comparison and we used lodash and lodash/fp all over the place
indeyets · 3 years ago
Flow was (and still is) awesome as a concept, but its main problem was that it felt as a side-project, which was supported for internal Facebook cases, but not really for open-source. TypeScript (back then) was a simpler language, but had a lot more manpower, which resulted in faster bug-fixes and more coverage of libraries.

If Flowtype had more resources from Facebook it could still be the dominating language

bern4444 · 3 years ago
Don't worry - the Twitter web team also made this mistake. But they made it at a time when TS was popular instead of earlier when the two were equally popular.

Even well after TS was clearly the better option (as in 2022) the twitter web team opposed anything being done in Typescript like separate modules that would be a dependency of the web repo.

At least you recognize the better direction now.

latchkey · 3 years ago
I'm curious what criteria you used to pick Flow vs. Typescript.
TOGoS · 3 years ago
So it would seem that going with the flow turned out to mean not going with Flow; how confusing![1]

I went with TypeScript early on because the compiler chain felt better integrated than the alternatives. No messing with chains of babel translators and source mappings; just use one tool. Maybe I liked the syntax better, also. Although as I recall, in the beginning, somebody my company interviewed had set up TypeScript using Babel, and it was all very over-my-head and impressive. He turned out to be too good to work for us, but some of his ideas really stuck with me.

[1]This is why I dislike cutesy names for software projects. Just call it FacebookTypeAnnotatedJavaScriptFrobulator3003 (FTAJSF3003) or something.

andsoitis · 3 years ago
> One of my most regretted decisions was evaluating Flow vs Typescript and going with Flow.

What caused you to choose Flow over TypeScript?

nikeee · 3 years ago
I remember this well, too.

Ironically, I think that angular is the framework that benefits least from actually using TypeScript. There is a separate templating language that's only type-checked if you set the right compiler options. JSX is much better suited for that. Being OOP like angular, it often requires opting out of null-safety or init-checks, because something is late-initialized. Having mutable instance state results in less opportunities to be more strict with typing.

Its good that the TS team decided to align with the ES standards. Initially (talking like v0.8.0), I had the impression that they're building a "C# for the web", being incompatible with ES. Maybe that's why enums and namespaces were added and initially, the boolean was named bool.

WorldMaker · 3 years ago
Enums have been proposed for JS for quite a while (there was a sort of enum in "the lost version" ES4 and a TC-39 proposal stuck in Stage 0 for years now [1]). Enums have always had relatively simple JS output that resembles a somewhat common pattern in JS. It was a "standard", just never really a deeply adopted "standard".

What's today called "namespaces" in Typescript was originally called "modules" and then "inner modules" (to differentiate from "exterior modules") and is a tiny simplification on a JS pattern that was extremely common at the time of Typescript's inception called at the time "IIFE modules". "namespace" is a very C# name chosen in desperation (when it became clear that "exterior modules" were the present not just the future of the language and "interior modules" was too confusing a term to live), but it's a very old (and used to be extremely common) JS pattern that TS gave a tiny bit of syntax sugar to. It was a "standard" that existed at the time that was (rightfully) killed by AMD/UMD/CommonJS/ESM, but it is hard to fault the Typescript team at the early 0.x days thinking the "Stage Wild" JS pattern would possibly live on for many years to come. (This is also relevant to the patch notes for Typescript 5.0 as 5.0 is the first version [!] to itself be written as [proper/"exterior"] modules rather than namespaces. There are some interesting stories, including in these release notes for why that took so long to transition and what the performance benefits have been post-transition.)

Even those things that didn't seem like ES standards have some history as JS "standards". It's not like TS 0.x/1.x didn't support "standards", it is more that the TS team mostly decided to focus more on later stage ES standards (more likely to be accepted by browsers) rather than trying to "prollyfill" Stage 0 and "Stage Wild" standards.

[1] https://github.com/rbuckton/proposal-enum

martypitt · 3 years ago
I remember this well.

From the outside, it seemed a fantastic example of collaboration between two separate (competing?) teams. It took humility and pragmatism for the Angular team to abandon AtScript and recognise TS as the better long-term bet.

agency · 3 years ago
I have often thought that it must have been tough to be on the Flow team. It was pretty good, and absolutely would have been "good enough" to catch on if it weren't for TypeScript. But ultimately the better language won.
epolanski · 3 years ago
Flow ultimately served only Facebook purposes and their work and the evolution of the language wasn't on par with TS.
dimitropoulos · 3 years ago
And it doesn't hurt that the TypeScript team is so great. We've seen some public apologies from the Flow team on this topic so I don't feel like I'm talking behind anyone's back if I say they ended up truly not being up to the task of being what TypeScript is today.
spankalee · 3 years ago
AtScript was always stillborn, and the Angular team absolutely could not have made a competitor to TypeScript.
dimitropoulos · 3 years ago
Agreed, but the point I was making here is that Angular itself was very far from stillborn, it pushed early adoption of TypeScript really really hard which did wonders for TypeScript to be taken seriously.
zaphirplane · 3 years ago
Wonder why they didn’t go with the other google language Dart

Too foreign to frontend audiences? It has a lot of fans in flutter

no_wizard · 3 years ago
>Today, we just have TypeScript. Well. I do know one company that uses ReasonML (or isn't it called Rescript now?)

One company outside Meta?

illusionalsgcty · 3 years ago
There's definitely a few around that are using ReScript; we've been using ReScript for production services for a bit more than 2 years now at Autobooks.

https://rescript-lang.org has a list too

dimitropoulos · 3 years ago
yes! haha. They love it. I ping them and see if they want to identify themselves.
throw_m239339 · 3 years ago
> Without Angular, we may very well not have TypeScript today.

Typescript was started at Microsoft by the guy who designed Turbo Pascal and C#, so completely independently from Google's Angular team. Angular had its own "AtScript" and eventually ditched that. Typescript had experimental decorator support well before Angular Team moved from AtScript, because it was a ECMAScript proposal.

Angular had zero influence in the design or success of Typescript. Typescript however does support JSX optionally so one can claim that React DID influence Typescript's design decisions.

RyanCavanaugh · 3 years ago
(I have worked on the TypeScript team since before its initial release)

While it's true that TS would have been started with or without Angular, I think OP is largely correct in the influence that Angular's embrace of TS had in TS's long-term success.

It's difficult to see these days, but if you were watching TypeScript's adoption numbers back when Angular made its TypeScript announcement, there is a marked inflection point when that happened. I was running lots of charts and graphs at the time tracking all kinds of data, and in every graph, you could see the Angular announcement in the chart; it's where the line went from kinda slow and linear to kinda fast and exponential. It was a true discontinuity in the second derivative.

We can't run history twice and see what would have happened without Angular, but I think the quantitative impact in this timeline is undeniable.

dimitropoulos · 3 years ago
Even if that's true (it's definitely not how it was depicted at the time at conferences and from people on the Google side).. the point stands Angular was absolutely huge for it's day and they pushed TypeScript really really hard. It was a truce between two huge companies and it made waves in terms of people trusting Microsoft.

I have personally never been one of those mega Microsoft haters but I witnessed shouting matches in the office from people that we're hotly opposed to TypeScript being added to the codebase against others using Angular as a core motivation in many of their counter-arguments.

I'm super glad we have TypeScript one way or the other because the team is so dedicated to OSS.

styfle · 3 years ago
> Typescript had experimental decorator support well before Angular Team moved from AtScript

Do you have a source for this. My memory isn't so good but I seem to remember that the Angular team pushed to get this Stage 0 proposal implemented even though the TypeScript team usually waits until Stage 2 or 3 to implement.

jeremycarter · 3 years ago
Typescript was born of JScript. Check the history and the docs.
cies · 3 years ago
> and others still that were pushing for Elm

Still pushing for it. TS is like make-up on a pig, compared to Elm.

> I do know one company that uses ReasonML (or isn't it called Rescript now?)

Re* is also a better alternative imho. Better interop with JS/TS is very nice. But in place one could use Elm, I'd say it certainly wins in the "clean" reward.

giraffe_lady · 3 years ago
god just think how good life would be if we had all switched to elm or reason instead.
rk06 · 3 years ago
Elm was never an option with how hard it is on "no js" policy
iudqnolq · 3 years ago
If only Elm was infinitesimally less pure.
roebk · 3 years ago
there's not a day that goes by that I don't think about this
truth_seeker · 3 years ago
Yep. Frameworks play an important role in end user (developers) helps deliver software as quickly as possible.

Just like without Rails framework, we may very well not have Ruby today.

Also, without WordPress, we may very well not have PHP today.

epolanski · 3 years ago
True, Angular was crucial for adoption of TypeScript 5+ years ago but I think the community would've migrated nonetheless.
dimitropoulos · 3 years ago
for sure for sure. that's kinda the point though: they already were migrating... to Flow. Lots of big projects are on the list that had to change course later because TypeScript won:

- Yarn

- Jest

- Luxon

- Gatsby

- Expo

- Styled-Components

- GitKraken

- GraphQL-js

and that's just off the top of my head. I'm sure there were many more.

Deleted Comment

skratlo · 3 years ago
We have WASM dude. But TS people are in TS bubble for what it's worth.
swatcoder · 3 years ago
WASM and TypeScript don’t really compare or compete. I’m not sure what you’re saying.
mc10 · 3 years ago
Until WASM can touch the DOM you’re still going to need JS (and hence, TS).
yCombLinks · 3 years ago
It's not worth anything. Are you writing raw WASM?
brundolf · 3 years ago
It's easy to miss, but I'm most excited for "--moduleResolution bundler" (https://devblogs.microsoft.com/typescript/announcing-typescr...)

My understanding is it should allow you to finally have TypeScript files that import other TypeScript files and include the file extension. This is important because, for one, it means Deno TypeScript modules and non-Deno TypeScript modules are now compatible (can import each other)! As long as no unavailable system APIs are used, of course

This has been a problem in a project I've been working on where a Deno back-end service wants to share some code with a Next.js front-end service. Currently, the shared modules are not able to import anything else, because Deno requires file extensions in import paths and non-Deno TS requires no file extensions in import paths

veidr · 3 years ago
FYI, I just tested this, and it seems to work. I was a little concerned about the commentary in the PR about this new mode being "definitely not suitable for Deno", but I think what you want to do is the same thing I've been really irritated that I couldn't do before.

Namely, I have an Nx monorepo full of standard TypeScript code, but that code works with a many things: Node, Electron, frontend apps with Angular or Svelte or whatever, etc.

I want to use Deno for some new stuff, but Deno couldn't import any of that code without modifying that code so it no longer worked with all the non-Deno stuff.

For a quick test, I made a new default Nx monorepo and a regular TS library and a Deno library and a Deno app.

I changed all imports to use '.ts', and added this to the tsconfig.json:

    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
...et voila! My Deno code can finally import all that normal TypeScript code I have sitting around.

Haven't tested anything else yet, so I am not sure what, if any, issues those two changes above, plus including the .ts extension, might cause for other existing TypeScript projects.

ddeck · 3 years ago
>I just tested this, and it seems to work. I was a little concerned about the commentary in the PR about this new mode being "definitely not suitable for Deno"

FWIW I've been using version 5.0.0-dev.20230223 for a few weeks specifically for this feature - to share code between TS Vite/web and Deno projects - and it's been working without issue.

brundolf · 3 years ago
Exciting!

It's weird to see this:

> commentary in the PR about this new mode being "definitely not suitable for Deno"

I wonder what they meant by that. I mean, this doesn't magically make all TS code Deno-compatible, but nobody expects it to. What it does do is remove by far the most ubiquitous (and silly) barrier to TS code being Deno-compatible. There are others- system APIs, http imports. But this change allows a whole lot of code that doesn't use those to become compatible

ssalbdivad · 3 years ago
Since `.ts` extensions were in alpha, our repo has been set up so that you can switch between Node and Deno seamlessly in-editor and continue developing with no config or source changes.

Personally, I found all the `npm` integration stuff to be a bit overkill for what we were looking for, and honestly Deno's network requests while installing from npm were constantly flaking out in our CI. We ended up just disabling it via Deno's `--no-npm` flag (https://github.com/denoland/deno/issues/17916) and reverting back to a simple set of import_maps to get the node deps we needed. Works like a charm!

Feel free to reference if it's useful:

https://github.com/arktypeio/arktype

jakebailey · 3 years ago
"bundler" is definitely not going to be the right resolution mode for using Deno; you may be better served by using ESNext or Node16/NodeNext (the "strictest" mode, really). The "who should use this mode" section here I believe is still accurate: https://github.com/microsoft/TypeScript/pull/51669
brundolf · 3 years ago
From the PR (https://github.com/microsoft/TypeScript/pull/51669):

> New compiler options

> - allowImportingTsExtensions: Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set.

To be clear, I'm not using tsc to build code for Deno. I've got module X which imports module Y, neither of which have any platform-specific dependencies. Right now if module X imports Y with the .ts extension, Deno can import X but tsc can't. If module X imports Y without the .ts extension, tsc can import X but Deno can't. With this compiler option, I should be able to include the .ts extension and allow both to (independently) import the same code

no_butterscotch · 3 years ago
Interesting. I don't like all the build-tooling around front-end/Typescript. It's a common complaint I know.

I recently tried to modularize some code into a package that used Typescript import-path aliases. I don't know which step(s) I got wrong since there's multiple tools/packages, each with different versions, each with a different package needed for the appropriate build tool (x-for-webpack, x-for-rollup, etc). When building and re-using the module in some other project with a different build config I couldn't get it to build properly and wanted to just get back to working on my actual project.

I eventually just went and looked at the typescript repo for a reference build config thinking they'd have something easy to follow, but I just decided since they don't use import path aliases I won't either.

I hope all the tools go away that require me to look up things like: "is it an X type of module? if so export/bundle it this way" or "are you using an X type of module? if so import it in Y fashion and use build-pipeline plugins A B and C"

endisneigh · 3 years ago
I have a strange take - I think Typescript types are better most other languages, including Java, C++ and Go. It's strange since TypeScript is adding types to a weakly typed language.

If we could push JavaScript performance to be another order of magnitude faster it wouldn't be necessary to use other languages, imho. Of course, pushing it that far without effectively creating a new one would be difficult, to say the least.

spion · 3 years ago
I used to think so too, until I tried Rust.

By comparison, JavaScript (and by extension, TypeScript) is still lacking fundamental features and the library ecosystem situation is pretty bad.

I wish there was a modern language that took all the good non-manual-memory-management things from Rust and added a GC and some immutable data structures. Error handling, enums, macros (with compile_error! / diagnostics API), traits / approach to OOP, embedded tests, doctests and the relentless determination to add examples in the docs in general... Everything in Rust feels like "oh, they got this right too", which hasn't been the case for any other typed lanuage I've used in the past 15 years (including typescript, my previous favorite; purescript; go; haskell)

hatuthecat · 3 years ago
You’re basically describing Swift. Swift and Rust had a ton of cross pollination during their early years which led to those features developing similarly but memory management is a lot less targeted for extreme efficiency like Rust. Hopefully as the language continues to mature, the feasibility to use it outside of apple platforms also does because I really enjoy the language design.
jiggawatts · 3 years ago
I've been saying the same thing: We need an ahead-of-time compiled high level, business language. Something as efficient as Rust, but not designed for embedded microcontrollers or systems software.

I feel like the entire industry has had a "kneejerk reaction" to C++ and its abysmally slow compile times. Everyone jumped onto the interpreter bandwagon and ended up throwing the baby out with the bathwater.

It is definitely possible to have sub-second compile times for large, complex software! Just look at Jonathan Blow's Jai language. He can recompile and reload an entire 3D game engine in about that time.

We can have our cake and eat it to. We can have efficient, compiled languages and still have safety and fast compilation.

jdthedisciple · 3 years ago
Have you tried C#? Sounds like it would fit your needs perfectly, additionally benefitting from a huge ecosystem behind it.
laurencerowe · 3 years ago
> I wish there was a modern language that took all the good non-manual-memory-management things from Rust and added a GC and some immutable data structures.

This basically describes all of the recent ML – perhaps more specifically OCaml – influenced languages like Kotlin, Swift, F#. (Rust is also heavily influenced by OCaml but its distinguishing feature is manual memory management with lifetimes.)

I do wish we had a good Linux/Posix option with as good of a package manager as Rust's cargo. Kotlin and Swift have some support but are largely focussed on the JVM and MacOS respectively. OCaml itself is of course an option here but its syntax and smaller ecosystem is a stumbling block. Reason is an attempt at a more familiar syntax for OCaml but that community is mostly focussed on transpilation to JavaScript with ReScript.

jpgvm · 3 years ago
For me that's Kotlin.

It's my general purpose language. I also use Rust everywhere Kotlin isn't suitable.

evntdrvn · 3 years ago
That’s basically F#. It’s great.

Deleted Comment

felipeccastro · 3 years ago
Have you tried Crystal? I got the same "oh, they got this right too" feeling about everything as well.
cmrdporcupine · 3 years ago
You just described OCaml or StandardML.

Or as others have said, F#, or maybe Scala. Or if you're feeling really brainy, Haskell.

But Rust was, in its early days, basically inspired by the ML type system, its type inference model, and its pattern matching facilities. The first Rust compiler was written in OCaml.

epolanski · 3 years ago
Well he said better than most, not best of every.
kaba0 · 3 years ago
Scala 3, or perhaps OCaml.
treis · 3 years ago
The jankiness of JS combined with the correctness of TS really is a powerful combo. Especially stuff like string keys and const arrays as enums make safe and readable code without a lot ceremony.

The big problem is the gap between TS and JS. User defined typeguards are a usable work around but it would be nice to be able to use a native isMyType function.

Also would be nice to have constraints natively in types. Like string lengths or max ints.

epolanski · 3 years ago
You can do all you list with effect-ts/schema.

Arguably the highest quality TS lib out there.

https://github.com/Effect-TS/schema

TOGoS · 3 years ago
Good take if you ask me. When I want to flesh out an ontology, I find that TypeScript's type syntax more natural than anything else. Generally I find it to do an amazing job of bridging between a very expressive and flexible type system and a language that at runtime knows nothing about your types.

Want structural/duck typing? No problem; that's the default. Define new interfaces that old classes happen to implement without having to wrap them. I always wanted that feature!

Want nominal types? No problem; just declare a field indicating the type name!

  interface Square { classRef: "http://example.com/Shapes/Square"; width: number; }
  interface Circle { classRef: "http://example.com/Shapes/Circle"; diameter: number; }
  type Shape = Circle|Square;
(I like to express things in a way that can be easily translated to RDF, hence my use of URIs for type and attribute names)

Since TypeScript types don't runtime checks, you can even do it on atomic types!

  type USDollars = number & { [Symbol.for("http://ns.nuke24.net/Synx/unit")]: "USD" }
  type CanadianDollars = number & { [Symbol.for("http://ns.nuke24.net/Synx/unit")]: "CAD" }
  
  const someAmount : CanadianDollars = someExpressionReturningUsDollars; // Compile error!  Try doing that in Java!  I OFTEN WISH I COULD

TOGoS · 3 years ago
Addendum to my nominal types: For the 'fake' nominal types (you can't put a symbol on a number!) I like to make those fields optional, which makes the type less of a lie. "If this number did have a [unit symbol] property, the value would be 'USD'". That will still prevent accidental USD <-> CAD conversion, but allows converting to/from regular numbers without explicit casting.

A pile of thoughts on the subject from back when I first came up with it: http://www.nuke24.net/plog/32.html

smt88 · 3 years ago
After using structural typing in TS, it's very hard to go back to nominal typing.
epolanski · 3 years ago
Better is hard to qualify but I'll add my 2 cents:

- for functional programmers TS offers lots of flexibility and power many other languages including statically typed and pure don't

- TS functions or methods that throw don't show up in the type system (they do in Java)

I hope TS keeps getting stricter.

throw_m239339 · 3 years ago
> I have a strange take - I think Typescript types are better most other languages, including Java, C++ and Go. It's strange since TypeScript is adding types to a weakly typed language.

Typescript types don't exist at run time, at all. So it's easy to be better when your language is merely about static analysis as it will not enforce any sort of type system during runtime. Java, Go or C++ have different constraints.

dimitropoulos · 3 years ago
that's a false equivocation in the sense that you just moved the goalposts by defining what "runtime" means.

There are no types whatsoever as far as processors are concerned. No types in assembly Not for Go or Java, not for C, and not for Rust. All you gotta do is keep compiling.

kaba0 · 3 years ago
To be honest, that’s the “default” way of type systems - without runtime reflection capabilities type erasure is just a normal phase of an AOT compiler, why would you store types?
hackandthink · 3 years ago
>If we could push JavaScript performance to be another order of magnitude faster

And it would speed up the TypeScript Compiler.

My bet is:

TypeScript typechecker in Rust:

https://github.com/dudykr/stc

epolanski · 3 years ago
TS is implementation-defined, it doesn't have a spec like C or Java.

It's simply impossible to keep up with TS for competing compilers.

iainmerrick · 3 years ago
One thing I wonder is whether a “strict mode” subset of TS could be compiled to efficient code. Disallow “any” and most of the dynamic and meta programming features of JS so it’s fully typesafe.

The type system is really nice, so even without being able to use the full range of JS hacks and escape hatches, I think it’d still be a nice language to work in.

awestroke · 3 years ago
TS by itself is not fully sound which could complicate such a compiler.

Example: https://www.typescriptlang.org/play?#code/MYewdgzgLgBAtgTwLI...

In the example above, the problem is that typescript allows casting function types to omit optional arguments, and also allows using a function with n arguments as a value where a function with >n arguments is expected

Deleted Comment

Deleted Comment

mekster · 3 years ago
If performance is the only concern to pick a language, world is far simpler.

Deleted Comment

mrits · 3 years ago
That is a strange take. It sounds like you think the reason people don't use Typescript is because of performance and not what some would consider a irresponsible ecosystem of abandoned frameworks and a language that provides little actual safety while still being unpleasant to use.
quonn · 3 years ago
It‘s not strange at all. I think them same. The type system of TypeScript is in practice much more useful than the one of C# or Java.

Nothing is abandoned and in any case typically only a small set of libraries is needed which should be carefully picked.

rr888 · 3 years ago
I agree TS is great. Not really multi threaded kills it for me though.
jdlshore · 3 years ago
Threads are a function of the environment, and are available in TS and other compiles-to-JS languages:

Node.js: https://nodejs.org/api/worker_threads.html

Browser: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers...

However, threads are very rarely needed. The common use case in other languages is I/O, and JS environments handle that with async I/O—a superior choice, IMO.

yanis_t · 3 years ago
Your regular reminder, that it’s just a regular release, since typescript don’t follow semver. After 4.9 goes 5.0
kypro · 3 years ago
Is there a reason for this? Why even have the decimal if 4.9 -> 5.0 is just as significant as 4.8 -> 4.9. Just make it v49 -> v50 and remove the ambiguity. What am I missing?
janaagaard · 3 years ago
One downside to having a version 4.10 is that some sorting algorithms put this release between 4.1 and 4.2 and not after 4.9.

But yeah, they should just go ahead and follow semver from now on.

hbn · 3 years ago
Why have decimals at all then? Just increment by whole numbers every release. It's the exact same thing except with the decimal moved over to a sensible place.
clarkdale · 3 years ago
From the release notes, it certainly seems minor / backwards compatible.

> 5.0 is not a disruptive release, and everything you know is still applicable. While TypeScript 5.0 includes correctness changes and some deprecations for infrequently-used options, we believe most developers will have an upgrade experience similar to previous releases.

brundolf · 3 years ago
It does have some backwards-incompatibilities, but they're mostly minor/edge-cases
swyx · 3 years ago
> How? There are a few notable improvements we’d like to give more details on in the future. But we won’t make you wait for that blog post.

the typescript project continues to set the bar extremely high in terms of changelog and clear communication. love you so much, drosenwasser and co!!

> Decorators are an upcoming ECMAScript feature that allow us to customize classes and their members in a reusable way.

huh. i thought this was a bit early to do this but i checked (https://github.com/tc39/proposal-decorators) and looks like they've moved to stage 3. curious how this is going to change library/api design in the long term.

deckard1 · 3 years ago
I don't think decorators being a proposal matters at this point. I know I've been using them for 5+ years now, and libraries such as NestJS already use them extensively.

If you like them, you're probably already drowning in them. Me, personally, I could take them or leave them.

madeofpalk · 3 years ago
NestJS uses the previous, incompatible decorators implementation IIRC.
dmix · 3 years ago
What do you use decorators for? I've never used them and I'm curious what the usecases are. The logging thing looks helpful.
swyx · 3 years ago
yeah also feel quite ambivalent about them. theyre opaque syntax sugar. dont provide enough value to me personally but i wont begrudge others
prmph · 3 years ago
I wish MS will fork Typescript into a new language altogether that transpiles to JS or compiles to WASM.

In that case, they can remove all JS weirdness from it, simplify it, add a proper standard library, and add other good parts from other (especially functional) languages to it.

My wish list for such a language (in addition to what is already in Typescript), in no particular order:

- Generic object literals (Why should generic type inference be limited to functions?)

- Deep support for an alternative to exceptions using a Failable<TResult, TError> type

- Localizable keywords (Why should programming languages be tools of cultural hegemony?)

- Dependent types, with no real distinction between values and types (At a certain point, Typescript’s type system begins to look like a separate Turing-complete language within a language. It’s probably time to do away with this dichotomy entirely somehow)

- Higher-kinded types (This is a pending issue in TS since 2014)

- JSX built-in without the need for any React-like dependency (No need to use it if you don’t like it; in the general sense, it’s just syntactic sugar for composing function invocations)

- No return necessary (the last expression in a block is returned). Thus every flow control construct _can_ (but does not have to) be an expression.

- No null, undefined, or any of all that, in favor of using a Maybe<T> type

- Proper decimal types (it’s shameful for a language to be without it now)

- A reasonably extensive standard library (Math, Stats, Collections (pull & push), String, Objects, Date/Time, Async, Functional, DOM, etc.)

That would be getting close to the perfect language for me.

modeless · 3 years ago
If you're breaking backwards compatibility then my number one request is replacing UTF-16 with UTF-8 for strings and nothing else comes close.
yencabulator · 3 years ago
You're asking Microsoft to undo a very Microsoft oddity that Microsoft seems to use just about everywhere. Good luck!
lmm · 3 years ago
> In that case, they can remove all JS weirdness from it, simplify it, add a proper standard library, and add other good parts from other (especially functional) languages to it.

Have you tried Scala.js? It's pretty much what you're asking for - a first-class functional language with all the things you'd expect from that, with compile-to-JS as something that works and feels fully first-class (and good integration with TypeScript types via ScalablyTyped).

prmph · 3 years ago
Scala.js seems interesting, and I will look into it more. But if it is so nice, why hasn't it taken off like TypeScript?
dmix · 3 years ago
> Deep support for an alternative to exceptions using a Failable<TResult, TError> type

Is there a good library for this currently?

I've been looking for one and a Maybe library. The Maybe one I use is pretty small.

halfmatthalfcat · 3 years ago
fp-ts (and most functional libraries) have a handy Either type just for this: https://gcanti.github.io/fp-ts/modules/Either.ts.html
ssalbdivad · 3 years ago
Massive release! `const` generic parameters in particular have been a god-send for our repo’s static inference (https://github.com/arktypeio/arktype) where previously we were forced to constantly rely on complex narrowing logic based on extends checks.

I look forward to the day when we support 5.0 as our minimum version and replace all of them with `const` generics for 1:1-inferred definitions like this:

const package = type({ name: "string", "version?": "number" })

Plus we’ll finally be able to remove the crazy hack we had to write to allow ts-morph to make type assertions on our codebase by transforming all of our `.ts` imports to `.js` in a virtual file system, which now that I think of it I’m probably looking forward to deleting even more XD

Great work, and looking forward to what comes next!

dimitropoulos · 3 years ago
100%! I have a package that I've been running on nightly just to get this.

Felt a bit like the wait for a const generics in Rust (except here, it didn't take long at all)!

com2kid · 3 years ago
Question, is there anything decorators can do that higher order functions and higher order classes cannot already accomplish?

I typically dislike decorators because they are spooky action at a distance, and whenever I look at code in a language that has decorators, the code almost becomes a DSL of sorts.

Not that HoF and HoC don't tend towards the same problems, React used to be famous for how often HoC got used in the ecosystem and the confusion that caused!

recursive · 3 years ago
"higher order class" is not a term I've heard before. I'm not sure what that could mean.

Decorators are syntactic sugar for higher ordered functions. They fundamentally have the same capability, just with better ergonomics.

zdragnar · 3 years ago
Functions can return new class definitions- the "class" keyword represents an expression, not a statement.

As such, you could write a function that takes in as an argument a class, and return a new class definition that extends the argument you provided... Or any number of other dubious practices.

com2kid · 3 years ago
Sorry, I meant a function that rips a class open, messes with it, and returns a new class!
seanalltogether · 3 years ago
My favorite usage for decorators in java is for defining http requests, it lets you write stuff like this

    @GET("/users/{id}")
    function loadUser(id: int): Promise<User> {}

    @PUT("/users/{id}")
    function updateUser(id: int, user: User): Promise<User> {}

topspin · 3 years ago
Can't fathom why annotation are used for this, except maybe as a holdover from years ago when Java didn't have certain language features. Other approaches in Java are much nicer and involve zero annotations. Example (from the Spark Java microframework documentation):

    path("/api", () -> {
        before("/*", (q, a) -> log.info("Received api call"));
        path("/email", () -> {
            post("/add",       EmailApi.addEmail);
            put("/change",     EmailApi.changeEmail);
            delete("/remove",  EmailApi.deleteEmail);
        });
        path("/username", () -> {
            post("/add",       UserApi.addUsername);
            put("/change",     UserApi.changeUsername);
            delete("/remove",  UserApi.deleteUsername);
        });
    });
All your endpoints concisely and composibly mapped out in code, and not smeared across dozens or hundreds of methods and classes. Not an annotation in sight; just plain old Java.

imbnwa · 3 years ago
Did't know Java had a `Promise` type
swatcoder · 3 years ago
> almost becomes a DSL of sorts

For mature projects with experienced, cohesive teams, that’s a good thing. You want a DSL that blends right in with your fully capable base language.

But yeah, just like with any powerful feature, people can get excited and carried away.

rcme · 3 years ago
I think some people want things to be DSL-like. However, I don’t think, long-term, using a DSL-like syntax wins. Ruby was famous for abusing Ruby’s unique syntax to make everything into a DSL and it turned off newcomers. Similarly, Java’s DI frameworks meet a lot of resistance because of their heavy use of annotations. Ultimately, DSLs are separate languages. Most people don’t want to learn a new language.
jdlshore · 3 years ago
The EcmaScript implementation of decorators is quite nice—it’s just syntactic sugar for a higher-order function call. Much better than the spooky reflection-based approach you see in some other languages.
super256 · 3 years ago
> I typically dislike decorators because they are spooky action at a distance, and whenever I look at code in a language that has decorators, the code almost becomes a DSL of sorts.

Yes, decorators are not evil by themselves, but they allow people to make poor choices easier. Having to debug decorators, fiddling with order of execution + scope binding/closures when setting multiple decorators, can (not sure!) become a nightmare; depending on the code base. Or we just go straight to the hibernate spaghetti. Imagining having to use three decorators with the same name, but different functions, makes me not to want to work with this.

Having worked with (old) Java EE and Jakarta code bases, I've seen decorators being abused in 300 ways and breaking ABI in 600 ways, so let's hope we stay sane this time.

ajkjk · 3 years ago
They're the same, but decorators encourage a programming style that is much easier to follow than HOF do. This way of using them is pretty standard in Python and it works well, imo.
spankalee · 3 years ago
Decorators enable metaprogramming over class fields. Nothing before them has done that.
epolanski · 3 years ago
The answer is obviously not since decorators still compile to higher order functions.
anthlax · 3 years ago
Yes - decorators are syntactically nicer :)