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

Fails to build with the latest typescript #44

Closed
styfle opened this issue Mar 1, 2022 · 3 comments
Closed

Fails to build with the latest typescript #44

styfle opened this issue Mar 1, 2022 · 3 comments
Assignees

Comments

@styfle
Copy link

styfle commented Mar 1, 2022

Problem

TypeScript 4.6.2 was just released and added crypto.randomUUID() in microsoft/TypeScript@4e689bc

This causes @peculiar/webcrypto to fail to build.

Steps to reproduce

Create a new project and install the latest dependencies.

mkdir example
cd example
npm init -y
npm install @peculiar/webcrypto@1.3.0 typescript@4.6.2
echo '{ "compilerOptions": { "module": "commonjs" } }' > tsconfig.json
echo 'import { Crypto } from "@peculiar/webcrypto"' > index.ts
./node_modules/.bin/tsc

Error

@peculiar/webcrypto/index.d.ts:1:22 - error TS2420: Class 'import("@peculiar/webcrypto/index").Crypto' incorrectly implements interface 'Crypto'.
  Property 'randomUUID' is missing in type 'import("@peculiar/webcrypto/index").Crypto' but required in type 'Crypto'.

1 export declare class Crypto implements globalThis.Crypto {
                       ~~~~~~

  node_modules/typescript/lib/lib.dom.d.ts:3652:5
    3652     randomUUID(): string;
@microshine
Copy link
Collaborator

Working on it

@microshine
Copy link
Collaborator

@styfle Please try @peculiar/webcrypto@1.3.1. It implements the missed Crypto::randomUUID method and uses the @types/web type definition file instead of the default lib-dom.

kodiakhq bot pushed a commit to vercel/next.js that referenced this issue Mar 2, 2022
This PR fixes the latest version of `typescript` (4.6.2) that was failing with the following:

```
Type error: Overload signatures must all be optional or required.
  207 |       array: T
  208 |     ): T
> 209 |     randomUUID?(): string
      |     ^
  210 |   }
  211 | }
```

https://github.com/vercel/next.js/runs/5376232868?check_suite_focus=true#step:8:106

- Related to PeculiarVentures/webcrypto#44

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
@styfle
Copy link
Author

styfle commented Mar 2, 2022

It works now, thanks!

@styfle styfle closed this as completed Mar 2, 2022
mandrean added a commit to Anchor-Protocol/anchor-web-app that referenced this issue Apr 13, 2022
mandrean added a commit to Anchor-Protocol/anchor-web-app that referenced this issue Apr 13, 2022
mandrean added a commit to Anchor-Protocol/anchor-web-app that referenced this issue Apr 17, 2022
mandrean added a commit to Anchor-Protocol/anchor-web-app that referenced this issue Apr 24, 2022
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

No branches or pull requests

2 participants