Debian Codegraph @

packages/babel-types/src/validators/isPlaceholderType.ts

raw
1 import { PLACEHOLDERS_ALIAS } from "../definitions";
2
3 /**
4 * Test if a `placeholderType` is a `targetType` or if `targetType` is an alias of `placeholderType`.
5 */
6 export default function isPlaceholderType(
7 placeholderType: string,
8 targetType: string,
9 ): boolean {
10 if (placeholderType === targetType) return true;
11
12 const aliases: Array<string> | undefined =
13 PLACEHOLDERS_ALIAS[placeholderType];
14 if (aliases) {
15 for (const alias of aliases) {
16 if (targetType === alias) return true;
17 }
18 }
19
20 return false;
21 }