@@ -243,30 +243,29 @@ function isAngularTestWrapper(node) {
243243
244244const isJsxElement = createTypeCheckFunction ( [ "JSXElement" , "JSXFragment" ] ) ;
245245
246- function isGetterOrSetter ( node ) {
247- return node . kind === "get" || node . kind === "set" ;
248- }
249-
250- // TODO: This is a bad hack and we need a better way to distinguish between
251- // arrow functions and otherwise
252- function isFunctionNotation ( node ) {
253- return isGetterOrSetter ( node ) || hasSameLocStart ( node , node . value ) ;
246+ function isMethod ( node ) {
247+ return (
248+ ( node . method && node . kind === "init" ) ||
249+ node . kind === "get" ||
250+ node . kind === "set"
251+ ) ;
254252}
255253
256- // Hack to differentiate between the following two which have the same ast
257- // type T = { method: () => void };
258- // type T = { method(): void };
259254/**
260255 * @param {Node } node
261256 * @returns {boolean }
262257 */
263- function isObjectTypePropertyAFunction ( node ) {
258+ function isFlowObjectTypePropertyAFunction ( node ) {
264259 return (
265260 ( node . type === "ObjectTypeProperty" ||
266261 node . type === "ObjectTypeInternalSlot" ) &&
267- node . value . type === "FunctionTypeAnnotation" &&
268262 ! node . static &&
269- ! isFunctionNotation ( node )
263+ ! node . method &&
264+ // @ts -expect-error -- exists on `ObjectTypeProperty` but not `ObjectTypeInternalSlot`
265+ node . kind !== "get" &&
266+ // @ts -expect-error -- exists on `ObjectTypeProperty` but not `ObjectTypeInternalSlot`
267+ node . kind !== "set" &&
268+ node . value . type === "FunctionTypeAnnotation"
270269 ) ;
271270}
272271
@@ -1193,7 +1192,7 @@ function isObjectProperty(node) {
11931192 return (
11941193 node &&
11951194 ( node . type === "ObjectProperty" ||
1196- ( node . type === "Property" && ! node . method && node . kind === "init" ) )
1195+ ( node . type === "Property" && ! isMethod ( node ) ) )
11971196 ) ;
11981197}
11991198
@@ -1241,10 +1240,9 @@ export {
12411240 isCallExpression ,
12421241 isCallLikeExpression ,
12431242 isExportDeclaration ,
1243+ isFlowObjectTypePropertyAFunction ,
12441244 isFunctionCompositionArgs ,
1245- isFunctionNotation ,
12461245 isFunctionOrArrowExpression ,
1247- isGetterOrSetter ,
12481246 isIntersectionType ,
12491247 isJsxElement ,
12501248 isLineComment ,
@@ -1253,12 +1251,12 @@ export {
12531251 isLongCurriedCallExpression ,
12541252 isMemberExpression ,
12551253 isMemberish ,
1254+ isMethod ,
12561255 isNextLineEmpty ,
12571256 isNumericLiteral ,
12581257 isObjectOrRecordExpression ,
12591258 isObjectProperty ,
12601259 isObjectType ,
1261- isObjectTypePropertyAFunction ,
12621260 isPrettierIgnoreComment ,
12631261 isRegExpLiteral ,
12641262 isSignedNumericLiteral ,
0 commit comments