Comment

Comment by ravenstine

I'd be more optimistic about official type annotations for JavaScript if said typing was less like the particularly unique syntax of TypeScript and more like that which already exists in C-family languages. For instance, in Typescript, we can do this:

---

const user: User = {

  ...
};

---

Why couldn't this be more like C rather than this weird conflation with the existing colon token?

---

const User user = {

  ...
};

---

That might seem not as pleasing to those familiar with Typescript, but it's much closer to other existing syntaxes (meaning less of a learning curve coming from Java or C).

Same with function definitions:

---

function foo (bar: string, baz: boolean): Qux {

  ...
}

---

Versus:

---

Qux function foo (string bar, bool baz) {

  ...
}

---

I find the latter much more familiar than Typescript and less confusing. It's also slightly less verbose.

parent ravenstine 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton