(name: ts.EntityName, context: SerializationContext)
| 74 | [...values].sort((left, right) => stableJson(left).localeCompare(stableJson(right))) |
| 75 | |
| 76 | const referenceResolution = (name: ts.EntityName, context: SerializationContext): unknown => { |
| 77 | let symbol = context.checker.getSymbolAtLocation(name) |
| 78 | if (symbol === undefined) { |
| 79 | return { unresolved: true } |
| 80 | } |
| 81 | if ((symbol.flags & ts.SymbolFlags.Alias) !== 0) { |
| 82 | symbol = context.checker.getAliasedSymbol(symbol) |
| 83 | } |
| 84 | const declaration = symbol?.declarations?.[0] |
| 85 | if (declaration === undefined) { |
| 86 | return { unresolved: true } |
| 87 | } |
| 88 | const publicApiId = context.publicSymbols.get(symbolIdentity(symbol, "type")) ?? |
| 89 | context.publicSymbols.get(symbolIdentity(symbol, "value")) |
| 90 | if (publicApiId !== undefined) { |
| 91 | return { apiId: publicApiId } |
| 92 | } |
| 93 | const file = declaration.getSourceFile().fileName |
| 94 | const separator = context.path.sep |
| 95 | const nodeModules = file.lastIndexOf(`${separator}node_modules${separator}`) |
| 96 | if (nodeModules !== -1) { |
| 97 | const remainder = file.slice(nodeModules + `${separator}node_modules${separator}`.length).split(separator) |
| 98 | return { |
| 99 | externalPackage: remainder[0]?.startsWith("@") ? remainder.slice(0, 2).join("/") : remainder[0] |
| 100 | } |
| 101 | } |
| 102 | return { declaration: normalizedPath(context.path, context.repoRoot, file) } |
| 103 | } |
| 104 | |
| 105 | const primitiveKinds = new Map<ts.SyntaxKind, string>([ |
| 106 | [ts.SyntaxKind.AnyKeyword, "any"], |
no test coverage detected