Skip to content

Commit

Permalink
generate proper dts file for json
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Aug 13, 2024
1 parent 542ea54 commit 8bbe084
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/pages/cli/abi-ts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ This command converts [JSON files](https://www.json.org/json-en.html) that conta
1. See the new file.

```sh copy
less greeting.abi.json.d.ts
less greeting.abi.d.json.ts
```

## Debugging
Expand Down
2 changes: 1 addition & 1 deletion packages/abi-ts/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# abi-ts

Create TypeScript type declaration files (`.d.ts`) for your ABI JSON files.
Create TypeScript type declaration files (`.d.json.ts`) for your ABI JSON files.

This allows you to import your JSON ABI and use it directly with libraries like [viem](https://npmjs.com/package/viem) and [abitype](https://npmjs.com/package/abitype).

Expand Down
2 changes: 1 addition & 1 deletion packages/abi-ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const commandModule: CommandModule<Options, Options> = {
}

const ts = `declare const abi: ${json}; export default abi;\n`;
const tsFilename = `${jsonFilename}.d.ts`;
const tsFilename = jsonFilename.replace(".json", ".d.json.ts");

debug("Writing", tsFilename);
writeFileSync(tsFilename, ts);
Expand Down
1 change: 1 addition & 0 deletions packages/common/tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"esModuleInterop": true,
"noErrorTruncation": true,
"resolveJsonModule": true,
"allowArbitraryExtensions": true,
"forceConsistentCasingInFileNames": true,
"sourceMap": true
}
Expand Down
3 changes: 0 additions & 3 deletions packages/world/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
// needed to ensure tests like those in packages/world/ts/encodeSystemCall.test.ts
// resolve narrowed types from .d.ts as opposed to widened ones from abi.json
"resolveJsonModule": false,
"lib": ["ESNext", "DOM"],
"outDir": "dist"
},
Expand Down

0 comments on commit 8bbe084

Please sign in to comment.