Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createConverter(options?: ConverterOptions): Converter {
const cwd = ts.sys.getCurrentDirectory();
const srcFilename = pathlib.join(
cwd,
options?.isJS ? "__tslab__.js" : "__tslab__.ts"
);
const declFilename = pathlib.join(cwd, "__prev__.d.ts");
const outDir = "outDir";
const dstFilename = pathlib.join(outDir, "__tslab__.js");
const dstDeclFilename = pathlib.join(outDir, "__tslab__.d.ts");
// c.f.
// https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping
// https://github.com/microsoft/TypeScript/issues/22306#issuecomment-412266626
const traspileTarget =
semver.major(process.version) >= 12
? ts.ScriptTarget.ES2019
function getTypeRoots(): string[] {
// If @types/node does not exist in the default type roots,
// use @types under tslab/node_modules (bug#10).
// TODO: Integration-test for this behavior.
const typeRoots =
ts.getDefaultTypeRoots(cwd, {
directoryExists: sys.directoryExists
}) || [];
for (const root of typeRoots) {
if (ts.sys.fileExists(pathlib.join(root, "node", "package.json"))) {
return typeRoots;
}
}
typeRoots.push(pathlib.join(__dirname, "..", "node_modules", "@types"));
return typeRoots;
}
sys.fileExists = function(path: string): boolean {
return ts.sys.fileExists(forwardTslabPath(cwd, path));
};
sys.readDirectory = function(