Definitelytyped: calling openlayers namespaces functions - ol 5.2 and @types/ol 4.6.2

Created on 3 Sep 2018  路  4Comments  路  Source: DefinitelyTyped/DefinitelyTyped

  • [X] I tried using the @types/ol package and had problems.
  • [X] I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • [X] I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • [X] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @yairtawil @osechet @wb14123 ...

I am trying to use some functions such as easeOut (found in the easing namespace), if I try to import it as
import {easeOut} from 'ol/easing';
I get a compiler error:
ERROR in src/app/app.component.ts(9,9): error TS2305: Module '"/home/data/hacknight/stomp/node_modules/@types/ol/easing/index"' has no exported member 'easeOut'.

even if the produced js works and correctly calls the function.
If I add:
export function easeOut(t: number): number;

in @types/ol/easing/index.d.ts everything seems to work fine but I am not sure if this is the right way to fix this issue - are 5.2 @types underway?

Thanks!

Most helpful comment

Related issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/28500

The latest version of @types/ol is 4.6.2 and unfortunately it doesn't look like there's any progress made towards the 5.x version typings. From this comment it looks like types definition are going to be dropped by the OpenLayers team in favour of native TypeScript support (which is currently blocked because of some issues with the compiler, apparently).

The possible solutions for now would seem to be two:

  1. Drop the @types/ol package altogether and hope for the TypeScript support to be completed soon
  2. If you're not willing to drop the type annotations, stay on the OpenLayers 4.6.2 release and upgrade after the TypeScript support is complete

All 4 comments

Related issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/28500

The latest version of @types/ol is 4.6.2 and unfortunately it doesn't look like there's any progress made towards the 5.x version typings. From this comment it looks like types definition are going to be dropped by the OpenLayers team in favour of native TypeScript support (which is currently blocked because of some issues with the compiler, apparently).

The possible solutions for now would seem to be two:

  1. Drop the @types/ol package altogether and hope for the TypeScript support to be completed soon
  2. If you're not willing to drop the type annotations, stay on the OpenLayers 4.6.2 release and upgrade after the TypeScript support is complete

Perfect, thank you very much, I was not able to discover all the related issues and the future native TypeScript support :)

any update?

Was this page helpful?
0 / 5 - 0 ratings