-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object literal may only specify known properties, and '"internalType"' does not exist in type 'ParamType'. #728
Comments
What is internalType? Is this in v4 or v5? In v5, does this not match JsonFragment? I get confused by how TypeScript sometimes chooses to allow additional properties and other times, not... does this need to extend any or { [ key: string ]: any } maybe? |
I'm actually not sure what
Yup, that would work. But its for JsonFragmentType, not JsonFragment. |
Oh, I mean what version of ethers are you using? The v4 branch (current master) or v5 (@ next). |
4.0.42 |
Can you try upgrading the 4.0.44 and see if you still have the problem? (There were some typing issues introduced that were fixed after 4.0.43; it may or may not help, just checking) |
Oh, can you also include a code snippet of what you are trying to do that causes that error? |
@aakilfernandes Did you try out |
I think this has been addressed? If not, please reopen. Thanks! :) |
Typescript is still unhappy about this in v5.2.0, have to JSON.stringify() it to appease the compiler. The change happened here: https://github.com/ethereum/solidity/releases/tag/v0.5.11. Adding it to fragments might solve the issue. Happy to drop a PR if you agree. |
Can you include the error? |
|
interestingly, the error is thrown with this: import { ContractInterface } from 'ethers';
export const CONTRACT_ABI: ContractInterface = [
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: 'address',
name: 'previousAdmin',
type: 'address',
},
.....
]; but not this: import { ContractInterface } from 'ethers';
const CONTRACT_ABI_RAW = [
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: 'address',
name: 'previousAdmin',
type: 'address',
},
.....
];
export const CONTRACT_ABI: ContractInterface = CONTRACT_ABI_RAW; |
I can confirm the problem exists. |
@ricmoo any objections to me opening a PR to address? |
Sorry, I’ve been busy with the EIP-1559 changes. I will look into this (and a few other issues) early this week. I suspect it will be an easy change, I mainly am interested in why this changed; it used to be TS didn’t care about extra properties, only missing ones. I wonder if they changed how types vs. interfaces work regarding object literals. I just need to look into it to find the best solution; ideally solidity adding new keys shouldn’t break JsonFragments. :) |
From the interfaces docs: Object literals get special treatment and undergo excess property checking when assigning them to other variables, or passing them as arguments. If an object literal has any properties that the “target type” doesn’t have, you’ll get an error: I think it's been around for a while, looks like since v3. It's just that in most cases you'd end up assigning it to the type Fragment vs declaring the object as as a Fragment. The former doesn't do excess checks, so it would work fine. |
Coolio. I've tested and added |
This has been fixed in 5.4.0. Sorry for the delay. Try it out and let me know how it works for you. :) |
I think this is taken care of, so I'm going to close this issue. If you have any problems, feel free to re-open or start a new issue. Thanks! :) |
This is a typescript compile issue, so should be able to fix this by just JSON.stringifying it and then passing it along. Making an issue here since ParamType should be able to hanlde
internalType
The text was updated successfully, but these errors were encountered: