Skip to content

Commit

Permalink
Add optional chain assignment to stage 1 preset (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
CanadaHonk committed Aug 1, 2023
1 parent d7cc6cc commit ba8dd37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/babel-standalone/src/preset-stage-1.ts
Expand Up @@ -33,6 +33,7 @@ export default (_: any, opts: any = {}) => {
babelPlugins.syntaxDecimal,
babelPlugins.proposalExportDefaultFrom,
babelPlugins.proposalDoExpressions,
babelPlugins.optionalChainingAssign
],
};
};
6 changes: 6 additions & 0 deletions packages/babel-standalone/test/preset-stage-1.test.js
Expand Up @@ -78,4 +78,10 @@ describe("stage-1 preset", () => {
}).code;
expect(output).toMatchInlineSnapshot(`"Tuple(Record({}));"`);
});
it("should support optional chaining assignment", () => {
const output = Babel.transform("expr1?.prop = val", {
presets: [["stage-1", { decoratorsVersion: "2021-12" }]],
}).code;
expect(output).toMatchInlineSnapshot(`"expr1 == null ? undefined : expr1.prop = val;"`);
});
});

0 comments on commit ba8dd37

Please sign in to comment.