Skip to content

Commit

Permalink
refactor: temporary add manual type hints needed by certain TypeScrip…
Browse files Browse the repository at this point in the history
…t environment
  • Loading branch information
tien committed Jun 15, 2024
1 parent e53f747 commit 33c66fd
Showing 1 changed file with 81 additions and 6 deletions.
87 changes: 81 additions & 6 deletions packages/core/src/QueryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,15 @@ export default class Query<
return new Query([
...this.#instructions,
{ instruction: "fetch-constant", pallet, constant },
]);
// TODO: remove manual type hint once all TypeScript environments
// i.e. StackBlitz can infer this correctly
]) as Query<
[
...TInstructions,
{ instruction: "fetch-constant"; pallet: TPallet; constant: TConstant },
],
TDescriptor
>;
}

readStorage<
Expand All @@ -241,7 +249,20 @@ export default class Query<
return new Query([
...this.#instructions,
{ instruction: "read-storage", pallet, storage, args },
]);
// TODO: remove manual type hint once all TypeScript environments
// i.e. StackBlitz can infer this correctly
]) as Query<
[
...TInstructions,
{
instruction: "read-storage";
pallet: TPallet;
storage: TStorage;
args: TArguments;
},
],
TDescriptor
>;
}

readStorages<
Expand All @@ -254,7 +275,21 @@ export default class Query<
return new Query([
...this.#instructions,
{ instruction: "read-storage", pallet, storage, args, multi: true },
]);
// TODO: remove manual type hint once all TypeScript environments
// i.e. StackBlitz can infer this correctly
]) as Query<
[
...TInstructions,
{
instruction: "read-storage";
pallet: TPallet;
storage: TStorage;
args: TArguments;
multi: true;
},
],
TDescriptor
>;
}

readStorageEntries<
Expand All @@ -269,7 +304,20 @@ export default class Query<
return new Query([
...this.#instructions,
{ instruction: "read-storage-entries", pallet, storage, args },
]);
// TODO: remove manual type hint once all TypeScript environments
// i.e. StackBlitz can infer this correctly
]) as Query<
[
...TInstructions,
{
instruction: "read-storage-entries";
pallet: TPallet;
storage: TStorage;
args: TArguments;
},
],
TDescriptor
>;
}

callApi<
Expand All @@ -282,7 +330,20 @@ export default class Query<
return new Query([
...this.#instructions,
{ instruction: "call-api", pallet, api, args },
]);
// TODO: remove manual type hint once all TypeScript environments
// i.e. StackBlitz can infer this correctly
]) as Query<
[
...TInstructions,
{
instruction: "call-api";
pallet: TPallet;
api: TApi;
args: TArguments;
},
],
TDescriptor
>;
}

callApis<
Expand All @@ -295,6 +356,20 @@ export default class Query<
return new Query([
...this.#instructions,
{ instruction: "call-api", pallet, api, args, multi: true },
]);
// TODO: remove manual type hint once all TypeScript environments
// i.e. StackBlitz can infer this correctly
]) as Query<
[
...TInstructions,
{
instruction: "call-api";
pallet: TPallet;
api: TApi;
args: TArguments;
multi: true;
},
],
TDescriptor
>;
}
}

0 comments on commit 33c66fd

Please sign in to comment.