question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generic type 'Layer<SourceType, RendererType>' requires 2 type argument(s).

See original GitHub issue

Describe the bug After upgrading our lib to use ol@6.10.0 or ol@6.11.0, the build fails with the above-mentioned errors.

Error: projects/hslayers/src/components/utils/layer-utils.service.ts:408:27 - error TS2314: Generic type 'Layer<SourceType, RendererType>' requires 2 type argument(s).

408   isLayerClustered(layer: Layer<Source>): boolean {

etc.

Our lib is based on Angular (i.e. TypeScript).

There is a question from my side, rather then a direct bug report, whether there was some undocumented breaking change happening between versions 6.9 and 6.10?

To Reproduce Steps to reproduce the behavior:

  1. Use openlayers in a TS application
  2. Use Layer<Source> as a type
  3. Compile the app and see error

Expected behavior No breaking changes when upgrading between minor-releases.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ahocevarcommented, Jan 26, 2022

Thanks @jmacura. I just created #13291, which will fix this issue. No generic types for Layer are required any more, but you may set a Source type (or even a Renderer type, which probably does not make sense in most cases) if you wish.

1reaction
ahocevarcommented, Jan 12, 2022

Apologies for this. Since this change is not a breaking change for JavaScript users, we did not increase the major version. Also see “API change policy” on https://openlayers.org/en/latest/apidoc/.

This change was made for avoiding type casts in the library, and we had not considered the implications for TypeScript users. Ideally, this change would not have had a user facing impact.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generic type 'ControlProps' requires 2 type argument(s). ...
This error is actually originating from a lot of types I've used from @types/react-select including NoticeProps, OptionProps, ValueType, etc. I' ...
Read more >
Generic type 'ElementRef' requires 2 type argument(s)
I updated typescript from 2.7.2 to 2.9.2 (global and local) and the error is not showing anymore. I think the solutions posted in...
Read more >
Type.MakeGenericType(Type[]) Method (System)
A Type representing the constructed type formed by substituting the elements of typeArguments for the type parameters of the current generic type.
Read more >
ts2314: generic type 'ɵɵdirectivedeclaration' requires 6 ...
Angular 9 Ivy - Generic type 'ɵɵFactoryDef' requires 2 type argument(s) Generic type 'Observable<T>' requires 1 type argument Injecting services in custom ...
Read more >
Generic type 'Promise<T, R>' requires 2 type argument
This question is locked. New answers and comments are not allowed. ... I'm working on a NavtiveScript project (Typescript-based). On my local ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found