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

TypeScript types for the format GeoJSON cause compilation errors #13881

Open
javier-lopez-1s opened this issue Jul 26, 2022 · 11 comments
Open

TypeScript types for the format GeoJSON cause compilation errors #13881

javier-lopez-1s opened this issue Jul 26, 2022 · 11 comments
Labels

Comments

@javier-lopez-1s
Copy link

Describe the bug
I am using OpenLayers 6.15.1 in an Angular 14 application and when I make use of the GeoJSON format I get the following compilation errors:

ERROR: node_modules/ol/format/GeoJSON.d.ts:2:36 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

2 export type GeoJSONObject = import("geojson").GeoJSON;
node_modules/ol/format/GeoJSON.d.ts:3:37 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

3 export type GeoJSONFeature = import("geojson").Feature;
node_modules/ol/format/GeoJSON.d.ts:4:47 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

4 export type GeoJSONFeatureCollection = import("geojson").FeatureCollection;
node_modules/ol/format/GeoJSON.d.ts:5:38 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

5 export type GeoJSONGeometry = import("geojson").Geometry;
node_modules/ol/format/GeoJSON.d.ts:6:35 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

6 export type GeoJSONPoint = import("geojson").Point;
node_modules/ol/format/GeoJSON.d.ts:7:40 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

7 export type GeoJSONLineString = import("geojson").LineString;
node_modules/ol/format/GeoJSON.d.ts:8:37 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

8 export type GeoJSONPolygon = import("geojson").Polygon;
node_modules/ol/format/GeoJSON.d.ts:9:40 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

9 export type GeoJSONMultiPoint = import("geojson").MultiPoint;
node_modules/ol/format/GeoJSON.d.ts:10:45 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

10 export type GeoJSONMultiLineString = import("geojson").MultiLineString;
node_modules/ol/format/GeoJSON.d.ts:11:42 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

11 export type GeoJSONMultiPolygon = import("geojson").MultiPolygon;
node_modules/ol/format/GeoJSON.d.ts:12:48 - error TS2307: Cannot find module 'geojson' or its corresponding type declarations.

12 export type GeoJSONGeometryCollection = import("geojson").GeometryCollection;

The error disappears if I add the following dependency:
npm install @types/geojson --save-dev

To Reproduce
Steps to reproduce the behavior:

  1. ng new test-app
  2. cd test-app
  3. npm install ol
  4. Add lines 2 and 10 to app.component.ts
import { Component } from '@angular/core';
import GeoJSON from 'ol/format/GeoJSON';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  myType = GeoJSON;
  title = 'test-app';
}
  1. ng build

Expected behavior
Not to have to add the dependency @types/geojson in order to get rid of the compilation errors. The same issue happens with the format EsriJSON, so I am guessing that the installation of multiple dependencies may potentially be required.

@ahocevar
Copy link
Member

It should be enough to move these types from devDependencies to dependencies in package.json. If you'd be able to try this and provide a pull request, it would be appreciated.

@javier-lopez-1s
Copy link
Author

Thanks @ahocevar. I was testing your proposal and I have found out that if I compile OpenLayers locally, then I no longer get the error. So a basic Angular application compiles without problems if I do the following:

  1. Clone OpenLayers' repository.
  2. Compile OpenLayers via npm run build-package. The file package.json is left untouched.
  3. Import local version of ol/format/GeoJSON into my Angular application.
  4. ng build

However if I import GeoJSON from the OpenLayers' NPM package, then I get the error back again.

@ahocevar
Copy link
Member

ahocevar commented Aug 1, 2022

Sorry, I think my previous comment was confusing. What I wrote was a suggestion to fix the problem in OpenLayers, so it was about OpenLayers's package.json.

@javier-lopez-1s
Copy link
Author

javier-lopez-1s commented Aug 1, 2022

I understood your first comment, @ahocevar. I updated OpenLayers' package.json moving @types/geojson and other types from devDependencies to dependencies. My problem was that I couldn't replicate the issue using a local repository because the code generated at build/ol could still find node_modules/@types/geojson. I finally figured out I had to create a local NPM package. After that, I can confirm that moving @types/geojson from devDependencies to dependencies fixes the issue.
From the following devDependencies, I know that the three in bold needs to be moved, but I not sure about the other two. For the pull request to be provided, should I move them all?

  • @types/arcgis-rest-api
  • @types/geojson
  • @types/offscreencanvas
  • @types/pbf
  • @types/topojson-specification

