-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Problem in generated ol-externs.js file #2615
Comments
There are also three types whichl appear as unknown: |
this seems to be related to the issues discussed in #2479 For the missing ones, see #2509 (comment) and #2359 |
For the duplicate of |
I'll see what I can do for the missing ones. |
Reopening for the remaining issues. |
Some comments on the missing types:
|
Thanks for the investigation @elemoine. I'll add support for interfaces to the generate-externs task. No need to add an |
There is also an issue with nullable returns; I created a distinct issue #2642 as it also impacts documentation. |
The inheritance relation is also absent from the generated externs. For example, ol.geom.Point extends ol.geom.Geometry, but the Currently, when I pass an ol.geom.Point, to a function taking an ol.geom.Geometry there is a check error. |
I'll add the |
Hi @ahocevar , there is a strange issue where ol.source.Vector extends ol.Observable instead of ol.source.Source in the generated externs. The documentation is correct, though. Could you please have a look to it? |
@gberaudo This is expected, because ol.source.Source is not exportable. The way the inheritance works in the generated externs is that if a parent class is not API, the parent's parent is used, and so on. If none is exported, the top of the inheritance chain is used, which is ol.Observable in this case. |
@ahocevar, it seems strange to me to have an API type extend a non API type. Here is the warning output by the compiler: It would be better if the generator could issue an error so that we can fix Is there a reason not to mark ol.source.Source as API? |
I think instead of marking ol.source.Source as API, I will go back to the previous idea and mark it |
Wait, it is weird that For example, reading the API docs, I'd expect the following to evaluate to layer.getSource() instanceof ol.source.Source Instead, that throws a TypeError: |
What you are describing @elemoine is the result of ol.source.Source not being exported/exportable. And if you look at the API docs, you won't see the constructor. Only the exportable methods. |
But I do see the problem, and a solution would be to make ol.source.Source exportable. So maybe we do want to make base classes exportable - also to allow users to subclass them? Not sure. |
Subclassing is another story. But yes the docs say that |
Do we agree that ol.source.Source and more generally base classes should be exported so that we can do instanceof checks and they be present in the externs so that the compiler throws no error? IMO, it would make sense to have the base classes in the API and documentation and to allow subclassing, but it is less important and we can decide on this particular point later. |
Makes sense to me.
Being able to subclass requires more than "exporting". It also requires externs to prevent renaming of overridable/overloadable methods. |
Makes sense for instanceof checks, agreed. |
Only one remaining issue here as far as I can tell. So if someone creates a pull request that exports the constructors of base classes, then I think we can close this. |
With d9976ca#diff-497c3a47c9cdc970f191c9e4e852833c the generated
ol-externs.js
file includes multiple definitions ofol.format.WFS
. There's a definition before the@typedef
's forFeatureCollectionMetadata
andTransactionResponse
, and another one for theol.format.WFS
constructor itself.@ahocevar, do you know where the problem comes from?
The text was updated successfully, but these errors were encountered: