code simplification

This commit is contained in:
juanelas 2020-03-03 09:43:13 +01:00
parent 676397d9ac
commit ccd81abae1
1 changed files with 7 additions and 15 deletions

View File

@ -15,20 +15,12 @@ const compilerOptions = {
'allowJs': true
};
(function compile(jsFile, dtsFile, options) { // Create a Program with an in-memory emit
const host = ts.createCompilerHost(options);
// host.writeFile = (fileName, contents) => createdFiles[fileName] = contents;
const host = ts.createCompilerHost(compilerOptions);
host.writeFile = (fileName, contents) => {
fs.writeFileSync(dtsFile, contents);
};
// Prepare and emit the d.ts files
const program = ts.createProgram([jsFile], options, host);
const program = ts.createProgram([jsFile], compilerOptions, host);
program.emit();
// Loop through all the input files
// fileNames.forEach(file => {
// console.log("### JavaScript\n");
// console.log(host.readFile(file));
// });
})(jsFile, dtsFile, compilerOptions);