ttsc
Version:
General-purpose TypeScript-Go compiler, runtime, plugin host, and LSP host.
24 lines (23 loc) • 931 B
TypeScript
/**
* Locate the JavaScript file emitted for a TypeScript source file.
*
* Resolution strategy:
*
* 1. Try to derive the exact output path by mirroring the source's relative
* position inside `projectRoot` into `outDir`, applying the correct JS
* extension (`.js` / `.jsx` / `.mjs` / `.cjs`). Use this path if it exists
* on disk.
* 2. Fall back to scoring each candidate in `emittedFiles` (or a recursive
* directory scan of `outDir`) by the number of trailing path-stem segments
* shared with the source file name, and pick the highest-scoring existing
* file.
*
* Returns `null` when no matching output file is found on disk.
*/
export declare function resolveEmittedJavaScript(options: {
/** Pre-computed list of emitted paths; when absent `outDir` is scanned. */
emittedFiles?: readonly string[];
outDir: string;
projectRoot: string;
sourceFile: string;
}): string | null;