Skip to content
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

Fix Typescript type checker errors #582

Open
silasdavis opened this issue Oct 20, 2024 · 3 comments
Open

Fix Typescript type checker errors #582

silasdavis opened this issue Oct 20, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@silasdavis
Copy link

Description

Currently there are a huge number of Typescript errors emitted by:

tsc --noEmit

Expected Behavior

There should be no Typescript compiler errors

Screenshots / Logs

❯ pnpm tsc --noEmit

... SNIP ...

Found 337 errors in 43 files.

Errors  Files
     1  hardhat.config.ts:22
     1  tasks/etherscanVerify.ts:5
     7  tasks/taskDeploy.ts:9
     1  tasks/taskGatewayRelayer.ts:111
     7  tasks/upgradeProxy.ts:2
    28  test/asyncDecrypt.ts:6
     1  test/blindAuction/BlindAuction.fixture.ts:4
     3  test/blindAuction/BlindAuction.ts:20
    87  test/coprocessorUtils.ts:2
     1  test/encryptedERC20/EncryptedERC20.fixture.ts:3
     4  test/fhevmjsMocked.ts:403
     1  test/governor/Comp.fixture.ts:3
     1  test/governor/Comp.ts:18
     2  test/governor/GovernorZama.fixture.ts:3
     2  test/governor/GovernorZama.ts:16
     1  test/identity/ERC20Rules.fixture.ts:3
     1  test/identity/compliantERC20.fixture.ts:3
     4  test/identity/compliantERC20.ts:26
     1  test/identity/identityRegistry.fixture.ts:3
     1  test/identity/identityRegistry.ts:18
     3  test/instance.ts:8
    11  test/payments/payments.ts:45
     1  test/rand/Rand.fixture.ts:3
    11  test/rand/Rand.ts:56
     2  test/regressions/Regression1.ts:6
     5  test/signers.ts:41
     1  test/tfheOperations/manual.ts:4
    11  test/tfheOperations/tfheOperations1.ts:4
    11  test/tfheOperations/tfheOperations10.ts:4
    11  test/tfheOperations/tfheOperations11.ts:4
    11  test/tfheOperations/tfheOperations12.ts:4
    11  test/tfheOperations/tfheOperations13.ts:4
    11  test/tfheOperations/tfheOperations2.ts:4
    11  test/tfheOperations/tfheOperations3.ts:4
    11  test/tfheOperations/tfheOperations4.ts:4
    11  test/tfheOperations/tfheOperations5.ts:4
    11  test/tfheOperations/tfheOperations6.ts:4
    11  test/tfheOperations/tfheOperations7.ts:4
    11  test/tfheOperations/tfheOperations8.ts:4
    11  test/tfheOperations/tfheOperations9.ts:4
     2  test/types.ts:1
     1  test/upgrades/upgrades.ts:4
     2  test/utils.ts:5
     ```
### **Environment Information**

Fill in the relevant environment details where the issue was observed:

- **Node.js Version**: `v20.17.0`
- **`fhEVMjs` Version**: `0.6.0-3`
- **Package Manager**: `pnpm`
- **Typescript Compiler**: `5.5.2`

### **Steps Taken to Debug**

Most of these errors would be straight-forward to address by making better use of:

- Typechain types
- Some type guards
- Some module declaration for hardhat types

Happy to follow-up with some fixes for these.

Trickier to resolve is:

test/instance.ts:8:8 - error TS2307: Cannot find module 'fhevmjs' or its corresponding type declarations.
There are types at '/home/silas/code/fhevm/node_modules/fhevmjs/lib/web.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.

8 } from 'fhevmjs';


I'm not entirely clear why these types are not resolved but it should be possible for `fhevmjs` to provide them in a manner consumable by NodeNext/Bundler configurations and Node16. Upgrading module/moduleResolution is not practical because it will pull in many more incompatibilities (e.g. with hardhat)
@silasdavis silasdavis added the bug Something isn't working label Oct 20, 2024
@silasdavis
Copy link
Author

silasdavis commented Oct 20, 2024

A hack that appears to work here:

Merge into tsconfig.json

{
   "compilerOptions": {
      "typeRoots": ["./node_modules/@types", "**/node_modules/@types", "./@types"]
    }
}

Add to root of repo: @types/fhevmjs/index.d.ts:

export * from "fhevmjs/web";

A fix on fhevmjs is preferable.

@silasdavis
Copy link
Author

Once you add the above incidentally you can see lots of type mismatches in ./test/instance.ts and associated mocks

@silasdavis
Copy link
Author

Made a start in #583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant