Skip to main content
added 75 characters in body; edited tags
Source Link
Bmaed Riasbet
  • 15.1k
  • 9
  • 42
  • 57

I am using Leaflet Library (http://leafletjs.com) in a TypeScript project.

I am displaying marker on the map that are configured using options: http://leafletjs.com/reference-1.3.0.html#marker-l-marker

I am trying to use this library in my project: https://github.com/bbecquet/Leaflet.RotatedMarker

I am trying to add more options to second argument of Marker but I am getting typescript errors:

ERROR in src/app/app.component.ts(61,7): error TS2345: Argument of type '{ rotationAngle: number; }' is not assignable to parameter of type 'MarkerOptions'.
  Object literal may only specify known properties, and 'rotationAngle' does not exist in type 'MarkerOptions'

I trying to create a typings script or file to allow me do that.

/// <reference types="leaflet" />

declare module L {
  export interface MarkerOptions { 
    rotationAngle: number;
    rotationOrigin: string;
  }
}

May be something similar to this: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/leaflet/index.d.ts#L1470

What am I missing to make this work ?

How to create custom typings for JavaScript code or third party library that doesn't provide typings out of the box ?

Here is an MCVE: https://github.com/badis/typescript-stackoverflow-question

I am using Leaflet Library (http://leafletjs.com) in a TypeScript project.

I am displaying marker on the map that are configured using options: http://leafletjs.com/reference-1.3.0.html#marker-l-marker

I am trying to add more options to second argument of Marker but I am getting typescript errors:

ERROR in src/app/app.component.ts(61,7): error TS2345: Argument of type '{ rotationAngle: number; }' is not assignable to parameter of type 'MarkerOptions'.
  Object literal may only specify known properties, and 'rotationAngle' does not exist in type 'MarkerOptions'

I trying to create a typings script or file to allow me do that.

/// <reference types="leaflet" />

declare module L {
  export interface MarkerOptions { 
    rotationAngle: number;
    rotationOrigin: string;
  }
}

May be something similar to this: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/leaflet/index.d.ts#L1470

What am I missing to make this work ?

How to create custom typings for JavaScript code or third party library that doesn't provide typings out of the box ?

I am using Leaflet Library (http://leafletjs.com) in a TypeScript project.

I am displaying marker on the map that are configured using options: http://leafletjs.com/reference-1.3.0.html#marker-l-marker

I am trying to use this library in my project: https://github.com/bbecquet/Leaflet.RotatedMarker

I am trying to add more options to second argument of Marker but I am getting typescript errors:

ERROR in src/app/app.component.ts(61,7): error TS2345: Argument of type '{ rotationAngle: number; }' is not assignable to parameter of type 'MarkerOptions'.
  Object literal may only specify known properties, and 'rotationAngle' does not exist in type 'MarkerOptions'

I trying to create a typings script or file to allow me do that.

/// <reference types="leaflet" />

declare module L {
  export interface MarkerOptions { 
    rotationAngle: number;
    rotationOrigin: string;
  }
}

May be something similar to this: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/leaflet/index.d.ts#L1470

What am I missing to make this work ?

How to create custom typings for JavaScript code or third party library that doesn't provide typings out of the box ?

Here is an MCVE: https://github.com/badis/typescript-stackoverflow-question

Source Link
Bmaed Riasbet
  • 15.1k
  • 9
  • 42
  • 57

How to fix typing errors of JavaScript Library?

I am using Leaflet Library (http://leafletjs.com) in a TypeScript project.

I am displaying marker on the map that are configured using options: http://leafletjs.com/reference-1.3.0.html#marker-l-marker

I am trying to add more options to second argument of Marker but I am getting typescript errors:

ERROR in src/app/app.component.ts(61,7): error TS2345: Argument of type '{ rotationAngle: number; }' is not assignable to parameter of type 'MarkerOptions'.
  Object literal may only specify known properties, and 'rotationAngle' does not exist in type 'MarkerOptions'

I trying to create a typings script or file to allow me do that.

/// <reference types="leaflet" />

declare module L {
  export interface MarkerOptions { 
    rotationAngle: number;
    rotationOrigin: string;
  }
}

May be something similar to this: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/leaflet/index.d.ts#L1470

What am I missing to make this work ?

How to create custom typings for JavaScript code or third party library that doesn't provide typings out of the box ?