json_schema_compiler doesn't typedef Objects in a .json API |
|||
Issue description
When generating externs from a .json extension API via json_schema_compiler, types with no properties aren't handled well.
Example (from bookmark_manager_private.json):
"types": [...
{
"id": "MetaInfoFields",
"type": "object",
"description": "Collection of meta info fields.",
"additionalProperties": {"type": "string"}
}...
Here, we don't specify any concrete properties on the MetaInfoFields type. It's just a bag of an arbitrary number of arbitrary properties. In other words, an {Object}.
(Note: additionalProperties means the type can include arbitrary properties, in this case of type string, but AFAICT, these are ignored in generating the externs.)
When it sees that MetaInfoFields has no properties, js_externs_generator.py skips adding the @typedef to the jsdoc comment:
/**
* Collection of meta info fields.
* @see https://developer.chrome.com/extensions/bookmarkManagerPrivate#type-MetaInfoFields
*/
chrome.bookmarkManagerPrivate.MetaInfoFields;
The result is a Closure error when other parts of the externs file reference MetaInfoFields:
## ../../../../third_party/closure_compiler/externs/bookmark_manager_private.js:160: ERROR -
Bad type annotation. Unknown type chrome.bookmarkManagerPrivate.MetaInfoFields
## * @param {!chrome.bookmarkManagerPrivate.MetaInfoFields} metaInfo
Manually adding @typedef {Object} resolves the above error.
,
May 3 2017
I tried fixing this in js_externs_generator.py: https://codereview.chromium.org/2854183005 but it broke a test (it causes an Object member of a Dictionary in an IDL file to get an additional @typedef line). Not sure if the externs generator is the right place to put it anyway.
,
May 3 2017
,
May 4 2018
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot |
|||
►
Sign in to add a comment |
|||
Comment 1 by michae...@chromium.org
, May 3 2017