mooz / js2-mode

Improved JavaScript editing mode for GNU Emacs
GNU General Public License v3.0
1.32k stars 186 forks source link

advice for nullish-coalescing? (??) #560

Closed ArneBab closed 4 years ago

ArneBab commented 4 years ago

Is there a similarly easy advice to add support for the ?? as for private fields (https://github.com/mooz/js2-mode/issues/537)?

It is currently stage 4: https://github.com/tc39/proposal-nullish-coalescing

Short form:


const response = {
  settings: {
    nullValue: null,
    height: 400,
    animationDuration: 0,
    headerText: '',
    showSplashScreen: false
  }
};

const undefinedValue = response.settings.undefinedValue ?? 'some other default'; // result: 'some other default'
const nullValue = response.settings.nullValue ?? 'some other default'; // result: 'some other default'
const headerText = response.settings.headerText ?? 'Hello, world!'; // result: ''
const animationDuration = response.settings.animationDuration ?? 300; // result: 0
const showSplashScreen = response.settings.showSplashScreen ?? true; // result: false```
ArneBab commented 4 years ago

closed in favor of https://github.com/mooz/js2-mode/issues/559 (sorry)