permissionless.js icon indicating copy to clipboard operation
permissionless.js copied to clipboard

getTypesForEIP712Domain error

Open mwawrusch opened this issue 1 year ago • 9 comments

Wagmi + Viem + AA upgrade === disaster.

Anyone seen this error:

../../node_modules/permissionless/actions/smartAccount/signTypedData.ts:137:49

 const types = {
> 137 |         EIP712Domain: getTypesForEIP712Domain({ domain }),
      |                                                 ^
  138 |         ...(types_ as TTypedData)
  139 |     }
'((TTypedData extends { [x: string]: readonly TypedDataParameter[]; [x: `string[${string}]`]: undefined; [x: `function[${string}]`]: undefined; [x: `address[${string}]`]: undefined; [x: `uint32[${string}]`]: undefined; [x: `bytes[${string}]`]: undefined; [x: `uint256[${string}]`]: undefined; [x: `bytes32[${string}]`]...' is not assignable to type 'TypedDataDomain | undefined'.
  Type '(TTypedData extends { [x: string]: readonly TypedDataParameter[]; [x: `string[${string}]`]: undefined; [x: `function[${string}]`]: undefined; [x: `address[${string}]`]: undefined; [x: `uint32[${string}]`]: undefined; [x: `bytes[${string}]`]: undefined; [x: `uint256[${string}]`]: undefined; [x: `bytes32[${string}]`]:...' is not assignable to type 'TypedDataDomain | undefined'.
    Type 'unknown' is not assignable to type 'TypedDataDomain | undefined'.
   
    "viem": "2.9.3",
    "wagmi": "2.5.12",
        "@alchemy/aa-accounts": "3.6.1",
        "@alchemy/aa-alchemy": "3.7.0",
        "@alchemy/aa-core": "3.6.1",
        "@alchemy/aa-ethers": "3.6.1",
        "@alchemy/aa-signers": "3.6.1",




mwawrusch avatar Mar 27 '24 09:03 mwawrusch

Same error here. Anyone can help?

eruizgar91 avatar Apr 04 '24 13:04 eruizgar91

Hard to tell what's going on without a minimal reproduction. Likely that skipLibCheck is falsy in your tsconfig.json.

jxom avatar Apr 04 '24 22:04 jxom

Hey what's your tsconfig's target? or as @jxom pointed out skipLibCheck is falsy in your tsconfig.json

plusminushalf avatar Apr 11 '24 08:04 plusminushalf

Share the command to reproduce the issue please

pavlovdog avatar Apr 11 '24 09:04 pavlovdog

The tsconfig skipLibCheck is true in my tsconfig. I solved adding an interface.d.ts file

eruizgar91 avatar Apr 11 '24 09:04 eruizgar91

Hey but can you provide a small repro repo? It will help us solve it!

plusminushalf avatar Apr 12 '24 07:04 plusminushalf

We're also getting this bug when moving from typescript 5.2.2 -> 5.4.5

../../node_modules/permissionless/actions/smartAccount/signTypedData.ts:139:49 - error TS2322: Type '((TTypedData extends { [x: string]: readonly TypedDataParameter[]; [x: `string[${string}]`]: undefined; [x: `function[${string}]`]: undefined; [x: `address[${string}]`]: undefined; [x: `uint32[${string}]`]: undefined; [x: `uint64[${string}]`]: undefined; [x: `uint256[${string}]`]: undefined; [x: `bytes32[${string}]`...' is not assignable to type 'TypedDataDomain | undefined'.
  Type '(TTypedData extends { [x: string]: readonly TypedDataParameter[]; [x: `string[${string}]`]: undefined; [x: `function[${string}]`]: undefined; [x: `address[${string}]`]: undefined; [x: `uint32[${string}]`]: undefined; [x: `uint64[${string}]`]: undefined; [x: `uint256[${string}]`]: undefined; [x: `bytes32[${string}]`]...' is not assignable to type 'TypedDataDomain | undefined'.
    Type 'unknown' is not assignable to type 'TypedDataDomain | undefined'.

139         EIP712Domain: getTypesForEIP712Domain({ domain }),
                                                    ~~~~~~

  ../../node_modules/viem/_types/utils/typedData.d.ts:13:5
    13     domain?: TypedDataDomain | undefined;
           ~~~~~~
    The expected type comes from property 'domain' which is declared here on type '{ domain?: TypedDataDomain | undefined; }'


Found 1 error in ../../node_modules/permissionless/actions/smartAccount/signTypedData.ts:139

trying to get a minimal repro

[edit] It's specifically the 5.4.X typescript upgrade that causes this. 5.3.X does not repro this behavior

CarterAppleton avatar Apr 22 '24 17:04 CarterAppleton

Sorry missed the ongoing thread. I can confirm that skipLibCheck is true on my end as well. Typescript upgrades are a huge PITA and cost factor these days :(. Would probably be best to always test on the latest supported Typescript version to catch this early.

mwawrusch avatar Apr 23 '24 08:04 mwawrusch

obviously this isn't a permanent fix for the issue but you can use patch-package to patch in an ignore flag for this type issue.

Doing this with the patch-package allows the patch to be applied after post-install so this will work in production builds and for other engineers working in the project.

example patch:

 
     const types = {
+        // @ts-ignore
         EIP712Domain: getTypesForEIP712Domain({ domain }),
         ...(types_ as TTypedData)
     }

gavinnewcomer avatar Apr 25 '24 16:04 gavinnewcomer