Skip to content

SubtleCrypto methods return PromiseLike instead of Promise #37756

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

Closed
taymonbeal opened this issue Apr 2, 2020 · 2 comments
Closed

SubtleCrypto methods return PromiseLike instead of Promise #37756

taymonbeal opened this issue Apr 2, 2020 · 2 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@taymonbeal
Copy link

TypeScript Version: 3.9.0-dev.20200328

Search Terms:
WebCrypto, web crypto, SubtleCrypto, subtle, PromiseLike

Expected behavior:
Should compile with no errors.

Actual behavior:

Type 'PromiseLike<CryptoKey>' is missing the following properties from type 'Promise<CryptoKey>': catch, [Symbol.toStringTag]

Related Issues:
microsoft/TypeScript-DOM-lib-generator#843 (pull request that should fix this)
microsoft/TypeScript-DOM-lib-generator#60
microsoft/TypeScript-DOM-lib-generator#47

Code

const keyPromise: Promise<CryptoKey> = crypto.subtle.generateKey({name: 'AES-GCM', length: 256}, true, ['encrypt']);
Output
"use strict";
const keyPromise = crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, true, ['encrypt']);
Compiler Options
{
  "compilerOptions": {
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "noImplicitThis": true,
    "noImplicitReturns": true,
    "alwaysStrict": true,
    "esModuleInterop": true,
    "declaration": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "moduleResolution": 2,
    "target": "ES2017",
    "jsx": "React",
    "module": "ESNext"
  }
}

Playground Link: Provided

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this labels Apr 21, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Apr 21, 2020
@taymonbeal
Copy link
Author

I've already sent a PR to fix this at microsoft/TypeScript-DOM-lib-generator#843. It just needs to be reviewed.

@jakebailey
Copy link
Member

This was fixed in #39052.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants