({ emittedFiles, packageDir, subpath, originalSpecifier })
| 190 | } |
| 191 | |
| 192 | function resolvePackageSubpath({ emittedFiles, packageDir, subpath, originalSpecifier }) { |
| 193 | const srcRoot = path.join(dtsRoot, packageDir, 'src'); |
| 194 | const directFile = path.resolve(srcRoot, `${subpath}.d.ts`); |
| 195 | if (emittedFiles.has(directFile) || existsSync(directFile)) { |
| 196 | return directFile; |
| 197 | } |
| 198 | |
| 199 | const indexFile = path.resolve(srcRoot, subpath, 'index.d.ts'); |
| 200 | if (emittedFiles.has(indexFile) || existsSync(indexFile)) { |
| 201 | return indexFile; |
| 202 | } |
| 203 | |
| 204 | throw new Error(`Unable to resolve ${originalSpecifier} in emitted declarations`); |
| 205 | } |
| 206 | |
| 207 | function relativeSpecifier(fromFile, toFile) { |
| 208 | const fromDir = path.dirname(fromFile); |
no test coverage detected