Improve overall typing of openlayers
See original GitHub issueAt the moment I am looking into how to improve the typing of openlayers to improve a) typechecking (also in dependent projects) and b) generation of typescript typings.
Options
One huge issue that I have with the typing of openlayers are the Options
objects of the layers. They all have a certain amount of strictly typed properties and can also accept arbitrary properties that get passed to the BaseObject
. For typing purposes this bad.
What I would like to see is that all Options
objects would get a property properties
which would get passed to the BaseObject
. I would like to look into this if you like the idea. This would be a breaking change and would only get included in v7. This mainly would affect the api of the layer types.
Nevertheless I found a way to type this properly in JSDoc, namely using
* @param {Options & Object<string, *>} opt_options Options.
Here is a PR for this: https://github.com/openlayers/openlayers/pull/11959
BaseObject
Maybe it is possible to incorporate @template
Variables for the properties ( https://github.com/openlayers/openlayers/issues/11572 ).
Generic source types for layers
I created a PR for improved generic source types of layers here: https://github.com/openlayers/openlayers/pull/11948
The Layer
and BaseVectorLayer
were already using it but all other types are missing it. This mainly improves the types of getSource
and setSource
, but also improves assignability. For example assignig an ImageLayer
to a variable of a type Layer<ImageSource>
.
I will continue to gather some issues here.
Issue Analytics
- State:
- Created 3 years ago
- Comments:21 (18 by maintainers)
Top GitHub Comments
Another idea is to get rid of BaseObject altogether. I would be in favor of doing this in a v7.
FYI: I created https://github.com/simonseyock/jsdoc-type-pratt-parser and will see what the folks at jsdoc think about it: https://github.com/jsdoc/jsdoc/issues/1917