Skip to content

Commit

Permalink
Set-up Typescript Configuration (compound-finance#233)
Browse files Browse the repository at this point in the history
This patch properly sets up TypeScript configuration so that other projects can import this and use it correctly. We effectively make sure that the project is built when it's imported to another project. We make sure that only the `dist/` directory is included in npm and that it's picked up when used in a project (TypeScript is behind in its integration of package.json's `exports` key, so it's a little complex). This is in line with the requirements of `compound-js`'s integration of Comet.

Co-authored-by: Torrey Atcitty <[email protected]>
  • Loading branch information
hayesgm and torreyatcitty authored Apr 28, 2022
1 parent 2125f70 commit 09c1b38
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage/
.env
src/
Empty file added index.ts
Empty file.
23 changes: 19 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@
"name": "compound-protocol-v2.5",
"version": "0.1.0",
"description": "",
"main": "index.js",
"main": "dist/index.js",
"files": ["dist"],
"exports": {
".": "./dist/index.js",
"./*": "./dist/*.js"
},
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"dist/index.d.ts": [ "dist/index.d.ts" ],
"*": [ "dist/*" ]
}
},
"scripts": {
"build": "hardhat compile",
"prepare": "hardhat compile && tsc",
"clean": "hardhat clean && rm -rf build/ cache/ coverage* dist/",
"cover": "hardhat cover && npx istanbul report --include coverage.json html lcov",
"deploy": "npx hardhat run ./scripts/deploy-comet.ts",
Expand All @@ -21,6 +34,11 @@
"keywords": [],
"author": "Compound Finance",
"license": "UNLICENSED",
"dependencies": {
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"jest-diff": "^27.4.2"
},
"devDependencies": {
"@compound-finance/hardhat-import": "^1.0.3",
"@nomiclabs/hardhat-ethers": "^2.0.4",
Expand All @@ -32,8 +50,6 @@
"@types/chai-as-promised": "^7.1.4",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.7",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"chalk": "^5.0.0",
"dotenv": "^10.0.0",
"ethereum-waffle": "^3.4.0",
Expand All @@ -43,7 +59,6 @@
"hardhat-contract-sizer": "^2.4.0",
"hardhat-cover": "compound-finance/hardhat-cover",
"hardhat-gas-reporter": "^1.0.7",
"jest-diff": "^27.4.2",
"mocha-junit-reporter": "^2.0.2",
"mocha-multi-reporters": "hayesgm/mocha-multi-reporters#hayesgm/reporter-options-to-option",
"nock": "^13.2.2",
Expand Down
2 changes: 1 addition & 1 deletion plugins/scenario/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type ScenarioFn<T, U> = (
property: Property<T, U>
) => Promise<void>;

interface ScenarioBuilder<T, U, R> {
export interface ScenarioBuilder<T, U, R> {
(name: string, requirements: R, property: Property<T, U>): void;
only: (name: string, requirements: R, property: Property<T, U>) => void;
skip: (name: string, requirements: R, property: Property<T, U>) => void;
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"module": "commonjs",
"esModuleInterop": true,
"outDir": "dist",
"moduleResolution": "node"
"moduleResolution": "node",
"declaration": true
},
"include": ["./scripts", "./test", "./tasks"],
"files": [
"./index.ts",
"./hardhat.config.ts",
"node_modules/@nomiclabs/hardhat-ethers/internal/type-extensions.d.ts",
"node_modules/@nomiclabs/hardhat-waffle/dist/src/type-extensions.d.ts",
Expand Down

0 comments on commit 09c1b38

Please sign in to comment.