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

Type VectorSource<Feature<Geometry>> is not assignable to type VectorSource<FeatureLike> #15830

Closed
codeflyA opened this issue May 16, 2024 · 12 comments · Fixed by #15831
Closed
Labels

Comments

@codeflyA
Copy link

this ts issue not happen in ol 9.1.0 happen in 9.2.0

image

@codeflyA codeflyA added the bug label May 16, 2024
@ahocevar
Copy link
Member

ahocevar commented May 16, 2024

@codeflyA Sorry, I cannot reproduce this. But since there are several thumbs-up on this, can anyone affected by this issue share a minimal reproduction repository?

@ahocevar
Copy link
Member

Never mind. Able to reproduce now.

@ahocevar
Copy link
Member

@codeflyA Does your project have a tsconfig.json? I can only reproduce the issue in projects without a tsconfig.json.

Does the issue go away when you add a tsconfig.json? If you have one already, please share a minimal reproduction repository.

@ahocevar
Copy link
Member

@codeflyA #15831 should fix this. At least in the case that I could reproduce, it does.

@alok-runner
Copy link

https://github.com/alok-runner/ol-15830


src/App.tsx:14:7 - error TS2322: Type 'VectorSource<Feature<Circle>>' is not assignable to type 'VectorSource<FeatureLike>'.
  Types of property 'setLoader' are incompatible.
    Type '(loader: FeatureLoader<Feature<Circle>>) => void' is not assignable to type '(loader: FeatureLoader<FeatureLike>) => void'.
      Types of parameters 'loader' and 'loader' are incompatible.
        Types of parameters 'arg4' and 'arg4' are incompatible.
          Type '((arg0: Feature<Circle>[]) => void) | undefined' is not assignable to type '((arg0: FeatureLike[]) => void) | undefined'.
            Type '(arg0: Feature<Circle>[]) => void' is not assignable to type '(arg0: FeatureLike[]) => void'.
              Types of parameters 'arg0' and 'arg0' are incompatible.
                Type 'FeatureLike[]' is not assignable to type 'Feature<Circle>[]'.
                  Type 'FeatureLike' is not assignable to type 'Feature<Circle>'.
                    Type 'Feature<Geometry>' is not assignable to type 'Feature<Circle>'.

14       source: new VectorSource({
         ~~~~~~

src/App.tsx:23:7 - error TS2322: Type 'Cluster' is not assignable to type 'VectorSource<FeatureLike>'.
  Types of property 'setLoader' are incompatible.
    Type '(loader: FeatureLoader<Feature<Geometry>>) => void' is not assignable to type '(loader: FeatureLoader<FeatureLike>) => void'.
      Types of parameters 'loader' and 'loader' are incompatible.
        Types of parameters 'arg4' and 'arg4' are incompatible.
          Type '((arg0: Feature<Geometry>[]) => void) | undefined' is not assignable to type '((arg0: FeatureLike[]) => void) | undefined'.
            Type '(arg0: Feature<Geometry>[]) => void' is not assignable to type '(arg0: FeatureLike[]) => void'.
              Types of parameters 'arg0' and 'arg0' are incompatible.
                Type 'FeatureLike[]' is not assignable to type 'Feature<Geometry>[]'.
                  Type 'FeatureLike' is not assignable to type 'Feature<Geometry>'.
                    Type 'RenderFeature' is missing the following properties from type 'Feature<Geometry>': on, once, un, geometryName_, and 39 more.

23       source: new Cluster({
         ~~~~~~

src/App.tsx:25:9 - error TS2322: Type 'VectorSource<Feature<Point>>' is not assignable to type 'VectorSource<Feature<Geometry>>'.
  Types of property 'setLoader' are incompatible.
    Type '(loader: FeatureLoader<Feature<Point>>) => void' is not assignable to type '(loader: FeatureLoader<Feature<Geometry>>) => void'.
      Types of parameters 'loader' and 'loader' are incompatible.
        Types of parameters 'arg4' and 'arg4' are incompatible.
          Type '((arg0: Feature<Point>[]) => void) | undefined' is not assignable to type '((arg0: Feature<Geometry>[]) => void) | undefined'.
            Type '(arg0: Feature<Point>[]) => void' is not assignable to type '(arg0: Feature<Geometry>[]) => void'.
              Types of parameters 'arg0' and 'arg0' are incompatible.
                Type 'Feature<Geometry>[]' is not assignable to type 'Feature<Point>[]'.
                  Type 'Feature<Geometry>' is not assignable to type 'Feature<Point>'.

25         source: new VectorSource({
           ~~~~~~

  node_modules/ol/source/Cluster.d.ts:52:5
    52     source?: VectorSource<Feature<import("../geom.js").Geometry>> | undefined;
           ~~~~~~
    The expected type comes from property 'source' which is declared here on type 'Options'


@ahocevar
Copy link
Member

@alok-runner That's a different issue, because ol/source/Cluster is affected here. But it's similar enough for me to attempt adding a fix in #15831.

@codeflyA
Copy link
Author

the issue happen when i has a tsconfig.json
this is a minimal reproduction repository
git@github.com:codeflyA/openlayerIssue.git
https://github.com/codeflyA/openlayerIssue
@ahocevar

@tschaub
Copy link
Member

tschaub commented May 16, 2024

@codeflyA - Can you try your example with the latest ol@dev version?

@codeflyA
Copy link
Author

issue fix in 9.2.1-dev.1715868460880 thanks

@tschaub
Copy link
Member

tschaub commented May 16, 2024

You can get the fix in the ol@9.2.1 release.

@zdila
Copy link

zdila commented Jun 10, 2024

I have the same problem also in 9.2.1 and 9.2.4. In version 9.1.0 it compiles without errors.

@ahocevar
Copy link
Member

Please use ol@dev, which contains the final fixes to these issues.

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.

5 participants