Is the API surface of the spec machine readable?

Over in Test for javascript.builtins · Issue #1056 · foolip/mdn-bcd-collector · GitHub I'm trying to figure out if there's already a data source for all of the API surface defined by Ecma262. By this I mean something which could be turned into lists of:

  • Constructors on the global object, like Array
  • What static methods are on that constructor, like Array.isArray
  • What methods are on the prototype, like Array.prototype.forEach
  • What properties are only on instances, like length

Based on this information, it would be possible to generate feature detection tests and cross-check the data in MDN's browser-compat-data project.

I think much of it could be inferred from just the spec's headings, but if the work of turning the spec into a dataset like that has already been done, that would be nice to take a look at.

I'm not aware of any existing efforts, I'm afraid. Perhaps someone else might know of one though.

I would hope it would be relatively straightforward to parse out of the specification (at least ignoring Annex B). For example, I think you can get all the non-Annex B properties of the global object by for searching for is the initial value of the \S+ property of the global object, you can get the static properties of Array by looking at the subclauses of 23.1.2 Properties of the Array Constructor, you can get the prototype properties of Array by looking at the subclauses of 23.1.3 Properties of the Array Prototype Object, etc.

Another approach could be to use the TypeScript definitions

TypeScript provides an API for walking the AST