I have some simple TypeScript code that uses OpenLayers that I can compile into JavaScript, load into a browser and everything works fine:
var map = new ol.Map({
target: 'map',
layers: [new ol.layer.Tile({source: new ol.source.OSM()})],
view: new ol.View({
center: [0, 0],
zoom: 4
})
});
However as soon as I try to import a second code file into the main file I get an error that I cannot resolve:
import {SomeClass} from "./SomeClass";
var map = new ol.Map({
// ... save as above
index.ts(3,15): error TS2686: 'ol' refers to a UMD global, but the current file is a module. Consider adding an import instead.
Compiling against OpenLayers types installed like so:
npm install --save-dev openlayers
npm install --save-dev @types/openlayers
How can I compile a TypeScript code base with multiple code files that uses OpenLayers?