main
ts 24 lines 677 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 ComponentDeclaration = t.FunctionDeclaration & {
11 __componentDeclaration: boolean;
12 };
13
14 export function isComponentDeclaration(
15 node: t.FunctionDeclaration,
16 ): node is ComponentDeclaration {
17 return Object.prototype.hasOwnProperty.call(node, '__componentDeclaration');
18 }
19
20 export function parseComponentDeclaration(
21 node: t.FunctionDeclaration,
22 ): ComponentDeclaration | null {
23 return isComponentDeclaration(node) ? node : null;
24 }