hyperweb-io / hyperweb-io/chain-registry
TypeScript build error on strict=true
- Dominant language
- TypeScript
- Stars
- 70
- Forks
- 39
- PR merge metrics
- No merged PRs in 30d
Description
I'm consuming chain-registry 1.20.0 with `"strict": true` in my `tsconfig.json` which leads to the following error:
```
node_modules/@chain-registry/types/types/chains.d.ts:177:9 - error TS2411: Property 'rpc' of type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[] | undefined' is not assignable to 'string' index type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[]'.
177 rpc?: {
~~~
node_modules/@chain-registry/types/types/chains.d.ts:182:9 - error TS2411: Property 'rest' of type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[] | undefined' is not assignable to 'string' index type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[]'.
182 rest?: {
~~~~
node_modules/@chain-registry/types/types/chains.d.ts:187:9 - error TS2411: Property 'grpc' of type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[] | undefined' is not assignable to 'string' index type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[]'.
187 grpc?: {
~~~~
node_modules/@chain-registry/types/types/chains.d.ts:192:9 - error TS2411: Property ''evm-http-jsonrpc'' of type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[] | undefined' is not assignable to 'string' index type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[]'.
192 'evm-http-jsonrpc'?: {
~~~~~~~~~~~~~~~~~~
node_modules/@chain-registry/types/types/chains.d.ts:197:9 - error TS2411: Property ''grpc-web'' of type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[] | undefined' is not assignable to 'string' index type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[]'.
197 'grpc-web'?: {
~~~~~~~~~~
node_modules/@chain-registry/types/types/chains.d.ts:202:9 - error TS2411: Property 'wss' of type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[] | undefined' is not assignable to 'string' index type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[]'.
202 wss?: {
~~~
node_modules/@chain-registry/types/types/chains.d.ts:207:9 - error TS2411: Property 'sidechains_rpc' of type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[] | undefined' is not assignable to 'string' index type '{ address: string; provider?: string | undefined; archive?: boolean | undefined; }[]'.
207 sidechains_rpc?: {
~~~~~~~~~~~~~~
Found 7 errors in the same file, starting at: node_modules/@chain-registry/types/types/chains.d.ts:177
```
This is my tsconfig.json
```
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"esModuleInterop": true,
"moduleResolution": "node",
"declaration": true,
"outDir": "./dist",
"strict": true,
"preserveConstEnums": true
},
"include": [
"src/**/*"
]
}
```
While the error could be fixed by the consuming project by using `"skipLibCheck": true`, I thought it might not be a bad idea if chain-registry type definition was also honoring strict.
The change doesn't seem too painful to make it comply.
Basically in `types/types/chains.d.ts` we need to change this line:
```ts
[key: string]: {
address: string;
provider?: string;
archive?: boolean;
}[];
```
By that one (not the `undefined` at the end):
```ts
[key: string]: {
address: string;
provider?: string;
archive?: boolean;
}[]|undefined;
```
By the way, are the types generated for the project or hand written? Because the address, provider, archive block could have its own subtype to be reused and make the code more readable (I would be happy to PR).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.