@ahocevar
Copy link
Member

ahocevar commented Aug 2, 2022

Only those that are used in the public API are needed:

  • @types/arcgis-rest-api
  • @types/geojson

@javier-lopez-1s
Copy link
Author

You get the same error if you import the format TopoJSON, as this is in turn importing types from topojson-specification. In a few days I will create a PR in which I will be moving the 3 items below:

  • @types/arcgis-rest-api
  • @types/geojson
  • @types/topojson-specification

Thanks

@mediafreakch
Copy link

Just ended up here and thought it's worth mentioning: There is also a type issue in a dependency of ol called geotiff:

TS2304: Cannot find name 'Source'.

It has been fixed on master there in March, but there haven't been any new releases since.

@ahocevar
Copy link
Member

ahocevar commented Aug 4, 2022

@mediafreakch That's a different issue, which was reported recently in #13924.

@MarkoDotCom
Copy link

installing typescript types npm libraries fixed my issue, very similar to yours.

$ npm i @types/geojson

@bjarkehs
Copy link

You get the same error if you import the format TopoJSON, as this is in turn importing types from topojson-specification. In a few days I will create a PR in which I will be moving the 3 items below:

  • @types/arcgis-rest-api
  • @types/geojson
  • @types/topojson-specification

Thanks

Did you ever get around to this? Else I'll gladly do it. I just ran into this issue recently as well.

@javier-lopez-1s
Copy link
Author

Did you ever get around to this? Else I'll gladly do it. I just ran into this issue recently as well.

I never found the time to create a PR. Please go ahead if you can. Thanks.

bakcsa83 pushed a commit to awst-austria/qa4sm that referenced this issue Oct 20, 2023
I guess they can be removed later once the official npm package includes them.
openlayers/openlayers#13881
sheenaze added a commit to awst-austria/qa4sm that referenced this issue Dec 6, 2023
* update gitignore

* update proxy config

* add geojson endpoint

* fixing merge error

* remove prev. changes

* adding extra Openlayers dependencies.
I guess they can be removed later once the official npm package includes them.
openlayers/openlayers#13881

* remove unnecessary type dependency

* work in progress

* remove obsolete fixture

* some error handling

* implementing rest of the filtering

* add back networks fixture

* add description for geoinfo.json

