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

feat(typedoc) - add typedoc to the repo #755

Merged
merged 4 commits into from
Nov 13, 2023
Merged

feat(typedoc) - add typedoc to the repo #755

merged 4 commits into from
Nov 13, 2023

Conversation

ctrlc03
Copy link
Collaborator

@ctrlc03 ctrlc03 commented Oct 19, 2023

fix #754

@ctrlc03 ctrlc03 self-assigned this Oct 19, 2023
@ctrlc03 ctrlc03 linked an issue Oct 23, 2023 that may be closed by this pull request
@baumstern
Copy link
Member

Before we proceed with this PR, could you please elaborate on the benefits of adding typedoc in the associated issue?

@ctrlc03
Copy link
Collaborator Author

ctrlc03 commented Oct 27, 2023

Before we proceed with this PR, could you please elaborate on the benefits of adding typedoc in the associated issue?

replied on the issue..

@baumstern
Copy link
Member

Before we proceed with this PR, could you please elaborate on the benefits of adding typedoc in the associated issue?

replied on the issue..

First off, great initiative on adding TypeDoc for auto-generating documentation. This could be a huge win for developer experience and maintainability of this project. However, I do have some clarifications I'd like to ask about this PR:

  1. I see that HTML files have been added to the PR. Is the expectation that developers will run the TypeDoc generation script manually before raising each PR to update these?

  2. If we're committing to hosting this on GitHub Pages, will the setup for that be handled in a separate PR or task?

@ctrlc03
Copy link
Collaborator Author

ctrlc03 commented Oct 30, 2023

Before we proceed with this PR, could you please elaborate on the benefits of adding typedoc in the associated issue?

replied on the issue..

First off, great initiative on adding TypeDoc for auto-generating documentation. This could be a huge win for developer experience and maintainability of this project. However, I do have some clarifications I'd like to ask about this PR:

  1. I see that HTML files have been added to the PR. Is the expectation that developers will run the TypeDoc generation script manually before raising each PR to update these?
  2. If we're committing to hosting this on GitHub Pages, will the setup for that be handled in a separate PR or task?
  1. this could be done via the CI, a pre commit hook, etc. We should document this feature for sure
  2. Evaluate MACI documentation needs #780 there is a separate issue tracking how we can aggregate documentation and/or host it going forward

@baumstern
Copy link
Member

I wonder if it might be more common for users to view TypeDoc files via a web page rather than opening HTML files locally. Perhaps it could be beneficial to automatically generate the latest documentation and serve it through a web page. Then we don't have to include html files in our VCS. What are your thoughts on this approach?

@ctrlc03
Copy link
Collaborator Author

ctrlc03 commented Nov 1, 2023

I wonder if it might be more common for users to view TypeDoc files via a web page rather than opening HTML files locally. Perhaps it could be beneficial to automatically generate the latest documentation and serve it through a web page. Then we don't have to include html files in our VCS. What are your thoughts on this approach?

Yea exactly what is mentioned in the comment above. For now the typedocs are saved in the docs folder, which is hosted via github pages -> one could navigate through there but it's not very user friendly without any navbar to navigate there directly. Hence we need to think about how we will display all our documentation going forward.

@samajammin
Copy link
Member

Nice @ctrlc03 !

Are you able to generate the pages locally?

I tried pulling this down locally & running it. Got these errors:

~/code/pse/maci on  feat/typedocs via ⬢ v18.18.2
➜ npm run docs

> [email protected] docs
> typedoc --options typedoc.json

circuits/ts/__tests__/Hasher.test.ts:201:17 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

201                 random50bitBigInt(),
                    ~~~~~~~~~~~~~~~~~~~

circuits/ts/__tests__/MessageToCommand.test.ts:36:13 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

36             random50bitBigInt(),
               ~~~~~~~~~~~~~~~~~~~

circuits/ts/__tests__/TallyVotes.test.ts:264:22 - error TS2554: Expected 1 arguments, but got 0.

264                 poll.processMessages()
                         ~~~~~~~~~~~~~~~~~

  core/build/MaciState.d.ts:74:23
    74     processMessages: (_pollId: number) => any;
                             ~~~~~~~~~~~~~~~
    An argument for '_pollId' was not provided.

circuits/ts/__tests__/utils.ts:4:8 - error TS2307: Cannot find module 'circom-helper' or its corresponding type declarations.

4 } from 'circom-helper'
         ~~~~~~~~~~~~~~~

cli/ts/genProofs.ts:8:10 - error TS2305: Module '"maci-core"' has no exported member 'genTallyResultCommitment'.

8 import { genTallyResultCommitment } from 'maci-core'
           ~~~~~~~~~~~~~~~~~~~~~~~~

cli/ts/genProofs.ts:235:9 - error TS2740: Type 'Promise<any>' is missing the following properties from type 'VerifyingKey': alpha1, beta2, gamma2, delta2, and 4 more.

235         subsidyVk = extractVk(args.subsidy_zkey)
            ~~~~~~~~~

cli/ts/verify.ts:3:10 - error TS2305: Module '"maci-core"' has no exported member 'genTallyResultCommitment'.

3 import { genTallyResultCommitment } from 'maci-core'
           ~~~~~~~~~~~~~~~~~~~~~~~~

contracts/ts/__tests__/AccQueue.test.ts:398:53 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

398     const aq = new AccQueue(SUB_DEPTH, HASH_LENGTH, ZERO)
                                                        ~~~~

contracts/ts/__tests__/AccQueueBenchmark.test.ts:35:53 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

35     const aq = new AccQueue(SUB_DEPTH, HASH_LENGTH, ZERO)
                                                       ~~~~

contracts/ts/__tests__/MACI.test.ts:91:5 - error TS2322: Type '{ maxUsers: number; maxMessages: number; maxVoteOptions: number; }' is not assignable to type 'MaxValues'.
  Object literal may only specify known properties, and 'maxUsers' does not exist in type 'MaxValues'.

91     maxUsers: 25,
       ~~~~~~~~~~~~

contracts/ts/__tests__/MACI.test.ts:599:17 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'bigint'.

599                 maxValues.maxVoteOptions,
                    ~~~~~~~~~~~~~~~~~~~~~~~~

contracts/ts/__tests__/MACI.test.ts:666:53 - error TS2554: Expected 0 arguments, but got 1.

666             const generatedInputs = poll.tallyVotes(pollId)
                                                        ~~~~~~

contracts/ts/__tests__/MACI_overflow.test.ts:29:5 - error TS2322: Type '{ maxUsers: number; maxMessages: number; maxVoteOptions: number; }' is not assignable to type 'MaxValues'.
  Object literal may only specify known properties, and 'maxUsers' does not exist in type 'MaxValues'.

29     maxUsers: 25,
       ~~~~~~~~~~~~

contracts/ts/__tests__/MACI_overflow.test.ts:132:13 - error TS2322: Type '{ maxUsers: number; maxMessages: number; maxVoteOptions: number; }' is not assignable to type 'MaxValues'.
  Object literal may only specify known properties, and 'maxUsers' does not exist in type 'MaxValues'.

132             maxUsers: 25,
                ~~~~~~~~~~~~

contracts/ts/genZerosContract.ts:39:38 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

39                 hashed = sha256Hash([z, z])
                                        ~

contracts/ts/genZerosContract.ts:39:41 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

39                 hashed = sha256Hash([z, z])
                                           ~

contracts/ts/genZerosContract.ts:41:38 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

41                 hashed = sha256Hash([z, z, z, z, z])
                                        ~

contracts/ts/genZerosContract.ts:41:41 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

41                 hashed = sha256Hash([z, z, z, z, z])
                                           ~

contracts/ts/genZerosContract.ts:41:44 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

41                 hashed = sha256Hash([z, z, z, z, z])
                                              ~

contracts/ts/genZerosContract.ts:41:47 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

