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