I'm working at the app which using TS and OpenLayers. I'm trying to build dependency tree so into all app I put import and export statements into my *.ts files.
I've got file 'openlayers.ts' which extended base OpenLayers library. It extended for example openlayers interaction namespace.
My openlayers.ts looks like:
declare namespace ol {
namespace interaction {
interface someEvent {
...
}
class myExtendedClass extends ol.interaction.Pointer {
...
}
}
}
I know that ol namespace
from base OpenLayers library and my extended ol namespace
will be merge. TypeScript documentation clearly described how to merge namespaces.
But my problem began when I had to export my extended namespace, because it is using in my app and before export it - app didn't saw my extended namespace.
My openlayers.ts now looks like:
export declare namespace ol {
...
}
As you can see into my ol namespace
I have a myExtendedClass
which need to extend ol.iteraction.Pointer
(from base OpenLayers).
But now, when I exported my namespace, app don't know what it is ol.interaction.Pointer
. So I deduced that I have to import base OpenLayers into my file and my app now will detect what is ol.interaction.Pointer
.
My openlayers.ts now looks like:
import ol = require('openlayers');
export declare namespace ol {
...
}
but now I have the errors:
ol.interaction.Pointer
- (TS) Property 'Pointer' does not exist on type 'typeof interaction'.I really don't know what I should to do. I just started with TS and those errors don't say me too much.
Any sugestions?
Ok, I found the solution.
There were a few problems.
import ol = require('openlayers');
export declare namespace ol
to just declare namespace ol
.I will leave my question and answer for person who will has a similar problem. I will let find solution much faster than I found.