bigint-crypto-utils/build/build.dts.js

27 lines
692 B
JavaScript
Raw Normal View History

const fs = require('fs');
const ts = require('typescript');
const path = require('path');
const pkgJson = require('../package.json');
const rootDir = path.join(__dirname, '..');
const jsFile = path.join(rootDir, 'src', 'main.js');
const dtsFile = path.join(rootDir, 'types', `${pkgJson.name}.d.ts`);
const compilerOptions = {
'declaration': true,
'noEmit': false,
'emitDeclarationOnly': true,
'allowJs': true
};
2020-03-03 08:43:13 +00:00
const host = ts.createCompilerHost(compilerOptions);
2020-03-03 08:43:13 +00:00
host.writeFile = (fileName, contents) => {
fs.writeFileSync(dtsFile, contents);
};
2020-03-03 08:43:13 +00:00
// Prepare and emit the d.ts files
const program = ts.createProgram([jsFile], compilerOptions, host);
program.emit();