typescript: remove unneeded parentheses around type annotation (#5724)
* Remove unnecessary parentheses from annotations * add test for ts parentheses bugmaster
parent
14730106db
commit
30979ed104
|
@ -339,7 +339,6 @@ function needsParens(path, options) {
|
|||
parent.type === "GenericTypeAnnotation" ||
|
||||
parent.type === "TSTypeReference") &&
|
||||
(node.typeAnnotation.type === "TSTypeAnnotation" &&
|
||||
node.typeAnnotation.typeAnnotation.type !== "TSFunctionType" &&
|
||||
grandParent.type !== "TSTypeOperator" &&
|
||||
grandParent.type !== "TSOptionalType")
|
||||
) {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class Foo {
|
||||
bar: (() => boolean);
|
||||
}
|
|
@ -1,5 +1,22 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`TSFunctionTypeNoUnnecessaryParentheses.ts 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
class Foo {
|
||||
bar: (() => boolean);
|
||||
}
|
||||
=====================================output=====================================
|
||||
class Foo {
|
||||
bar: () => boolean;
|
||||
}
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`functionImplementationErrors.ts 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["typescript"]
|
||||
|
|
Loading…
Reference in New Issue