I am trying to get Leaflet and the plugin to work together in the Ionic 2 project. I installed and imported the Flyer and the poster-path-conversion plugin, as well as the Flyer declaration included in the Definitely. The code works if I add declare var L: any; to ignore type declarations.
These are important parts of the page controller (home.ts):
var polyline = new L.Polyline( L.GeoJSON.coordsToLatLngs([ [114.14314270019531, 22.49479484975443], [114.21798706054688, 22.524608511026262], [114.20768737792969, 22.524608511026262], [114.20768737792969, 22.536024805886974] ]), { weight: 15, draggable: true, transform: true }) .bindPopup("L.Polyline") .addTo(map); polyline.transform.enable();
draggable and transform are invalid parameters in the base sheet (and not .transform ), so I wrote a type declaration file in PROJECT_DIR\node_modules\@types\leaflet-path-transform\index.d.ts . What I have written so far is based on a type declaration for an editable flyer , since this plugin allows you to create new MapOptions when creating an L.Map object.
/// <reference types="leaflet" /> declare namespace L { export interface Polyline { draggable: boolean; } namespace Polyline { export interface PolylineOptions { draggable: boolean; } } }
This only applies to the first option, but failed to clear the TypeScript error:
Typescript Error Argument of type '{ weight: number; draggable: boolean; }' is not assignable to parameter of type 'PolylineOptions'. Object literal may only specify known properties, and 'draggable' does not exist in type 'PolylineOptions'.
Can someone help me figure out what I'm doing wrong here? At first, I thought the new type declaration file was simply ignored, but if I left a typo it would cause new errors, so it seems to have an effect.
In case this helps, here is the environment in which I work:
- Ionic Framework: 2.0.0
- Ionic Native: 2.4.1
- Ionic App Scripts: 1.0.0
- Angular Core: 2.2.1
- Angular CLI Compiler: 2.2.1
- Node: 6.9.4
- OS Platform: Windows 10
- Navigator Platform: Win32
- User agent: Mozilla / 5.0 (Windows NT 10.0; WOW64) AppleWebKit / 537.36 (KHTML, e.g. Gecko) Chrome / 56.0.2924.87 Safari / 537.36