Files
test-repo/tests/format/misc/errors/js/optional-chaining/jsfmt.spec.js
T

22 lines
598 B
JavaScript

const { outdent } = require("outdent");
run_spec(
{
dirname: __dirname,
snippets: [
"const baz3 = new obj?.foo?.bar?.baz(); // baz instance",
"const safe5 = new obj?.qux?.baz(); // undefined",
"const safe6 = new obj?.foo.bar.qux?.(); // undefined",
"const willThrow = new obj?.foo.bar.qux(); // Error: not a constructor",
outdent`
// Top classes can be called directly, too.
class Test {
}
new Test?.(); // test instance
`,
"new exists?.(); // undefined",
],
},
["babel", "acorn", "espree", "meriyah"]
);