From d4393cb9c14e4a204e39fae3401ccbd45a7677ee Mon Sep 17 00:00:00 2001 From: cf Date: Sat, 14 Oct 2023 20:07:52 +0800 Subject: [PATCH] Fixed types --- package.json | 4 +++- tsconfig.types.json | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tsconfig.types.json diff --git a/package.json b/package.json index 8ab4e9d..8c869ff 100644 --- a/package.json +++ b/package.json @@ -8,17 +8,19 @@ "module": "./dist/poseidon2.mjs", "exports": { "./goldilocks-12": { + "types": "./dist/goldilocks-12.d.ts", "require": "./dist/goldilocks-12.cjs", "import": "./dist/goldilocks-12.mjs" }, ".": { + "types": "./dist/poseidon2.d.ts", "require": "./dist/poseidon2.cjs", "import": "./dist/poseidon2.mjs" } }, "scripts": { "dev": "vite --host", - "build": "rimraf ./dist && tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts", + "build": "rimraf ./dist && tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts && tsc -p ./tsconfig.types.json", "test": "vitest", "test:coverage": "vitest --coverage", "lint:scripts": "eslint . --ext .ts", diff --git a/tsconfig.types.json b/tsconfig.types.json new file mode 100644 index 0000000..d2cddf7 --- /dev/null +++ b/tsconfig.types.json @@ -0,0 +1,36 @@ +{ + "compilerOptions": { + "rootDir": "./src", + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ESNext", "DOM"], + "moduleResolution": "Node", + "strict": true, + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "forceConsistentCasingInFileNames": true, + "types": ["vite/client", "node"], + // Tells TypeScript to read JS files, as + // normally they are ignored as source files + "allowJs": true, + // Generate d.ts files + "declaration": true, + // This compiler run should + // only output d.ts files + "emitDeclarationOnly": true, + // Types should go into this directory. + // Removing this would place the .d.ts files + // next to the .js files + "outDir": "dist", + // go to js file when using IDE functions like + // "Go to Definition" in VSCode + "declarationMap": true + }, + "include": ["src"], + "exclude": ["**/*.test.ts", "node_modules", "test/**", ".history/**"] +}