Live data from Hacker News

Announcing TypeScript 2.2

blogs.msdn.microsoft.com

81–90 of 123 posts

Re: Announcing TypeScript 2.2

#81

I know this probably comes up each typescript thread, but I still cannot figure out why I should use TS instead of flow + es6, and maintaining the typing definitions always discourages me as it's one more thing that needs to be kept up to date. Am I working on old information here?

I'm not sure this answers your question, but: I've been working with TS for the past couple of years but now I'm working on a Flow project. Flow doesn't even compare. It falls short on many things TS would immediately flag, and just feels less thought-out (subjective I know). Tooling support is terrible and while not the language's fault, it means it just doesn't help you as much as it could. Using Flow basically bec…

> It falls short on many things TS would immediately flag

I'm kind of curious what you've run into personally. Having a dependency without any type-defs get silently treated as `any` is my own beef, but I haven't hit much else yet.

(Some type-defs' use for `any` also gets my goat, such as Promise's catch argument and some of the lodash functions, but I'm considering that a separate thing.)

> And honestly, some of the decisions around the language just feel strange. Not knowing what kind of bool to use [0] is pretty emblematic of where it is going as a language.

This is more an existing JS weirdness (`true`/`false` vs `Boolean()`); Flow doesn't mess with runtime semantics, only adding a layer that you check with then strip out.

And TypeScript has the same thing:

  var a: boolean = new Boolean(1);
  
  // Produces:
  // NewTypering.ts(29,5): error TS2322: Type 'Boolean' is not assignable to type 'boolean'.

Re: Announcing TypeScript 2.2

#82
post #47

Earlier quoted context omitted.

One reason flow might be considered "better" (context is key) is that it plays well with the babel ecosystem, letting one pick and choose their language features.

Picking and choosing language features via babel plugins (many of which will never become part of JavaScript) is an anti-feature. You essentially are creating your own language that only you understand.

We don't support custom syntax that isn't already a proposal (meaning it has potential to be in JS), and we also encourage using presets like https://github.com/babel/babel-preset-env instead of providing your own configuration of plugins unless you are more of a power user.

It's our intention as a tool to align with TC39 and transition users to using native JS when it's supported

Re: Announcing TypeScript 2.2

#83
post #27
post #24

Earlier quoted context omitted.

Why would flow + es6 be better?

Avoid vendor locking. Someday in near future if you don't like flow anymore, you can just strip all type annotations with Babel and move on. You are not risking ending up like coffeescript.

FYI we do have an issue open about TS https://github.com/babel/babylon/issues/320 so that we could eventually support TS in Babel as a plugin and then create the same strip-types-plugin just like Flow.

Re: Announcing TypeScript 2.2

#84

I know this probably comes up each typescript thread, but I still cannot figure out why I should use TS instead of flow + es6, and maintaining the typing definitions always discourages me as it's one more thing that needs to be kept up to date. Am I working on old information here?

Talking about flow, I was wondering: couldn't something like that be implemented just with comments, leaving us with actually 100% valid javascript? Eg: // @param somestring [String] yadda yadda // @return [Boolean] function somefunction(somestring) { // @type [Boolean] var ret; ... return ret; } This would remove any type of "lock in" if you want to use it...

Flow actually explicitly allows this[1] by just /* */ commenting out the flow type signatures. We use this in Aphrodite's code base[2] and it works pretty well.

[1]: https://flowtype.org/blog/2015/02/20/Flow-Comments.html

[2]: https://github.com/Khan/aphrodite/blob/master/src/generate.j...

Re: Announcing TypeScript 2.2

#85
post #77

Earlier quoted context omitted.

Talking about flow, I was wondering: couldn't something like that be implemented just with comments, leaving us with actually 100% valid javascript? Eg: // @param somestring [String] yadda yadda // @return [Boolean] function somefunction(somestring) { // @type [Boolean] var ret; ... return ret; } This would remove any type of "lock in" if you want to use it...

I'd prefer that approach too, as I can also document things at the same time as providing type annotations; flow-jsdoc looks interesting, but I don't know how easy it would be to plug into a Babel/Webpack+Babel workflow: https://github.com/Kegsay/flow-jsdoc

There's also comments support in Flow directly, but it's sadly (but understandably) hideous:

  function somefunction(somestring/*: string*/)/*: boolean */ {
     var ret/*: boolean */;
     ...
     return ret;
  }
(See https://flowtype.org/blog/2015/02/20/Flow-Comments.html)

Re: Announcing TypeScript 2.2

#86
post #75

Earlier quoted context omitted.

Why do you want turn avoid Visual Studio out of curiosity? It's pretty great now.

I was about to say "Visual Studio doesn't work in Linux," but apparently it (or at least Visual Studio Code) actually does now. Living in the future is weird.

When did VSCode not work for linux???? I'm confused...

Re: Announcing TypeScript 2.2

#87
post #49
post #42

Earlier quoted context omitted.

For passersby who were confused like I was: IntelliJ Community Edition has absolutely no support for Javascript or Typescript, which is not noted clearly in the help docs. You apparently need Ultimate Edition to get it. I was real excited that I could finally use the same IDE for front-end and back-end too... :/

The price gets lower each year for the first few years you renew your license. My company pays for my license but I think it's hella worth it and I'd pay it on my own if I had to. I avoid VS like the plague and I've never really felt at home in an IDE until I started using IntelliJ. It's the only thing that was able to get me off of Notepad++

Like other replies said, VS Code is nothing like VS.

I've been a dedicated Sublime Text user for years (wary of IDEs like you) but VS code kicks ST2/3's butt for Typescript development.

Re: Announcing TypeScript 2.2

#88
post #75
post #13

Speaking of tooling -- has anyone had a good experience with Typescript in IntelliJ/Webstorm? It does a fantastic job figuring out ES6 code but seems to totally choke on Typescript. I'd like to avoid switching to Visual Studio.

Why do you want turn avoid Visual Studio out of curiosity? It's pretty great now.

Team's standardized on IntelliJ so everyone already has Ultimate. It works great for everything not-Typescript.

Re: Announcing TypeScript 2.2

#89

Earlier quoted context omitted.

I'm not sure this answers your question, but: I've been working with TS for the past couple of years but now I'm working on a Flow project. Flow doesn't even compare. It falls short on many things TS would immediately flag, and just feels less thought-out (subjective I know). Tooling support is terrible and while not the language's fault, it means it just doesn't help you as much as it could. Using Flow basically bec…

> It falls short on many things TS would immediately flag I'm kind of curious what you've run into personally. Having a dependency without any type-defs get silently treated as `any` is my own beef, but I haven't hit much else yet. (Some type-defs' use for `any` also gets my goat, such as Promise's catch argument and some of the lodash functions, but I'm considering that a separate thing.) ​ > And honestly, some of t…

TypeScript's full error message on that last one is actually

  Type 'Boolean' is not assignable to type 'boolean'.
    'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible.

Re: Announcing TypeScript 2.2

#90
post #13

Speaking of tooling -- has anyone had a good experience with Typescript in IntelliJ/Webstorm? It does a fantastic job figuring out ES6 code but seems to totally choke on Typescript. I'd like to avoid switching to Visual Studio.

My proposition is out of the box but maybe get a chance to VSCode?

In my team we used to be splitted between sublime/webstorm/atom, now we all are pretty happy with VS Code for typescript and javascript.
Post reply on HN