Problem
[email protected]:
const x = a ? b ? c : void 0 : null;
If a is false, x === null, but if a is true and b is false, x === undefined; this is inconsistent with the defined behavior of IfExpressions which is to produce null when the alternate is omitted.
Cause
This:
https://github.com/lightscript/babel-plugin-lightscript/blob/eb650acf69a17f0e4af9ce10a4c1bdeacec1e9e7/src/index.js#L504
which leads to this:
https://github.com/babel/babel/blob/1e55653ac173c3a59f403a7b5269cf6d143d32d9/packages/babel-traverse/src/path/replacement.js#L195
which leads to this:
https://github.com/babel/babel/blob/master/packages/babel-types/src/converters.js#L47
Babel's algorithm for converting statements to expressions produces undefined by default.
Resolution
It is probably necessary to recapitulate this algorithm inside the lsc transform and make sure it makes nulls here.
Problem
[email protected]:If
ais false,x === null, but ifais true andbis false,x === undefined; this is inconsistent with the defined behavior ofIfExpressions which is to producenullwhen the alternate is omitted.Cause
This:
https://github.com/lightscript/babel-plugin-lightscript/blob/eb650acf69a17f0e4af9ce10a4c1bdeacec1e9e7/src/index.js#L504
which leads to this:
https://github.com/babel/babel/blob/1e55653ac173c3a59f403a7b5269cf6d143d32d9/packages/babel-traverse/src/path/replacement.js#L195
which leads to this:
https://github.com/babel/babel/blob/master/packages/babel-types/src/converters.js#L47
Babel's algorithm for converting statements to expressions produces
undefinedby default.Resolution
It is probably necessary to recapitulate this algorithm inside the lsc transform and make sure it makes
nulls here.