* Whether a `declare module` in `file` can be in the program `fromFile` is in. * Each package of a monorepo has a program of its own, so it can if `fromFile` * is in the package `file` is in, or in a package nested under that one: * vscode's extensions are packages of their own, and each has its
(file: string, test: boolean, fromFile: string, fromTest: boolean, context: ResolutionContext)
| 763 | * under copilot's `test/fixtures` are left out of its build and shadow nothing. |
| 764 | */ |
| 765 | function reachesProgram(file: string, test: boolean, fromFile: string, fromTest: boolean, context: ResolutionContext): boolean { |
| 766 | if (test && !fromTest) return false; |
| 767 | const folder = packageFolder(dirOf(file), context); |
| 768 | if (folder === '' || fromFile.startsWith(`${folder}/`)) return true; |
| 769 | if (test) return false; |
| 770 | const name = packageManifest(folder, context)?.name; |
| 771 | return !!name && !!packageManifest(packageFolder(dirOf(fromFile), context), context)?.dependencies.has(name); |
| 772 | } |
| 773 | |
| 774 | /** Whether a `declare module` in `declaringFile` counts for a file in `fromFile` (see reachesProgram). */ |
| 775 | export function declaringFileAnswers(declaringFile: string, fromFile: string, context: ResolutionContext): boolean { |
no test coverage detected