DEV Community

Cover image for How TypeScript 3.7 Helps Quality

How TypeScript 3.7 Helps Quality

Matt Eland on November 07, 2019

In this article I’ll go over a few key highlights from the recent release of TypeScript 3.7. I’ll be looking at things through the lens of how they...
Collapse
 
ap13p profile image
Afief S

Does "Uncalled function check" has wrong screenshot? Because the screenshot show "declare" error instead of uncalled function check

Collapse
 
integerman profile image
Matt Eland

Yeah... I think I cropped it to the wrong error. It should have read: This condition will always return true since the function is always defined. Did you mean to call it instead?

I've made the edit.

I feel shame. Don't publish tired.

Collapse
 
kpulkit29 profile image
Pulkit Kashyap

I think some of the examples are not in the right order. Nice otherwise :)

Collapse
 
integerman profile image
Matt Eland

As in you'd like to see the functions reordered within the gists for readability?

Collapse
 
kpulkit29 profile image
Pulkit Kashyap

Ya kind of

Collapse
 
psalaun profile image
Pierre Salaün • Edited

The gists don’t seem to be in the right order, as some of them don’t match the text surrounding them.

Collapse
 
boredcity profile image
boredcity

example for Nullish Coalescing doesn't really seem to explain why it's useful: "old way" would just be var calculator = someCalculator || new Calculator();

Collapse
 
davinc profile image
Danijel Vincijanović • Edited

I was also wondering what's the difference between those two and I've found it. Nullish Coalescing better handles cases when it comes to truthy/falsy values.

For example:

const a = 0
const b = a || 100

console.log(b) // 100

Same thing, but different result with Nullish Coalescing:

const a = 0
const b = a ?? 100

console.log(b) // 0
Collapse
 
integerman profile image
Matt Eland

I personally hate the use of the || operator in this context, but that's mostly because my background is a C# one where I read the operator and think that b would be assigned to true since a and 100 would both be evaluated as booleans.

Obviously they wouldn't, but to me ?? is way more intuitive than the use of || in this context.

Collapse
 
boredcity profile image
boredcity

I thought I remembered something like this being the edge case where this was useful... Thank you, this seems like a better example!

Collapse
 
n4bb12 profile image
Abraham Schilling

Yessss I've been waiting for Optional Chaining and Nullish Coalescing so hard, thanks for writing this up and appearing on my newsfeed 🙌

Collapse
 
integerman profile image
Matt Eland

I know. Almost every merge request I review in the JavaScript / TypeScript world I wish the committer had access to optional chaining.

Collapse
 
bnaya profile image
Bnaya Peretz

The decalre keyword is not really a feature, but compatebility option with es class members
devblogs.microsoft.com/typescript/...

Collapse
 
macsikora profile image
Pragmatic Maciej • Edited

Some more details about why optional chaining is not so perfect thing
dev.to/macsikora/what-is-wrong-wit...