BundlerMinifier icon indicating copy to clipboard operation
BundlerMinifier copied to clipboard

Using the JS nullish coalescing operator (??) generates an object reference not set to an instance of an object error.

Open AndradeAlbuquerque opened this issue 3 years ago • 4 comments

Installed product versions

  • Visual Studio: 2019 Community Edition (16.9.4)
  • Bundler & Minifier version: 2.8.396

Description

It seems it is not possible to Bundle & Minify javascript files containing the nullish coalescing operator ('??') because it generates the error "(Bundler & Minifier) Object reference not set to an instance of an object."

Steps to recreate

  1. Create a js file
  2. Create some function with: let otherurl = null; let userOptions = { parameter1: 'this is my parameter 1' }; let options = { url: otherurl ?? '/myurl', parameter: userOptions?.parameter1 ?? '' };
  3. When Bundle & Minification the "(Bundler & Minifier) Object reference not set to an instance of an object." is shown in Error List and no minified file is generated.

AndradeAlbuquerque avatar Apr 23 '21 13:04 AndradeAlbuquerque

The same happens when using the elvis operator i.e., optional chaining (?.)

msschl avatar May 07 '21 14:05 msschl

I am having the same issue, and worked around it by using old-school null handling for now, but it would be great to know if this is something that might be resolved, as I'm in the process of moving all my bundling over to use this extension.

bronthulke avatar Jun 17 '21 07:06 bronthulke

Still doesn't work 1y later

m1dst avatar Apr 19 '22 10:04 m1dst

I am also trying optional chaining operator ('?.') and arrow functions ('() => {}') but getting a syntax error on compile to a bundle. Still now fixed so will have to revert to old JavaScript syntax.

Lucidize avatar Nov 27 '23 10:11 Lucidize