From ccd81abae12248cce7062cfaa761be4beaac5740 Mon Sep 17 00:00:00 2001 From: juanelas Date: Tue, 3 Mar 2020 09:43:13 +0100 Subject: [PATCH] code simplification --- build/build.dts.js | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/build/build.dts.js b/build/build.dts.js index 6b3abee..a7fbd05 100644 --- a/build/build.dts.js +++ b/build/build.dts.js @@ -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; - host.writeFile = (fileName, contents) => { - fs.writeFileSync(dtsFile, contents); - }; +const host = ts.createCompilerHost(compilerOptions); - // Prepare and emit the d.ts files - const program = ts.createProgram([jsFile], options, host); - program.emit(); +host.writeFile = (fileName, contents) => { + fs.writeFileSync(dtsFile, contents); +}; - // Loop through all the input files - // fileNames.forEach(file => { - // console.log("### JavaScript\n"); - // console.log(host.readFile(file)); - // }); -})(jsFile, dtsFile, compilerOptions); +// Prepare and emit the d.ts files +const program = ts.createProgram([jsFile], compilerOptions, host); +program.emit();