I'm currently developing an app that utilizes TS and OpenLayers. In order to create a dependency tree, I have included import and export statements in my *.ts files.
One of the files is 'openlayers.ts', which extends the base OpenLayers library by adding functionalities to the openlayers interaction namespace.
Here is how my openlayers.ts file looks:
declare namespace ol {
namespace interaction {
interface someEvent {
...
}
class myExtendedClass extends ol.interaction.Pointer {
...
}
}
}
According to TypeScript documentation, the 'ol' namespace from the base OpenLayers library will merge with my extended 'ol' namespace. However, I encountered an issue when trying to export my extended namespace as it was not being recognized by the app without the export statement.
So, I modified my openlayers.ts file to look like this:
export declare namespace ol {
...
}
Within my 'ol' namespace, there is the 'myExtendedClass' which requires extension of 'ol.iteraction.Pointer' from the base OpenLayers.
After exporting the namespace, the app no longer recognizes 'ol.interaction.Pointer'. To resolve this, I concluded that I needed to import the base OpenLayers library into my file.
Therefore, my openlayers.ts now includes an import statement:
import ol = require('openlayers');
export declare namespace ol {
...
}
However, this resulted in errors:
- (TS) individual declarations in merged declaration 'ol' must be all exported or all local.
- At the 'ol.interaction.Pointer' - (TS) Property 'Pointer' does not exist on type 'typeof interaction'.
- (TS) Import declaration conflicts with local declaration of 'ol'
As a beginner in TypeScript, I am unsure of what steps I need to take next. The errors are quite confusing to me. Any suggestions?