Live data from Hacker News

Announcing TypeScript 2.2

blogs.msdn.microsoft.com

71–80 of 123 posts

Re: Announcing TypeScript 2.2

#71
post #57

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've done some average sized projects in Flow and in TypeScript, and it's a lot more subtle IMO than most people would have it (especially people who only tried one, or only tried both cursively) TypeScript absolutely has the better tooling. It's not even -close-. It's a little tricky though because a lot of FE devs these days use VIM or Sublime with a few plugins and a linter running in a terminal is as far as it go…

> TypeScript's type definitions I found are very, very poor, as a relic of the days where versioning was an issue and many have not been fixed.

I've always found it funny that DefinitelyTyped's tag line is "The repository for high quality TypeScript type definitions", but it's an absolutely disastrous system. If it's not a well-used library, definitions there will be woefully out of date. Versioning is a huge issue with it, so it's hard to figure out what definitions actually match the version library you're using. I can only admit that it's an effort that's better than nothing.

The few projects I added types to, the original project owners gladly accepted them into their main repos, which is great since types will "just work" without fuddling with @types packages.

Re: Announcing TypeScript 2.2

#72
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.

If you're afraid of vendor lock-in, but fine with comments then you can just put all of your typing information in jsdoc comments.

https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-i...

Re: Announcing TypeScript 2.2

#73
post #64

Earlier quoted context omitted.

TypeScript type inference is minimal though and doesn't go very far. It falls back to "any" very quickly (and if you use the noImplicitAny option, then you have to type almost everything). It does a decent enough job at return types, but not a whole lot beyond that.

Do you have a use case where something would be correctly inferred in Flow but not in TS?

The classic example is:

  function double(x) {
    return x * 2;
  }
  const result = double("foo");
Which passes in TS, but fails in Flow. In TS, the 'x' parameter to the double function is inferred as Any.

Re: Announcing TypeScript 2.2

#74

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...

Re: Announcing TypeScript 2.2

#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.

Re: Announcing TypeScript 2.2

#76
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.

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.

Re: Announcing TypeScript 2.2

#77

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...

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

Re: Announcing TypeScript 2.2

#78
post #48

Earlier quoted context omitted.

Yeah, I personally don't mess around with Babel but I imagine you could just take TypeScript's ES6 output and feed it through babel in your gulp/webpack pipeline.

Yeah, that's what I use with Webpack. It's just one more rule on Webpack config, so no reason not to do it. There's many things that are out of scope of TS that are better handled by Babel (like embedding corejs methods based on target browser versions).

If you're using Webpack is it possible to gradually opt files into TS type checking _without_ having to rename them, since you can specify which filename patterns loaders apply to?

Re: Announcing TypeScript 2.2

#79
post #42
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.

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... :/

It's a bit of an investment if you're still a student, but if you're working full time as a programmer, the JetBrains IDEs are the highest bang for your buck.

Beyond the basic functionality working, the paid versions have a lot of cross-langauge support (PyCharm gets a huge chunk of the JetStorm functionality) which means that autocomplete "just works".

Like when I'm writing Angular templates, it looks up my custom directives and provides autocomplete on that. It is able to give autocomplete inside Angular expressions (down to looking up the controller and providing type information if you're using Typescript) inside my Django templates.

It's a lot of fuzzy searching but they have very good heuristics.

I think it would be near-impossible to get this cross-language support in Atom/Emacs, if only because it requires the I in IDE. Totally worth it.

Re: Announcing TypeScript 2.2

#80
post #79
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... :/

It's a bit of an investment if you're still a student, but if you're working full time as a programmer, the JetBrains IDEs are the highest bang for your buck. Beyond the basic functionality working, the paid versions have a lot of cross-langauge support (PyCharm gets a huge chunk of the JetStorm functionality) which means that autocomplete "just works". Like when I'm writing Angular templates, it looks up my custom d…

> It's a bit of an investment if you're still a student

They have free licenses for students that includes all their products and a discount when you graduate. If you're making money off it, the license cost for intellij or just webstorm is pretty cheap.

https://www.jetbrains.com/student/

Post reply on HN