Treat unknown opt types as Object in ol externs #2765
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As discussed previously we want to export base classes. This is to be able to do, for example,
source instanceof ol.style.Image
in applications. Exporting base classes means marking them with the@api
annotation.The problem is that, currently, if we just add the
@api
annotation to the base class we get an unknown type for that class' options type in the ol externs file:where
ol.style.ImageOptions
is not declared in the ol externs file.One option involves adding
@api
to the options@typedef
as well. This indeed fixes the problem in the ol externs file. But this creates a broken link in the API doc. In any way, it does not make sense to add@api
to the options@typedef
, because abstract base classes are not meant to be instantiated by applications.This PR fixes the problem by making the
generate-externs.js
script use@typedef {Object}
in the generated externs file for options types that are referenced in "exported" constructors but not marked with an@api
annotation.I have to admit that the code added to
generate-externs.js
is not of the prettiest, but I haven't been able to come up with a prettier solution.Thanks for any review.