Add support for the optional chaining operator (babel/babel-eslint#630)
This commit is contained in:
parent
735abb06b4
commit
3477626973
@ -233,6 +233,10 @@ function monkeypatch(modules) {
|
||||
// visit ClassPrivateProperty as a Property.
|
||||
referencer.prototype.ClassPrivateProperty = visitClassProperty;
|
||||
|
||||
// visit OptionalMemberExpression as a MemberExpression.
|
||||
referencer.prototype.OptionalMemberExpression =
|
||||
referencer.prototype.MemberExpression;
|
||||
|
||||
// visit flow type in FunctionDeclaration, FunctionExpression, ArrowFunctionExpression
|
||||
var visitFunction = referencer.prototype.visitFunction;
|
||||
referencer.prototype.visitFunction = function(node) {
|
||||
|
||||
@ -1651,6 +1651,18 @@ describe("verify", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("optional chaining operator", () => {
|
||||
it("should not be undefined #595", () => {
|
||||
verifyAndAssertMessages(
|
||||
`
|
||||
const foo = {};
|
||||
foo?.bar;
|
||||
`,
|
||||
{ "no-undef": 1 }
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("flow types on class method should be visited correctly", () => {
|
||||
verifyAndAssertMessages(
|
||||
`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user