TypeScript types for the format GeoJSON cause compilation errors
See original GitHub issueDescribe 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:
ng new test-app
cd test-app
npm install ol
- 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';
}
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.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Typescript assignment causes compilation error - Stack Overflow
1 Answer 1 ... The error is not about assignment, it's about calling JSON.parse() function. Error looks like your data variable is already...
Read more >TSConfig Reference - Docs on every TSConfig option
An error occurs if any of the files can't be found. This is useful when you only have a small number of files...
Read more >TypeScript errors and how to fix them
This error occurs when you import the same file in two different files using two different casing styles (ex. camelCase and UpperCamelCase):.
Read more >Take control of unexpected data at runtime with TypeScript
In this article, we'll explore how to use TypeScript type ... returning HTML-formatted error responses with OK (200) status from JSON APIs, ...
Read more >Troubleshooting | ts-node - TypeStrong · GitHub
... errors from ts-node, errors from the TypeScript compiler, and errors from node . It is also important to understand when errors are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mediafreakch That’s a different issue, which was reported recently in #13924.
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:Thanks