main
ts 24 lines 637 Bytes
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 import * as t from '@babel/types';
9
10 export type HookDeclaration = t.FunctionDeclaration & {
11 __hookDeclaration: boolean;
12 };
13
14 export function isHookDeclaration(
15 node: t.FunctionDeclaration,
16 ): node is HookDeclaration {
17 return Object.prototype.hasOwnProperty.call(node, '__hookDeclaration');
18 }
19
20 export function parseHookDeclaration(
21 node: t.FunctionDeclaration,
22 ): HookDeclaration | null {
23 return isHookDeclaration(node) ? node : null;
24 }