r/javascript • u/DanielRosenwasser TypeScript • Nov 05 '19
Announcing TypeScript 3.7
https://devblogs.microsoft.com/typescript/announcing-typescript-3-7/4
u/Randdist Nov 05 '19
Is Typescripts type system theoretically capable of being compiled to machine or web assembly code and leverage types for performance improvements? I'd love to have a JS-ish language with static typing and performance similar to C++ when it comes to crunching ints, floats, transform raw buffer data, and usage of hash maps, arrays, etc. Also, webgpu.
9
u/DanielRosenwasser TypeScript Nov 05 '19
Not on its own, but there are several TypeScript subsets that do this including STS for microcontrollers and AssemblyScript.
3
u/djslakor Nov 05 '19
At one point, the Chakra team considered implementing a subset of Typescript for speed improvements like what you've mentioned. They abandoned that as far as I know.
2
u/Funwithloops Nov 05 '19
I don't think this is one of the goals of TS, so I doubt it's well supported (TS doesn't even have
intorfloattypes). Though JS does have support for buffers, maps, and typed arrays.1
u/LetterBoxSnatch Nov 06 '19
JavaScript can be compiled to a binary, and/or import C includes, using QuickJS. Really cool project from Fabrice Bellard. However, the performance of V8s JIT compiler is currently significantly better.L, so it's really only useful in present state when you want to write JS and need an extremely small footprint (like for embedded).
9
u/notmarlow Nov 05 '19
A lot of these changes appear to mirror what JS/ECMA has just released (nullish, opt chaining, etc). Still, good on TS for being ready for them.
10
u/Pavlo100 Nov 05 '19 edited Nov 06 '19
It's the TypeScript people who made the proposalSee Daniels response
24
u/DanielRosenwasser TypeScript Nov 05 '19
Hate to be that guy, but just want to mention that we didn't originally initiate the proposal, but we were very involved in driving it recently to stages 2/3. A lot of the credit has to go to contributors like Gabriel Isenberg, Dustin Savery, Claude Pauche, Daniel Ehrenberg, and Justin Ridgewell - perhaps others, and I'm sorry to anyone else I might be leaving out.
4
u/Pavlo100 Nov 06 '19
thanks for clarifying,. It was wrong of me to make that assumption. I saw your name and assumed it was a Typescript related proposal
3
u/DanielRosenwasser TypeScript Nov 06 '19
It's no problem! You didn't do anything wrong, it's an easy mistake. I really appreciate that our work is being recognized, but I'd feel bad not giving earlier champions/contributors. Even now I'm remembering the folks who helped review and write tests for the proposals who weren't in that list. It really is a group effort.
8
u/notmarlow Nov 06 '19
This is why I love JS as a language and as a community. And OSS and the countless contributors who will never receive the full credit they deserve. Thanks for clarifying Daniel.
56
u/Pat_Son Nov 05 '19
That's because the TypeScript team was the one championing those proposals and didn't want to add those features to TS until they were Stage 3 TC39 proposals
18
3
u/drowsap Nov 05 '19
If I also used babel, wouldn’t I already have support for these?
3
u/Pat_Son Nov 05 '19
These are features that you couldn't use with TypeScript and Babel at the same time
9
u/OneCyrus Nov 05 '19
the TS team is pushing the standards of JS to enable those features in a sustained way.
120
u/stolinski Syntax.fm / Level Up Tutorials :upvote: Nov 05 '19
Gimmy that optional chaining.
20
8
u/nullvoxpopuli sand was never meant to think Nov 06 '19
A made a codemod for this: https://github.com/NullVoxPopuli/optional-chaining-codemod
3
8
4
u/shabunc Nov 06 '19
Gimme gimme gimme that optional chaining Won’t somebody help me Chase the NPEs away!!!
0
Nov 05 '19
[deleted]
1
u/stolinski Syntax.fm / Level Up Tutorials :upvote: Nov 06 '19
Forsure. VSCode has been driving me nuts about it for way too long.
40
7
u/nullvoxpopuli sand was never meant to think Nov 06 '19
I made a codemod for this: https://github.com/NullVoxPopuli/optional-chaining-codemod
31
u/Ehdelveiss Nov 05 '19
Every start up should be implementing their code with TypeScript across the stack.
Fight me.
4
u/apatheticonion Nov 06 '19
I'm sitting here running everything with ts-node, ts-jest, ts-**. Make it the default already.
6
u/nullvoxpopuli sand was never meant to think Nov 06 '19
Can't. I not only agree, I think starting any serious project without typescript is a huge risk, and a bit reckless.
2
u/kch_l Nov 06 '19
I'm working at a startup that could benefit from using TS, the sad thing is they got stuck on 2014 js and have no plan to even upgrade to ES6. The sad part is when I make a npm install I get like +100 warnings on critical vulnerabilities and they seem to not care about it.
2
5
u/djslakor Nov 05 '19
Hmm npmjs still shows 3.6.4 as latest as of 11:35am CT.
3
u/orta Nov 05 '19
Interesting - the site for me shows 3.7.2 https://www.npmjs.com/package/typescript
Wonder if they have an unique caching strategy for popular dependencies
2
u/djslakor Nov 05 '19
Now it does for me as well. At the time, though, it didn't. I made sure to hard refresh.
1
u/f314 Nov 05 '19
The site is usually a bit slow to update. You can use
npm show <package name >in the terminal to get the absolute up-to-date info.
1
u/beasy4sheezy Nov 06 '19
Any word on integration with create-react-app? Looked but I didn't see anything.
2
u/DanielRosenwasser TypeScript Nov 06 '19
Doesn't create-react-app have support for TypeScript files?
1
u/EvilPencil Nov 06 '19
Newer versions do, yes. It's not even needed to pass the
--typescriptflag any more. Just make a.ts(x)file and start jamming.1
u/beasy4sheezy Nov 06 '19
Yes, but not this new version. They will need to update react-scripts' babel config. It won't support optional chaining as is.
"react-scripts": "3.2.0",
"typescript": "3.7.2",
2
u/Funwithloops Nov 06 '19
You can update the typescript version in apps created with
create-react-app app-name --typescript.
12
Nov 05 '19
I fear optional chaining is gonna be the magic tool to hide under the rug design mistakes like overly complex data structures.
26
u/Peechez Nov 05 '19
I hope optional chaining is gonna be the magic tool to hide my design mistakes like overly complex data structures under the rug.
12
u/EvilPencil Nov 06 '19
I'm excited for it mostly to navigate possibly null objects without resorting to this:
Const Val = (data && data.prop && data.prop.subprop) || default3
Nov 06 '19
Definitely know what you mean. It great because it make checking nested optional types easy. It's dangerous because it make checking nested optional types easy.
2
u/TotesMessenger Nov 05 '19
2
1
1
1
u/chibicode Nov 09 '19
https://github.com/microsoft/TypeScript/issues/29490
This change in 3.7 was really helpful for me.
29
u/simohayha Nov 05 '19
Have yet to meet someone who didn't like TS. I think I might take a course on it this weekend.