Skip to content

Affecting the ES6 library #47

Closed
Closed

Description

@rapropos

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?

Activity

  1. mhegazy commented on Jan 13, 2016

    @mhegazy
    Contributor

    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

  2. rapropos commented on Jan 13, 2016

    @rapropos
    ContributorAuthor

    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.

  3. mhegazy commented on Jan 13, 2016

    @mhegazy
    Contributor

    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.

  4. rapropos commented on Jan 13, 2016

    @rapropos
    ContributorAuthor

    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?

  5. mhegazy commented on Jan 14, 2016

    @mhegazy
    Contributor

    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.

  6. saschanaz commented on Mar 27, 2017

    @saschanaz
    Contributor

    Is this fixed by microsoft/TypeScript#14053?

  7. mhegazy commented on Mar 27, 2017

    @mhegazy
    Contributor

    Yes. we should just use Promise everywhere now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions