code simplification
This commit is contained in:
parent
676397d9ac
commit
ccd81abae1
|
@ -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) => {
|
host.writeFile = (fileName, contents) => {
|
||||||
fs.writeFileSync(dtsFile, contents);
|
fs.writeFileSync(dtsFile, contents);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Prepare and emit the d.ts files
|
// Prepare and emit the d.ts files
|
||||||
const program = ts.createProgram([jsFile], options, host);
|
const program = ts.createProgram([jsFile], compilerOptions, host);
|
||||||
program.emit();
|
program.emit();
|
||||||
|
|
||||||
// Loop through all the input files
|
|
||||||
// fileNames.forEach(file => {
|
|
||||||
// console.log("### JavaScript\n");
|
|
||||||
// console.log(host.readFile(file));
|
|
||||||
// });
|
|
||||||
})(jsFile, dtsFile, compilerOptions);
|
|
||||||
|
|
Loading…
Reference in New Issue