41                 hashed = sha256Hash([z, z, z, z, z])
                                                 ~

contracts/ts/genZerosContract.ts:41:50 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

41                 hashed = sha256Hash([z, z, z, z, z])
                                                    ~

contracts/ts/genZerosContract.ts:45:40 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

45                 hashed = hashLeftRight(z, z)
                                          ~

contracts/ts/genZerosContract.ts:47:33 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

47                 hashed = hash5([z, z, z, z, z])
                                   ~

contracts/ts/genZerosContract.ts:47:36 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

47                 hashed = hash5([z, z, z, z, z])
                                      ~

contracts/ts/genZerosContract.ts:47:39 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

47                 hashed = hash5([z, z, z, z, z])
                                         ~

contracts/ts/genZerosContract.ts:47:42 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

47                 hashed = hash5([z, z, z, z, z])
                                            ~

contracts/ts/genZerosContract.ts:47:45 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

47                 hashed = hash5([z, z, z, z, z])
                                               ~

core/ts/MaciState.ts:860:13 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

860             newSubsidyCommitment
                ~~~~~~~~~~~~~~~~~~~~

core/ts/MaciState.ts:1157:48 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

1157         return hashLeftRight(resultsTree.root, _salt)
                                                    ~~~~~

core/ts/MaciState.ts:1174:40 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

1174         return hashLeftRight(subtotal, _salt)
                                            ~~~~~

core/ts/MaciState.ts:1212:48 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

1212         return hashLeftRight(resultsTree.root, _salt)
                                                    ~~~~~

core/ts/MaciState.ts:1382:13 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

1382             _initialVoiceCreditBalance,
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~

core/ts/MaciState.ts:1591:37 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

1591     return hashLeftRight(tree.root, salt)
                                         ~~~~

domainobjs/ts/index.ts:415:12 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

415            ...[this.msgType],
               ~~~~~~~~~~~~~~~~~

domainobjs/ts/index.ts:416:12 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

416            ...this.data,
               ~~~~~~~~~~~~

domainobjs/ts/index.ts:417:12 - error TS2322: Type 'bigint | BigInt' is not assignable to type 'bigint'.
  Type 'BigInt' is not assignable to type 'bigint'.

417            ..._encPubKey.rawPubKey,
               ~~~~~~~~~~~~~~~~~~~~~~~

domainobjs/ts/index.ts:473:30 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

473         return hashLeftRight(vals[0], vals[1])
                                 ~~~~~~~

domainobjs/ts/index.ts:618:22 - error TS2345: Argument of type 'BigInt[]' is not assignable to parameter of type 'Plaintext'.
  Type 'BigInt' is not assignable to type 'bigint'.

618         return hash4(this.asArray())
                         ~~~~~~~~~~~~~~

domainobjs/ts/index.ts:793:22 - error TS2345: Argument of type 'BigInt[]' is not assignable to parameter of type 'Plaintext'.

793         return hash4(this.asArray())
                         ~~~~~~~~~~~~~~

domainobjs/ts/index.ts:803:41 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

803         return sign(privKey.rawPrivKey, this.hash())
                                            ~~~~~~~~~~~

domainobjs/ts/index.ts:817:13 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

817             this.hash(),
                ~~~~~~~~~~~

domainobjs/ts/index.ts:846:48 - error TS2345: Argument of type '(bigint | BigInt)[]' is not assignable to parameter of type 'Plaintext'.
  Type 'bigint | BigInt' is not assignable to type 'bigint'.
    Type 'BigInt' is not assignable to type 'bigint'.

846         const ciphertext: Ciphertext = encrypt(plaintext, sharedKey, BigInt(0))
                                                   ~~~~~~~~~

domainobjs/ts/index.ts:861:35 - error TS2345: Argument of type 'BigInt[]' is not assignable to parameter of type 'Ciphertext'.

861         const decrypted = decrypt(message.data, sharedKey, BigInt(0), 7)
                                      ~~~~~~~~~~~~

