Consider TSNonNullExpression part of member chain (#3442)

master
Lucas Duailibe 2017-12-10 02:41:53 -02:00 committed by GitHub
parent c9079926c9
commit 69f05e42c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -403,7 +403,8 @@ function genericPrintNoParens(path, options, print, args) {
i++;
} while (
firstNonMemberParent &&
firstNonMemberParent.type === "MemberExpression"
(firstNonMemberParent.type === "MemberExpression" ||
firstNonMemberParent.type === "TSNonNullExpression")
);
const shouldInline =

View File

@ -1,5 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`member-chain.js 1`] = `
const { somePropThatHasAReallyLongName, anotherPropThatHasALongName } = this.props.imReallySureAboutThis!;
const { somePropThatHasAReallyLongName, anotherPropThatHasALongName } = this.props.imReallySureAboutThis!.anotherObject;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const {
somePropThatHasAReallyLongName,
anotherPropThatHasALongName
} = this.props.imReallySureAboutThis!;
const {
somePropThatHasAReallyLongName,
anotherPropThatHasALongName
} = this.props.imReallySureAboutThis!.anotherObject;
`;
exports[`parens.ts 1`] = `
(a ? b : c) ![tokenKey];
(a || b) ![tokenKey];

View File

@ -0,0 +1,3 @@
const { somePropThatHasAReallyLongName, anotherPropThatHasALongName } = this.props.imReallySureAboutThis!;
const { somePropThatHasAReallyLongName, anotherPropThatHasALongName } = this.props.imReallySureAboutThis!.anotherObject;