Skip to content

Conversation

@saschanaz
Copy link
Contributor

@saschanaz saschanaz commented Nov 14, 2018

Fixes microsoft/TypeScript#17804

Because the Web IDL spec says JS->IDL conversion internally uses Promise.resolve().

An ECMAScript value V is converted to an IDL PromiseT value as follows:

  1. Let promise be ! Call(%Promise_resolve%, %Promise%, «V»).
  2. Return the IDL promise type value that is a reference to the same object as promise.

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Couple of questions about how the code changes map to the changes in *.generated.d.ts.

p = { name: p.name, type: [p.subtype!, p] }
}
const isOptional = !p.variadic && p.optional;
const pType = isOptional ? convertDomTypeToTsType(p) : convertDomTypeToNullableTsType(p);
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand what change this is expected to have on *.generated.d.ts. Is it the change of Promise<any> to any? If so, why?

If there is no change in generated files, then is this just extra cleanup?

Copy link
Contributor Author

@saschanaz saschanaz Jan 24, 2019

Choose a reason for hiding this comment

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

Yes, this is intended to be an extra cleanup, but now I think it's better to just remove convertDomTypeToNullableTsType because convertDomTypeToTsType now also can process nullable types. Currently convertDomTypeToNullableTsType looks redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted this line and moved it to #641.

@sandersn sandersn merged commit 6ec9795 into microsoft:master Jan 25, 2019
@saschanaz saschanaz deleted the promise-resolve branch January 25, 2019 18:37
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.

lib.webworker.d.ts has incorrect description of FetchEvent.respondWith

2 participants