integrationTests/ts/__tests__/suites.ts:45:13 - error TS2554: Expected 0 arguments, but got 5.

 45             coordinatorKeypair,
                ~~~~~~~~~~~~~~~~~~~
 46             config.constants.maci.stateTreeDepth,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
 48             config.constants.maci.voteOptionTreeDepth,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 49             config.constants.maci.maxVoteOptions,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

integrationTests/ts/__tests__/suites.ts:125:19 - error TS2339: Property 'maxUsers' does not exist on type 'MaxValues'.

125         maxValues.maxUsers = config.constants.maci.maxUsers
                      ~~~~~~~~

integrationTests/ts/__tests__/suites.ts:131:13 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'bigint'.

131             (Date.now() + (config.constants.poll.duration * 60000)),
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

integrationTests/ts/__tests__/suites.ts:163:17 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'bigint'.

163                 Date.now()
                    ~~~~~~~~~~

@baumstern
Copy link
Member

baumstern commented Nov 2, 2023

Nice @ctrlc03 !

Are you able to generate the pages locally?

I tried pulling this down locally & running it. Got these errors:

~/code/pse/maci on  feat/typedocs via ⬢ v18.18.2
➜ npm run docs

> [email protected] docs
> typedoc --options typedoc.json

circuits/ts/__tests__/Hasher.test.ts:201:17 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

201                 random50bitBigInt(),
                    ~~~~~~~~~~~~~~~~~~~

circuits/ts/__tests__/MessageToCommand.test.ts:36:13 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

36             random50bitBigInt(),
               ~~~~~~~~~~~~~~~~~~~

circuits/ts/__tests__/TallyVotes.test.ts:264:22 - error TS2554: Expected 1 arguments, but got 0.

264                 poll.processMessages()
                         ~~~~~~~~~~~~~~~~~

  core/build/MaciState.d.ts:74:23
    74     processMessages: (_pollId: number) => any;
                             ~~~~~~~~~~~~~~~
    An argument for '_pollId' was not provided.

circuits/ts/__tests__/utils.ts:4:8 - error TS2307: Cannot find module 'circom-helper' or its corresponding type declarations.

4 } from 'circom-helper'
         ~~~~~~~~~~~~~~~

cli/ts/genProofs.ts:8:10 - error TS2305: Module '"maci-core"' has no exported member 'genTallyResultCommitment'.

8 import { genTallyResultCommitment } from 'maci-core'
           ~~~~~~~~~~~~~~~~~~~~~~~~

cli/ts/genProofs.ts:235:9 - error TS2740: Type 'Promise<any>' is missing the following properties from type 'VerifyingKey': alpha1, beta2, gamma2, delta2, and 4 more.

235         subsidyVk = extractVk(args.subsidy_zkey)
            ~~~~~~~~~

cli/ts/verify.ts:3:10 - error TS2305: Module '"maci-core"' has no exported member 'genTallyResultCommitment'.

3 import { genTallyResultCommitment } from 'maci-core'
           ~~~~~~~~~~~~~~~~~~~~~~~~

contracts/ts/__tests__/AccQueue.test.ts:398:53 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

398     const aq = new AccQueue(SUB_DEPTH, HASH_LENGTH, ZERO)
                                                        ~~~~

contracts/ts/__tests__/AccQueueBenchmark.test.ts:35:53 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

35     const aq = new AccQueue(SUB_DEPTH, HASH_LENGTH, ZERO)
                                                       ~~~~

contracts/ts/__tests__/MACI.test.ts:91:5 - error TS2322: Type '{ maxUsers: number; maxMessages: number; maxVoteOptions: number; }' is not assignable to type 'MaxValues'.
  Object literal may only specify known properties, and 'maxUsers' does not exist in type 'MaxValues'.

91     maxUsers: 25,
       ~~~~~~~~~~~~

contracts/ts/__tests__/MACI.test.ts:599:17 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'bigint'.

599                 maxValues.maxVoteOptions,
                    ~~~~~~~~~~~~~~~~~~~~~~~~

contracts/ts/__tests__/MACI.test.ts:666:53 - error TS2554: Expected 0 arguments, but got 1.

666             const generatedInputs = poll.tallyVotes(pollId)
                                                        ~~~~~~

contracts/ts/__tests__/MACI_overflow.test.ts:29:5 - error TS2322: Type '{ maxUsers: number; maxMessages: number; maxVoteOptions: number; }' is not assignable to type 'MaxValues'.
  Object literal may only specify known properties, and 'maxUsers' does not exist in type 'MaxValues'.

29     maxUsers: 25,
       ~~~~~~~~~~~~

contracts/ts/__tests__/MACI_overflow.test.ts:132:13 - error TS2322: Type '{ maxUsers: number; maxMessages: number; maxVoteOptions: number; }' is not assignable to type 'MaxValues'.
  Object literal may only specify known properties, and 'maxUsers' does not exist in type 'MaxValues'.

132             maxUsers: 25,
                ~~~~~~~~~~~~

contracts/ts/genZerosContract.ts:39:38 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

39                 hashed = sha256Hash([z, z])
                                        ~

contracts/ts/genZerosContract.ts:39:41 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

39                 hashed = sha256Hash([z, z])
                                           ~

contracts/ts/genZerosContract.ts:41:38 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

41                 hashed = sha256Hash([z, z, z, z, z])
                                        ~

contracts/ts/genZerosContract.ts:41:41 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

41                 hashed = sha256Hash([z, z, z, z, z])
                                           ~

contracts/ts/genZerosContract.ts:41:44 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

41                 hashed = sha256Hash([z, z, z, z, z])
                                              ~

contracts/ts/genZerosContract.ts:41:47 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

41                 hashed = sha256Hash([z, z, z, z, z])
                                                 ~

contracts/ts/genZerosContract.ts:41:50 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

41                 hashed = sha256Hash([z, z, z, z, z])
                                                    ~

contracts/ts/genZerosContract.ts:45:40 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

45                 hashed = hashLeftRight(z, z)
                                          ~

contracts/ts/genZerosContract.ts:47:33 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

47                 hashed = hash5([z, z, z, z, z])
                                   ~

contracts/ts/genZerosContract.ts:47:36 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

47                 hashed = hash5([z, z, z, z, z])
                                      ~

contracts/ts/genZerosContract.ts:47:39 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

47                 hashed = hash5([z, z, z, z, z])
                                         ~

contracts/ts/genZerosContract.ts:47:42 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

47                 hashed = hash5([z, z, z, z, z])
                                            ~

contracts/ts/genZerosContract.ts:47:45 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

47                 hashed = hash5([z, z, z, z, z])
                                               ~

core/ts/MaciState.ts:860:13 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

860             newSubsidyCommitment
                ~~~~~~~~~~~~~~~~~~~~

core/ts/MaciState.ts:1157:48 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

1157         return hashLeftRight(resultsTree.root, _salt)
                                                    ~~~~~

core/ts/MaciState.ts:1174:40 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

1174         return hashLeftRight(subtotal, _salt)
                                            ~~~~~

core/ts/MaciState.ts:1212:48 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

1212         return hashLeftRight(resultsTree.root, _salt)
                                                    ~~~~~

core/ts/MaciState.ts:1382:13 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

1382             _initialVoiceCreditBalance,
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~

core/ts/MaciState.ts:1591:37 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

1591     return hashLeftRight(tree.root, salt)
                                         ~~~~

domainobjs/ts/index.ts:415:12 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

415            ...[this.msgType],
               ~~~~~~~~~~~~~~~~~

domainobjs/ts/index.ts:416:12 - error TS2322: Type 'BigInt' is not assignable to type 'bigint'.

416            ...this.data,
               ~~~~~~~~~~~~

domainobjs/ts/index.ts:417:12 - error TS2322: Type 'bigint | BigInt' is not assignable to type 'bigint'.
  Type 'BigInt' is not assignable to type 'bigint'.