* Release 2.4.4 (#772)

* order of loading fixtures changed

* release 2.4.4 prepared

* Exclude user data as reference (#773)

* user dataset can be selected max n-1 times, as it can not be spatial reference

* user dataset can not be selected as the spatial reference

* explanation added to the tooltip

* release note updated

* Rabit version downgraded to avoid issues with connection between work… (#777)

* Rabit version downgraded to avoid issues with connection between worker and celery containers; release prepared

* release note udpated

* add clustered points

* fixing entrypoint.sh

---------

Co-authored-by: Zoltan Bakcsa <bakcsa@awst.at>
sheenaze added a commit to awst-austria/qa4sm that referenced this issue Feb 9, 2024
* update gitignore

* update proxy config

* add geojson endpoint

* fixing merge error

* remove prev. changes

* adding extra Openlayers dependencies.
I guess they can be removed later once the official npm package includes them.
openlayers/openlayers#13881

* remove unnecessary type dependency

* work in progress

* remove obsolete fixture

* some error handling

* implementing rest of the filtering

* add back networks fixture

* add description for geoinfo.json

* add clustered points

* fixing entrypoint.sh

* printing commented

* code refinement done

* map legend added

* legend updated; missing interface added

* tooltip for multiple sensors added

* tooltips updated

* single locations with multiple sensors marked separately

* map filter updated to be consistent with ISMN depth filter

* code refinement done; network map filter uncommented

* map updated

* map updated added when frm filter is checked

* frm class removed from the tooltip

* map layer updated

* geojson file view updated, not to throw an error if other than ismn dataset is requested

* geojson file name defined in globals

* ismn package updated to the master branch to prepare geojson files properly

* entrypoint updated to create geojson files

---------

Co-authored-by: Zoltan Bakcsa <bakcsa@awst.at>
sheenaze added a commit to awst-austria/qa4sm that referenced this issue Feb 9, 2024
* update gitignore

* update proxy config

* add geojson endpoint

* fixing merge error

* remove prev. changes

* adding extra Openlayers dependencies.
I guess they can be removed later once the official npm package includes them.
openlayers/openlayers#13881

* remove unnecessary type dependency

* work in progress

* remove obsolete fixture

* some error handling

* implementing rest of the filtering

* add back networks fixture

* add description for geoinfo.json

* add clustered points

* fixing entrypoint.sh

* printing commented

* code refinement done

* map legend added

* legend updated; missing interface added

* tooltip for multiple sensors added

* tooltips updated

* single locations with multiple sensors marked separately

* map filter updated to be consistent with ISMN depth filter

* code refinement done; network map filter uncommented

* map updated

* map updated added when frm filter is checked

* frm class removed from the tooltip

* map layer updated

* geojson file view updated, not to throw an error if other than ismn dataset is requested

* geojson file name defined in globals

* ismn package updated to the master branch to prepare geojson files properly

* entrypoint updated to create geojson files

* path updated

* page content centered

---------

Co-authored-by: Zoltan Bakcsa <bakcsa@awst.at>
sheenaze added a commit to awst-austria/qa4sm that referenced this issue Feb 21, 2024
* Ismn on map (#823)

* update gitignore

* update proxy config

* add geojson endpoint

* fixing merge error

* remove prev. changes

* adding extra Openlayers dependencies.
I guess they can be removed later once the official npm package includes them.
openlayers/openlayers#13881

* remove unnecessary type dependency

* work in progress

* remove obsolete fixture

* some error handling

* implementing rest of the filtering

* add back networks fixture

* add description for geoinfo.json

* add clustered points

* fixing entrypoint.sh

* printing commented

* code refinement done

* map legend added

* legend updated; missing interface added

* tooltip for multiple sensors added

* tooltips updated

* single locations with multiple sensors marked separately

* map filter updated to be consistent with ISMN depth filter

* code refinement done; network map filter uncommented

* map updated

* map updated added when frm filter is checked

* frm class removed from the tooltip

* map layer updated

* geojson file view updated, not to throw an error if other than ismn dataset is requested

* geojson file name defined in globals

* ismn package updated to the master branch to prepare geojson files properly

* entrypoint updated to create geojson files

---------

Co-authored-by: Zoltan Bakcsa <bakcsa@awst.at>

* Ismn on map (#824)

* update gitignore

* update proxy config

* add geojson endpoint

* fixing merge error

* remove prev. changes

* adding extra Openlayers dependencies.
I guess they can be removed later once the official npm package includes them.
openlayers/openlayers#13881

* remove unnecessary type dependency

* work in progress

* remove obsolete fixture

* some error handling

* implementing rest of the filtering

* add back networks fixture

* add description for geoinfo.json

* add clustered points

* fixing entrypoint.sh

* printing commented

* code refinement done

* map legend added

* legend updated; missing interface added

* tooltip for multiple sensors added

* tooltips updated

* single locations with multiple sensors marked separately

* map filter updated to be consistent with ISMN depth filter

* code refinement done; network map filter uncommented

* map updated

* map updated added when frm filter is checked

* frm class removed from the tooltip

* map layer updated

* geojson file view updated, not to throw an error if other than ismn dataset is requested

* geojson file name defined in globals

* ismn package updated to the master branch to prepare geojson files properly

* entrypoint updated to create geojson files

* path updated

* page content centered

---------

Co-authored-by: Zoltan Bakcsa <bakcsa@awst.at>

* docker updated (#825)

* Update entrypoint.sh

missing / added

* Update entrypoint.sh

printing added

* Update entrypoint.sh

creating ismn geojson script updated

* Update entrypoint.sh

ismn keyword removed from the path reuirements

* Update entrypoint.sh

data folder updated

* Update entrypoint.sh

var added; 2018 folder excluded

* Ismn on map and geojson (#826)

* docker updated

* file name updated

* permissions added

* Ismn on map and geojson (#827)

* docker updated

* file name updated

* permissions added

* legend updated

* condition updated to work properly

* code refinement done

* disabling validate button added when there are no ismn stations available

* Ismn on map and geojson (#828)

* docker updated

* file name updated

* permissions added

* legend updated

* condition updated to work properly

* code refinement done

* disabling validate button added when there are no ismn stations available

* updating the map added when removing dataset

* Update app-routing.module.ts

about route removed

---------

Co-authored-by: Zoltan Bakcsa <bakcsa@awst.at>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants