( compileIdentifier: CompileIdentifierMetadata | null | undefined, )
| 207 | let _anonymousTypeIndex = 0; |
| 208 | |
| 209 | export function identifierName( |
| 210 | compileIdentifier: CompileIdentifierMetadata | null | undefined, |
| 211 | ): string | null { |
| 212 | if (!compileIdentifier || !compileIdentifier.reference) { |
| 213 | return null; |
| 214 | } |
| 215 | const ref = compileIdentifier.reference; |
| 216 | if (ref['__anonymousType']) { |
| 217 | return ref['__anonymousType']; |
| 218 | } |
| 219 | if (ref['__forward_ref__']) { |
| 220 | // We do not want to try to stringify a `forwardRef()` function because that would cause the |
| 221 | // inner function to be evaluated too early, defeating the whole point of the `forwardRef`. |
| 222 | return '__forward_ref__'; |
| 223 | } |
| 224 | let identifier = stringify(ref); |
| 225 | if (identifier.indexOf('(') >= 0) { |
| 226 | // case: anonymous functions! |
| 227 | identifier = `anonymous_${_anonymousTypeIndex++}`; |
| 228 | ref['__anonymousType'] = identifier; |
| 229 | } else { |
| 230 | identifier = sanitizeIdentifier(identifier); |
| 231 | } |
| 232 | return identifier; |
| 233 | } |
| 234 | |
| 235 | export interface CompileIdentifierMetadata { |
| 236 | reference: any; |
no test coverage detected
searching dependent graphs…