( path: NodePath, )
| 6 | * its value. |
| 7 | */ |
| 8 | export default function getNameOrValue( |
| 9 | path: NodePath, |
| 10 | ): boolean | number | string | null { |
| 11 | if (path.isIdentifier()) { |
| 12 | return path.node.name; |
| 13 | } else if (path.isQualifiedTypeIdentifier() || path.isTSQualifiedName()) { |
| 14 | return printValue(path); |
| 15 | } else if ( |
| 16 | path.isStringLiteral() || |
| 17 | path.isNumericLiteral() || |
| 18 | path.isBooleanLiteral() |
| 19 | ) { |
| 20 | return path.node.value; |
| 21 | } else if (path.isRegExpLiteral()) { |
| 22 | return path.node.pattern; |
| 23 | } else if (path.isNullLiteral()) { |
| 24 | return null; |
| 25 | } |
| 26 | |
| 27 | throw new TypeError( |
| 28 | `Argument must be Identifier, Literal, QualifiedTypeIdentifier or TSQualifiedName. Received '${path.node.type}'`, |
| 29 | ); |
| 30 | } |
no test coverage detected
searching dependent graphs…