Fix(typescript) non-null identifier same line in chain (#4052)

master
Eric Anderson 2018-02-26 13:12:03 -05:00 committed by Lucas Duailibe
parent 65b988a989
commit efd5bde713
3 changed files with 10 additions and 0 deletions

View File

@ -4006,6 +4006,7 @@ function printMemberChain(path, options, print) {
let i = 1;
for (; i < printedNodes.length; ++i) {
if (
printedNodes[i].node.type === "TSNonNullExpression" ||
printedNodes[i].node.type === "CallExpression" ||
(printedNodes[i].node.type === "MemberExpression" &&
printedNodes[i].node.computed &&

View File

@ -6,6 +6,8 @@ const { somePropThatHasAReallyLongName, anotherPropThatHasALongName } = this.pro
const { somePropThatHasAReallyLongName, anotherPropThatHasALongName } = this.props.imReallySureAboutThis!.anotherObject;
this.foo.get("bar")!.doThings().more();
foo!.bar().baz().what();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const {
somePropThatHasAReallyLongName,
@ -22,6 +24,11 @@ this.foo
.doThings()
.more();
foo!
.bar()
.baz()
.what();
`;
exports[`parens.ts 1`] = `

View File

@ -3,3 +3,5 @@ const { somePropThatHasAReallyLongName, anotherPropThatHasALongName } = this.pro
const { somePropThatHasAReallyLongName, anotherPropThatHasALongName } = this.props.imReallySureAboutThis!.anotherObject;
this.foo.get("bar")!.doThings().more();
foo!.bar().baz().what();