Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider TSNonNullExpression part of member chain #3442

Merged
merged 1 commit into from
Dec 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ function genericPrintNoParens(path, options, print, args) {
i++;
} while (
firstNonMemberParent &&
firstNonMemberParent.type === "MemberExpression"
(firstNonMemberParent.type === "MemberExpression" ||
firstNonMemberParent.type === "TSNonNullExpression")
);

const shouldInline =
Expand Down
17 changes: 17 additions & 0 deletions tests/typescript_non_null/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
@@ -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];
Expand Down
3 changes: 3 additions & 0 deletions tests/typescript_non_null/member-chain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const { somePropThatHasAReallyLongName, anotherPropThatHasALongName } = this.props.imReallySureAboutThis!;

const { somePropThatHasAReallyLongName, anotherPropThatHasALongName } = this.props.imReallySureAboutThis!.anotherObject;