typescript#ParsedCommandLine TypeScript Examples
The following examples show how to use
typescript#ParsedCommandLine.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: getParsedCommandLineForPackage.ts From DefinitelyTyped-tools with MIT License | 6 votes |
export function getParsedCommandLineForPackage(
ts: typeof import("typescript"),
packagePath: string
): ParsedCommandLine {
const tsConfigPath = ensureExists(path.resolve(packagePath, "tsconfig.json"));
const parsedCommandLine = ts.getParsedCommandLineOfConfigFile(
tsConfigPath,
{},
{
fileExists: ts.sys.fileExists,
getCurrentDirectory: ts.sys.getCurrentDirectory,
readDirectory: ts.sys.readDirectory,
readFile: ts.sys.readFile,
useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,
onUnRecoverableConfigFileDiagnostic: (diagnostic) => {
console.error(ts.formatDiagnostic(diagnostic, formatDiagnosticsHost));
},
}
);
if (!parsedCommandLine) {
throw new Error(`Could not get ParsedCommandLine from config file: ${tsConfigPath}`);
}
return parsedCommandLine;
}