bluehalo / ngx-leaflet-draw

MIT License
88 stars 29 forks source link

Incompatible types on drawOptions #109

Open mactep opened 3 years ago

mactep commented 3 years ago

I'm facing some errors when passing the drawOptions object. The code works although the console show some errors about incompatible types. I got those errors even when using the drawOptions provided in the README.

error TS2322: Type '{ position: string; draw: { marker: { icon: L.Icon<L.IconOptions>; }; polyline: boolean; circle: { shap
eOptions: { color: string; }; }; rectangle: { shapeOptions: { color: string; }; }; }; edit: { featureGroup: L.FeatureGroup<...>; }; }' is not assignable to type 'DrawConstruc
torOptions'.
      Types of property 'position' are incompatible.
        Type 'string' is not assignable to type 'ControlPosition'.

    9     [leafletDrawOptions]="drawOptions"

If i remove that line I get another error.

error TS2322: Type '{ draw: { marker: { icon: L.Icon<L.IconOptions>; }; polyline: boolean; circle: { shapeOptions: { color:
 string; }; }; rectangle: { shapeOptions: { color: string; }; }; }; edit: { featureGroup: L.FeatureGroup<any>; }; }' is not assignable to type 'DrawConstructorOptions'.
      The types of 'draw.polyline' are incompatible between these types.
        Type 'boolean' is not assignable to type 'false | PolylineOptions'.

    9     [leafletDrawOptions]="drawOptions"

Am I missing something here?

Thank you!

dhutaryan commented 3 years ago

I have the same issue Type 'boolean' is not assignable to type 'false | PolylineOptions'

dhutaryan commented 3 years ago

I've found a solution: set a type as Control.DrawConstructorOptions to your drawOptions