417            ..._encPubKey.rawPubKey,
               ~~~~~~~~~~~~~~~~~~~~~~~

domainobjs/ts/index.ts:473:30 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

473         return hashLeftRight(vals[0], vals[1])
                                 ~~~~~~~

domainobjs/ts/index.ts:618:22 - error TS2345: Argument of type 'BigInt[]' is not assignable to parameter of type 'Plaintext'.
  Type 'BigInt' is not assignable to type 'bigint'.

618         return hash4(this.asArray())
                         ~~~~~~~~~~~~~~

domainobjs/ts/index.ts:793:22 - error TS2345: Argument of type 'BigInt[]' is not assignable to parameter of type 'Plaintext'.

793         return hash4(this.asArray())
                         ~~~~~~~~~~~~~~

domainobjs/ts/index.ts:803:41 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

803         return sign(privKey.rawPrivKey, this.hash())
                                            ~~~~~~~~~~~

domainobjs/ts/index.ts:817:13 - error TS2345: Argument of type 'BigInt' is not assignable to parameter of type 'bigint'.

817             this.hash(),
                ~~~~~~~~~~~

domainobjs/ts/index.ts:846:48 - error TS2345: Argument of type '(bigint | BigInt)[]' is not assignable to parameter of type 'Plaintext'.
  Type 'bigint | BigInt' is not assignable to type 'bigint'.
    Type 'BigInt' is not assignable to type 'bigint'.

846         const ciphertext: Ciphertext = encrypt(plaintext, sharedKey, BigInt(0))
                                                   ~~~~~~~~~

domainobjs/ts/index.ts:861:35 - error TS2345: Argument of type 'BigInt[]' is not assignable to parameter of type 'Ciphertext'.

861         const decrypted = decrypt(message.data, sharedKey, BigInt(0), 7)
                                      ~~~~~~~~~~~~

integrationTests/ts/__tests__/suites.ts:45:13 - error TS2554: Expected 0 arguments, but got 5.

 45             coordinatorKeypair,
                ~~~~~~~~~~~~~~~~~~~
 46             config.constants.maci.stateTreeDepth,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
 48             config.constants.maci.voteOptionTreeDepth,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 49             config.constants.maci.maxVoteOptions,
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

integrationTests/ts/__tests__/suites.ts:125:19 - error TS2339: Property 'maxUsers' does not exist on type 'MaxValues'.

125         maxValues.maxUsers = config.constants.maci.maxUsers
                      ~~~~~~~~

integrationTests/ts/__tests__/suites.ts:131:13 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'bigint'.

131             (Date.now() + (config.constants.poll.duration * 60000)),
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

integrationTests/ts/__tests__/suites.ts:163:17 - error TS2345: Argument of type 'number' is not assignable to parameter of type 'bigint'.

163                 Date.now()
                    ~~~~~~~~~~

fyi: I was able to generate typedocs.

my environment:

OS: MacOS Ventura 13.4.1
processor arch: M1
Node.js: v18.17.0
npm: 9.6.7

my steps:

cd maci
npm install
npm run bootstrap
npm run build

npm run docs

@ctrlc03
Copy link
Collaborator Author

ctrlc03 commented Nov 2, 2023

my environment:

did you run install, bootstrap, build before? @samajammin

@samajammin
Copy link
Member

Ok so ran:

gco feat/typedocs
npm i

All good, but failed on bootstrap (same issue as earlier this week):

~/code/pse/maci on  feat/typedocs via ⬢ v18.18.2
➜ npm run bootstrap

> [email protected] bootstrap
> lerna bootstrap

lerna notice cli v6.0.3
lerna info Bootstrapping 9 packages
lerna info Installing external dependencies
lerna ERR! npm install exited 1 in 'maci-circuits'
lerna ERR! npm install stderr:
npm ERR! code 1
npm ERR! path /Users/samrichards/code/pse/maci/circuits/node_modules/better-sqlite3
npm ERR! command failed
npm ERR! command sh -c prebuild-install || npm run build-release

