question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve overall typing of openlayers

See original GitHub issue

At 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:closed
  • Created 3 years ago
  • Comments:21 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
tschaubcommented, Jan 29, 2021

Another idea is to get rid of BaseObject altogether. I would be in favor of doing this in a v7.

1reaction
simonseyockcommented, May 17, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to improve OpenLayer Vector layers refresh for 200 ...
I tried your code with forEach method, inverse order, ++counter and the result still the same, so the problem could be map.
Read more >
OpenLayers v7.2.2 API - Class: VectorSource
When features are removed and added frequently, and the total number of features is low, setting this to false may improve performance.
Read more >
Is there OpenLayers layer type that supports just labels?
In case you use MapServer, you can create layer of TYPE annotation that will show only features names. From MapServer's documentation:.
Read more >
OpenLayers | Documentation - ArcGIS Developers
OpenLayers is an open source JavaScript library used to make interactive maps. It features a rich variety of interactive cartographic features and can ......
Read more >
@types/openlayers - npm
Start using @types/openlayers in your project by running `npm i ... TypeScript icon, indicating that this package has built-in type ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found