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

VectorImageLayer options don't accept flat styles #15703

Closed
janruo opened this issue Apr 5, 2024 · 3 comments · Fixed by #15713
Closed

VectorImageLayer options don't accept flat styles #15703

janruo opened this issue Apr 5, 2024 · 3 comments · Fixed by #15713
Labels

Comments

@janruo
Copy link
Contributor

janruo commented Apr 5, 2024

Describe the bug

VectorLayer options type accepts a StyleLike | FlatStyleLike | null | undefined.
VectorImageLayer options type accepts a StyleLike | null | undefined.

* @property {import("../style/Style.js").StyleLike|import("../style/flat.js").FlatStyleLike|null} [style] Layer style. When set to `null`, only

* @property {import("../style/Style.js").StyleLike|null} [style] Layer style. When set to `null`, only

However, VectorImageLayer seems to actually support flat styles, so it looks like FlatStyleLike is just missing from the type definition.

To Reproduce

new VectorImageLayer({
    style: {
        "fill-color": "#0000ff11",
        "stroke-color": "blue"
    } // as any <- forcing it to accept the style works
});

Object literal may only specify known properties, and '"fill-color"' does not exist in type 'StyleLike'.ts(2353)

Expected behavior
Both VectorLayer and VectorImageLayer options should accept flat styles.

@janruo janruo added the bug label Apr 5, 2024
@janruo
Copy link
Contributor Author

janruo commented Apr 5, 2024

Just noticed that the declutter option is also a bit too narrow in VectorImageLayer options.

Both VectorImageLayer and VectorLayer inherit from BaseVectorLayer, so this should work, right?

import { Options as BaseVectorLayerOptions } from "ol/layer/BaseVector";
import VectorImageLayer from "ol/layer/VectorImage";
import VectorSource from "ol/source/Vector";

const options: BaseVectorLayerOptions<VectorSource> = {};

new VectorImageLayer(options);
  Types of property 'declutter' are incompatible.
    Type 'string | number | boolean | undefined' is not assignable to type 'boolean | undefined'.
      Type 'string' is not assignable to type 'boolean | undefined'.ts(2345)

@ahocevar
Copy link
Member

ahocevar commented Apr 5, 2024

Are you able to provide a pull request with the types fixed?

@janruo
Copy link
Contributor Author

janruo commented Apr 5, 2024

Sure, I'll see what I can do some time next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants