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

Affecting the ES6 library #47

Closed
rapropos opened this issue Jan 13, 2016 · 7 comments
Closed

Affecting the ES6 library #47

rapropos opened this issue Jan 13, 2016 · 7 comments

Comments

@rapropos
Copy link
Contributor

I am attempting to update the WebCrypto interface definitions, where functions return Promises. If I declare these return values as Promises, tsc will fail to build. If I change this to PromiseLike, it builds fine, but if I am targeting es6 (or using the es6 library via other means), it would be nice to have the return values be actual Promises. Is there a way to specify separate signatures for es5 and es6 libraries?

@mhegazy
Copy link
Contributor

mhegazy commented Jan 13, 2016

We should generate a new file dom.es6.d.ts, that include the definitions that contain es6-specific definitions. and we can wire it in the TS build in https://github.com/Microsoft/TypeScript/blob/master/Jakefile.js#L172

@rapropos
Copy link
Contributor Author

If it's in a separate file, won't there be conflicting definitions in the eventual lib.es6.d.ts output? In this case, the method signature changes depending on the language level.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 13, 2016

if the difference is only in the return types, then we need to to have two separate files that include all definitions. then the build can pick one or the other based on the language version.

@rapropos
Copy link
Contributor Author

Perhaps I'm not properly explaining what I'm worried about. As I understand things, when I add to overridingTypes.json, these changes are reflected both in lib.d.ts and lib.es6.d.ts via dom.generated.d.ts. Let's say we have:

    {
         "kind": "method",
         "interface": "Foo",
         "name": "bar",
         "signatures": ["bar(param:string): PromiseLike<string>"]
     }

So if there is a new file, say overridingTypesEs6.json, and I put the following version in it:

    {
         "kind": "method",
         "interface": "Foo",
         "name": "bar",
         "signatures": ["bar(param:string): Promise<string>"]
     }

...and that gets put into a dom.es6.d.ts file, won't both versions of the declaration try to end up in lib.es6.d.ts? The first version via the existing mechanism, and the second via the proposed new route?

Perhaps there could be an es6-signatures key that would provide method signatures to be picked up in lieu of the ones specified in signatures?

@mhegazy
Copy link
Contributor

mhegazy commented Jan 14, 2016

what i meant is to generate two files here, dom.generated.d.ts and dom.es6.generated.d.ts. the second can be just an augmentation to the first, or it can be a replica of it with only different return types. then in the main ts repo, we would wire the build to pick one or the other based on which lib it is building.

@saschanaz
Copy link
Contributor

Is this fixed by microsoft/TypeScript#14053?

@mhegazy
Copy link
Contributor

mhegazy commented Mar 27, 2017

Yes. we should just use Promise everywhere now.

@mhegazy mhegazy closed this as completed Mar 27, 2017
sandersn pushed a commit that referenced this issue Jun 12, 2020
Previously, these methods returned PromiseLike, even though the spec has
always required them to return real Promises and browsers have always
done so. According to #60, this was done in order to work around #47;
now that #47 has been fixed, this workaround is obsolete.

This generally should not be a breaking change since it is making the
SubtleCrypto type contract stricter and that API is generally
implemented by the platform, not by users.
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

3 participants