openlayers: Included typings do not work correctly
I’ve been using types from DefinitelyTyped (https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ol) and all worked fine.
It wants to use new OL included typings in 6.3.0 and ignores the DefinitelyTyped typings. The included types does not work correctly.
Example of included types:

Comparsion between OL types and DefinitelyTyped types

How can I use the OL types in this example where DefinitelyTyped typings are used:
this.draw = new Draw({
source: this.source,
type: GeometryType.POINT,
snapTolerance: 6,
stopClick: true
});
There are many types like this.
How can I exclude/ignore the included types and use types from https://github.com/DefinitelyTyped?
I have angular application with tsconfig.json. I’ve tried ignore section in tsconfig.json but it does not help.

About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 22 (8 by maintainers)
I can confirm that the new patched version works now (using TS 3.8) . It fortunately still works with the types from https://github.com/hanreev/types-ol
This is now my workaround for having types in an Angular project
@ahocevar I still do not know how to use it. Compilation errors:
Is this a valid syntax?
I am using typescript “typescript”: “3.8.3” and latest build “ol”: “6.3.1-dev.1586002061224”.
“skipLibCheck”: true has no effect.
There is a workaround to be able to update openlayers and build application => remove included typings with postintall in package.json
@mhosman It depends on the TypeScript version you are using. If you use TypeScript v3.5.x, the types will work. For newer versions, you’ll need the
"skipLibCheck": trueoption for now, because TypeScript v3.8 still has a bug that causes problems with OpenLayers. See microsoft/TypeScript#33575.@MichalK6677 The inofficial types from DefinitelyTyped were manually created for older versions of OpenLayers, so some of them will very likely be incompatible. My advice would be to update your code to work with the types that ship with OpenLayers when upgrading to v6.3.
I’m pretty sure there are TypeScript users who are unhappy with the types that are derived from the TypeDoc comments. For IntelliSense in VS Code the types included in the library do their job very well.
That said, I think @types/ol still has its justification for TypeScript users, although there should be no issues any more with the included types derived from the TypeDoc comments.
@tomgruszowski I do exactly the same as @MichalK6677. Works fine. The types from hanreev are synced with the official DefinitelyTyped repo.