Transpiles optional chaining just like tsc do
a?.b?.c // works in tsc, but fails in ts-loader
Getting an error "You may need an additional loader to handle the result of these loaders."
ts-loader uses whatever comes out of tsc - I'd be surprised if tsc isn't supporting optional chaining via the APIs.... š¤
cc @andrewbranch @sheetalkamat does this ring any bells?
What is target set to in your tsconfig?
What is
targetset to in your tsconfig?
My target is esnext, should I change it on somthing different?
Well, I've changed target to es2018 and it works just fine! Thank you!
Can anybody explain what the difference between targets: esnext and es2020 if at this moment it's the same?
esnext is a moving target. In the year 2030, es2020 will be old hat but esnext will always contain the latest and greatest features yet to make it into the ECMAScript spec, like perhaps syntax primitives for quantum computing operations, or my upcoming āincredulous chainingā operator proposal, whatā½.inā½.theā½.worldā½.isā½.that.
In other words, esnext is always an alias to the latest spec version, and we continue to move it forward every year.
@andrewbranch ok, just as I suspected. But how this affects to ts-loader? I mean why target esnext is causing an error

but target es2020 not because esnext are equivalent of es2020 at current moment?
UPD: or it is not ts-loader error?
Sorry, I actually misremembered this. esnext and latest are aliases for each other, but es2020 is actually already a set value:

I think I've spotted the next Y2K bug in that enum š
"We've only got 92 years of TypeScript left!"
Well fortunately TypeScript enums support non-integer number values, although Iām definitely going to spend the next 92 years looking forward to when we have to do safe floating point comparisons throughout the compiler whenever we look at target š
I think somebody should make an issue in Typescript repo to prevent this bug š
So is it possible use ts-loader with esnext?
ts-loader has no problem with esnext. The problem youāre seeing is that Webpack itself canāt statically analyze the output JavaScript because _it_ doesnāt understand ?. and ?? yet. This is a good thing, because _browsers_ also do not understand ?. and ?? yet, so Webpack is saving you from shipping unsupported code to your users.
Oh, thank you Andrew!
Most helpful comment
I think I've spotted the next Y2K bug in that enum š
"We've only got 92 years of TypeScript left!"