Add ASI protection for TSNonNullExpression (#5262)

master
Lucas Duailibe 2018-10-13 20:03:51 -03:00 committed by GitHub
parent dd4687e7ef
commit c7093cb3e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 1 deletions

View File

@ -5461,7 +5461,8 @@ function hasNakedLeftSide(node) {
node.type === "SequenceExpression" ||
node.type === "TaggedTemplateExpression" ||
node.type === "BindExpression" ||
(node.type === "UpdateExpression" && !node.prefix)
(node.type === "UpdateExpression" && !node.prefix) ||
node.type === "TSNonNullExpression"
);
}

View File

@ -49,3 +49,25 @@ class A {
}
`;
exports[`non-null.ts - typescript-verify 1`] = `
// the 2nd line needs ASI protection
const el = ReactDOM.findDOMNode(ref)
;(el as HTMLElement)!.style.cursor = 'pointer'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// the 2nd line needs ASI protection
const el = ReactDOM.findDOMNode(ref);
(el as HTMLElement)!.style.cursor = "pointer";
`;
exports[`non-null.ts - typescript-verify 2`] = `
// the 2nd line needs ASI protection
const el = ReactDOM.findDOMNode(ref)
;(el as HTMLElement)!.style.cursor = 'pointer'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// the 2nd line needs ASI protection
const el = ReactDOM.findDOMNode(ref)
;(el as HTMLElement)!.style.cursor = "pointer"
`;

View File

@ -0,0 +1,3 @@
// the 2nd line needs ASI protection
const el = ReactDOM.findDOMNode(ref)
;(el as HTMLElement)!.style.cursor = 'pointer'