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

Support implicit iterable interfaces #235

Merged
merged 5 commits into from
May 12, 2017

Conversation

saschanaz
Copy link
Contributor

@saschanaz saschanaz commented Apr 20, 2017

This generates a new dom.es6.generated.d.ts which contains [Symbol.iterator] index signature for some interfaces. ('es6' because it should ultimately support setlike and maplike which will add some methods including keys() values() entries() etc.)

Copying from microsoft/TypeScript#5329:

WebIDL says:

If the interface has any of the following:

  • an iterable declaration
  • an indexed property getter and an integer-typed attribute named “length”
  • a maplike declaration
  • a setlike declaration

then a property must exist whose name is the @@iterator symbol, with attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } and whose value is a function object.

Chromium on April 2016 implemented and merged the change based on the criteria number 2.

This means we can add [Symbol.iterator] key for some interfaces and also means that TSJS-lib-generator can automatically add the key but without methods e.g. values().

TS.fsx Outdated
@@ -1466,8 +1468,8 @@ module Emit =
Pt.Reset()
Pt.Printl "/////////////////////////////"
match flavor with
| Worker -> Pt.Printl "/// IE Worker APIs"
| _ -> Pt.Printl "/// IE DOM APIs"
| Worker -> Pt.Printl "/// MSEdge Worker APIs"
Copy link
Contributor

Choose a reason for hiding this comment

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

i would remove MSEdge / IE alltogether.

@mhegazy
Copy link
Contributor

mhegazy commented May 12, 2017

@saschanaz we need to come up with a way to merge this with dom.iterable.d.ts in src/lib in the ts repo.

[Symbol.iterator](): IterableIterator<ClientRect>
}

interface DOMStringList {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@saschanaz saschanaz May 12, 2017

Choose a reason for hiding this comment

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

It meets the standard on WHATWG spec:

interface DOMStringList {
  readonly attribute unsigned long length;
  getter DOMString? item(unsigned long index);
  boolean contains(DOMString string);
};

It has 1. an indexed property getter and 2. an integer-typed attribute named “length”.

@saschanaz
Copy link
Contributor Author

saschanaz commented May 12, 2017

we need to come up with a way to merge this with dom.iterable.d.ts in src/lib in the ts repo.

That file should ultimately be completely replaced by generated one, once we get #227 merged (as current input xml file does not have every needed data). I think we have two options, we can:

  1. have two files temporarily and merge it on TS builder side
  2. support manual type adding as current addedTypes.json does and remove dom.iterable.d.ts completely

@saschanaz
Copy link
Contributor Author

I'm not sure what happened on Travis side.

@mhegazy
Copy link
Contributor

mhegazy commented May 12, 2017

new mono 5.0, not sure why..

@mhegazy mhegazy closed this May 12, 2017
@mhegazy mhegazy reopened this May 12, 2017
@mhegazy mhegazy merged commit 4e3b084 into microsoft:master May 12, 2017
@saschanaz saschanaz deleted the implicit-iterable branch May 12, 2017 23:01
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.

3 participants