Skip to content
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

Improve some nullable map types #13328

Merged
merged 2 commits into from
Feb 7, 2022
Merged

Conversation

EvertEt
Copy link
Contributor

@EvertEt EvertEt commented Feb 4, 2022

Closes #13326

I left out the interactions for now, they could probably also be improved.

src/ol/control/Control.js Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Feb 4, 2022

📦 Preview the examples and docs from this branch here: https://deploy-preview-13328--ol-site.netlify.app/.

src/ol/Overlay.js Outdated Show resolved Hide resolved
src/ol/control/Control.js Outdated Show resolved Hide resolved
@@ -121,7 +121,7 @@ class Control extends BaseObject {
}
this.listenerKeys.length = 0;
this.map_ = map;
if (this.map_) {
if (map) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better TS type inference inside the if

src/ol/Overlay.js Outdated Show resolved Hide resolved
Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @EvertEt

return /** @type {import("./PluggableMap.js").default|undefined} */ (
this.get(Property.MAP)
return /** @type {import("./PluggableMap.js").default|null} */ (
this.get(Property.MAP) || null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this looks like a breaking change, it actually only fixes the inconsistency that when previouslyMap#removeOverlay() was called, a subsequent call of Overlay#getMap() returned null, but when called after Overlay creation, it returned undefined.

@ahocevar ahocevar merged commit ec1eec8 into openlayers:main Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Layer.setMap(null) does not work in typescript strict mode
2 participants