So I tried rebasing this branch off dev, which got me past bootstrap step, but then build fails 🤷

~/code/pse/maci on  feat/typedocs [⇕$!] via ⬢ v18.18.2
➜ npm run build

> [email protected] build
> lerna run build

lerna notice cli v6.0.3

    ✔  maci-crypto:build (2s)
    ✔  maci-domainobjs:build (2s)
    ✔  maci-core:build (2s)

    ✖  maci-circuits:build
       > [email protected] build
       > tsc

       ../node_modules/@types/jest/index.d.ts(2,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.
       ../node_modules/@types/jest/index.d.ts(4,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'afterEach' must be of type 'HookFunction', but here has type 'Lifecycle'.
       ../node_modules/@types/jest/index.d.ts(5,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'describe' must be of type 'SuiteFunction', but here has type 'Describe'.
       ../node_modules/@types/jest/index.d.ts(7,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'xdescribe' must be of type 'PendingSuiteFunction', but here has type 'Describe'.
       ../node_modules/@types/jest/index.d.ts(8,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'it' must be of type 'TestFunction', but here has type 'It'.
       ../node_modules/@types/jest/index.d.ts(10,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'xit' must be of type 'PendingTestFunction', but here has type 'It'.
       ../node_modules/@types/jest/index.d.ts(11,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'TestFunction', but here has type 'It'.
       ../node_modules/@types/jest/index.d.ts(1198,22): error TS2344: Type 'T' does not satisfy the constraint 'new (...args: any) => any'.
         Type 'abstract new (...args: any) => any' is not assignable to type 'new (...args: any) => any'.
           Cannot assign an abstract constructor type to a non-abstract constructor type.
       ../node_modules/@types/jest/index.d.ts(1199,31): error TS2344: Type 'T' does not satisfy the constraint 'new (...args: any) => any'.
         Type 'abstract new (...args: any) => any' is not assignable to type 'new (...args: any) => any'.
           Cannot assign an abstract constructor type to a non-abstract constructor type.


 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  Lerna (powered by Nx)   Ran target build for 7 projects (7s)

    ✔    3/4 succeeded [0 read from cache]

    ✖    1/4 targets failed, including the following:
         - maci-circuits:build

Any ideas?

@samajammin
Copy link
Member

Here's my env:

~/code/pse/maci on  feat/typedocs [⇕$!] via ⬢ v18.18.2
➜ volta list
⚡️ Currently active tools:

    Node: v18.18.2 (default)
    npm: v10.2.1 (default)
    Yarn: v1.22.19 (default)
    Tool binaries available:
        phase2cli (default)
        ethportocli (default)
        gatsby (default)
        ntl, netlify (default)
        pnpm, pnpx (default)

@samajammin
Copy link
Member

Also confirming that if I go through everything on dev branch, it completes successfully... 😕

~/code/pse/maci on  dev [$!] via ⬢ v18.18.2
➜ npm run build

> [email protected] build
> lerna run build

lerna notice cli v6.0.3

    ✔  maci-crypto:build (2s)
    ✔  maci-domainobjs:build (2s)
    ✔  maci-core:build (2s)
    ✔  maci-circuits:build (1s)
    ✔  maci-contracts:build (2s)
    ✔  maci-cli:build (2s)
    ✔  maci-integrationtests:build (2s)

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  Lerna (powered by Nx)   Successfully ran target build for 7 projects (13s)

package.json Outdated
},
"author": "",
"devDependencies": {
"@types/jest": "^29.5.6",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is why builds fail for me? Something related to the jest types is failing...

~/code/pse/maci on  feat/typedocs [⇕$!] via ⬢ v18.18.2
➜ npm run build

> [email protected] build
> lerna run build

lerna notice cli v6.0.3

    ✔  maci-crypto:build (2s)
    ✔  maci-domainobjs:build (2s)
    ✔  maci-core:build (2s)

    ✖  maci-circuits:build
       > [email protected] build
       > tsc

       ../node_modules/@types/jest/index.d.ts(2,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.
       ../node_modules/@types/jest/index.d.ts(4,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'afterEach' must be of type 'HookFunction', but here has type 'Lifecycle'.
       ../node_modules/@types/jest/index.d.ts(5,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'describe' must be of type 'SuiteFunction', but here has type 'Describe'.
       ../node_modules/@types/jest/index.d.ts(7,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'xdescribe' must be of type 'PendingSuiteFunction', but here has type 'Describe'.
       ../node_modules/@types/jest/index.d.ts(8,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'it' must be of type 'TestFunction', but here has type 'It'.
       ../node_modules/@types/jest/index.d.ts(10,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'xit' must be of type 'PendingTestFunction', but here has type 'It'.
       ../node_modules/@types/jest/index.d.ts(11,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'TestFunction', but here has type 'It'.
       ../node_modules/@types/jest/index.d.ts(1198,22): error TS2344: Type 'T' does not satisfy the constraint 'new (...args: any) => any'.
         Type 'abstract new (...args: any) => any' is not assignable to type 'new (...args: any) => any'.
           Cannot assign an abstract constructor type to a non-abstract constructor type.
       ../node_modules/@types/jest/index.d.ts(1199,31): error TS2344: Type 'T' does not satisfy the constraint 'new (...args: any) => any'.
         Type 'abstract new (...args: any) => any' is not assignable to type 'new (...args: any) => any'.
           Cannot assign an abstract constructor type to a non-abstract constructor type.


 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  Lerna (powered by Nx)   Ran target build for 7 projects (7s)

    ✔    3/4 succeeded [0 read from cache]

    ✖    1/4 targets failed, including the following:
         - maci-circuits:build

@samajammin
Copy link
Member

Ah, interesting, looks like maybe some jest <> mocha clashing on the type defintions?

~/code/pse/maci/circuits on  feat/typedocs [⇕$!] via ⬢ v18.18.2
➜ npm run build

> [email protected] build
> tsc

../node_modules/@types/jest/index.d.ts:2:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'HookFunction', but here has type 'Lifecycle'.

2 declare var beforeEach: jest.Lifecycle;
              ~~~~~~~~~~

  node_modules/@types/mocha/index.d.ts:2638:13
    2638 declare var beforeEach: Mocha.HookFunction;
                     ~~~~~~~~~~
    'beforeEach' was also declared here.

@samajammin
Copy link
Member

samajammin commented Nov 2, 2023

This seems to fix the issue: https://stackoverflow.com/questions/55680391/typescript-error-ts2403-subsequent-variable-declarations-must-have-the-same-typ

i.e. adding this to tsconfig.json:

"compilerOptions": {
    "skipLibCheck": true
},

Not sure if we SHOULD add that though... any thoughts? 🤔

@samajammin
Copy link
Member

So now build passes but still failures running docs 😖

~/code/pse/maci on  feat/typedocs [⇕$!] via ⬢ v18.18.2
➜ npm run docs

> [email protected] docs
> typedoc --options typedoc.json

circuits/ts/__tests__/CalculateTotal.test.ts:12:5 - error TS2304: Cannot find name 'before'.

12     before(async () => {
       ~~~~~~
...

I suspect more mocha/jest clash or import issues?

Copy link

netlify bot commented Nov 3, 2023

Deploy Preview for candid-cranachan-1cd06a failed.

Name Link
🔨 Latest commit d3981bc
🔍 Latest deploy log https://app.netlify.com/sites/candid-cranachan-1cd06a/deploys/6550ad2655e4ef0008c2e997

Copy link
Member

@samajammin samajammin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything now working on my end! I believe #819 fixed all my dependency issues.

Copy link
Member

@baumstern baumstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@baumstern baumstern merged commit 16628dd into dev Nov 13, 2023
8 of 11 checks passed
@ctrlc03 ctrlc03 deleted the feat/typedocs branch November 23, 2023 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add typedoc for better TS documentation
3 participants