Merged PR 72: add index.d.ts file

add index.d.ts file
master
Tudor Stanciu 2023-02-09 22:53:55 +00:00
parent 4992da2997
commit eda1e16325
2 changed files with 23 additions and 1 deletions

View File

@ -43,6 +43,19 @@ const srcPath = path.join(packagePath, "./src");
// );
// }
async function typescriptCopy({ from, to }) {
if (!(await fse.exists(to))) {
console.warn(`path ${to} does not exists`);
return [];
}
const files = glob.sync("**/*.d.ts", { cwd: from });
const cmds = files.map(file =>
fse.copy(path.resolve(from, file), path.resolve(to, file))
);
return Promise.all(cmds);
}
async function createPackageFile() {
const packageData = await fse.readFile(
path.resolve(packagePath, "./package.json"),
@ -54,7 +67,9 @@ async function createPackageFile() {
const newPackageData = {
...packageDataOther,
private: false,
main: "./index.js"
main: "./index.js",
//module: "./esm/index.js",
typings: "./index.d.ts"
};
const targetPath = path.resolve(buildPath, "./package.json");
@ -77,6 +92,9 @@ async function run() {
try {
await createPackageFile();
// TypeScript
await typescriptCopy({ from: srcPath, to: buildPath });
//await createModulePackages({ from: srcPath, to: buildPath });
} catch (err) {
console.error(err);

4
src/index.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
import * as typeValidator from "./data/typeValidator";
import * as localStorage from "./storage/localStorage";
export { typeValidator, localStorage };