I am using the below, standard (I assume) code to create a select interaction, add it on a map and take some actions when a feature is selected or deselected:
const select: Select = new Select({
hitTolerance: 5,
multi: false,
condition: singleClick
});
this.map.addInteraction(select);
select.on('select', (se: SelectEvent) => {
console.log('select fired: ', se);
// do some stuff using se...
});
My problem is that I am using TypeScript and would like to take full advantage of type-checking but I can't figure out where to import SelectEvent
from. So the above code fails type-checking with:
`TS2304: Cannot find name 'SelectEvent'`
When I try:
import {SelectEvent} from 'ol/interaction';
I get:
TS2305: Module '"../../../node_modules/@types/ol/interaction"' has no exported member 'SelectEvent'.
The open layers - relevant section of my package.json
is:
$ npm ls --depth=0 | grep -i ol | grep -v polyfill
├── @siedlerchr/[email protected] (git+https://github.com/Siedlerchr/types-ol-ext.git#ec995982b2ba7aa4d415e67a350ec4b9f841ea37)
├── @types/[email protected]
├── [email protected]
├── [email protected]
Grepping for the SelectEvent
type I found:
node_modules/@types/ol/interaction/Select.d.ts:declare class SelectEvent extends BaseEvent {
.. but it is not clear to me how to import this declaration (also it doesn't seem to even be exported to begin with).
question from:
https://stackoverflow.com/questions/65873168/where-is-selectorevent-defined-and-how-to-import-it-for-type-checking-purposes 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…