Definitelytyped: [@types/googlemaps] Generic type 'MapHandlerMap<T>' requires 1 type argument(s)

Created on 7 Oct 2020  路  20Comments  路  Source: DefinitelyTyped/DefinitelyTyped

Hello,

I receive this error in the production build phase of my Angular10 project, I use @agm/core ver.3.0.0-beta.0. Everything was working fine until the new release of @types/googlemaps (3.39.14).

These are the errors:

ERROR in node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts:51:41 - error TS2314: Generic type 'MapHandlerMap' requires 1 type argument(s).
51 subscribeToMapEvent(eventName: N): Observable

node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts:51:94 - error TS2314: Generic type 'MapHandlerMap' requires 1 type argument(s).
51 subscribeToMapEvent(eventName: N): Observable

Thank you

Most helpful comment

I found a temporary solution, install an earlier version of @types/googlemaps in the package.json, I added @types/googlemaps: "3.39.12" to my devDependencies, now the production build works !

All 20 comments

I changed line 51 of node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts

from: subscribeToMapEvent(eventName: N): Observable to : subscribeToMapEvent>(eventName: N): Observable[N]>;

and both the errors disappeared and compilation could be completed. Application is working. Not sure if it is a solution to this, though....

Thank you for your reply,

Unfortunately, in a context of CI/CD, where everything is installed automatically, this solution won't work ...

I found a temporary solution, install an earlier version of @types/googlemaps in the package.json, I added @types/googlemaps: "3.39.12" to my devDependencies, now the production build works !

Same here. I received it after reinstalling the package.

Thank you for your reply,

Unfortunately, in a context of CI/CD, where everything is installed automatically, this solution won't work ...

Certainly.
But there are two points.....
(1) In the said context of CI/CD, the solution should be incorporated into a new version of the package and distributed, which of course the package owner(s) needs to do. I have no idea as to when they will bring out a solution. So I keep a history of changes I locally makes and verifies upon an automatic version update, if the problem persists. It is only an activity of continuing / maintaining my application.
(2) Downgrading the package is certainly an alternative and waiting for the updated solution. In this case too, another package version upgrade can break ones' application.
Since the issue under consideration was found to be of minor nature (according to me), I thought of modifying package to save outage time of my application, and shared it, thinking that it may help someone or trigger the package developer to look into the issue....
Thank you...

Same issue here, downgrading to 3.39.12 resolved this problem.

Same issue here, downgrading to 3.39.12 worked.

Didn't work for me :(

"dependencies": {
"@agm/core": "^3.0.0-beta.0",
"@angular/animations": "~10.1.5",
"@angular/common": "~10.1.5",
"@angular/compiler": "~10.1.5",
"@angular/core": "~10.1.5",
"@angular/forms": "~10.1.5",
"@angular/platform-browser": "~10.1.5",
"@angular/platform-browser-dynamic": "~10.1.5",
"@angular/router": "~10.1.5",
"@types/googlemaps": "^3.39.12",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1001.5",
"@angular/cli": "~10.1.5",
"@angular/compiler-cli": "~10.1.5",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}

Error -
ERROR in node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts:51:41 - error TS2314: Generic type 'MapHandlerMap' requires 1 type argument(s).

51 subscribeToMapEvent(eventName: N): Observable ~~~~~
node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts:51:94 - error TS2314: Generic type 'MapHandlerMap' requires 1 type argument(s).

51 subscribeToMapEvent(eventName: N): Observable

can someone pls help?

thanks
Srikanth

Didn't work for me :(

"dependencies": {
"@agm/core": "^3.0.0-beta.0",
"@angular/animations": "~10.1.5",
"@angular/common": "~10.1.5",
"@angular/compiler": "~10.1.5",
"@angular/core": "~10.1.5",
"@angular/forms": "~10.1.5",
"@angular/platform-browser": "~10.1.5",
"@angular/platform-browser-dynamic": "~10.1.5",
"@angular/router": "~10.1.5",
"@types/googlemaps": "^3.39.12",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1001.5",
"@angular/cli": "~10.1.5",
"@angular/compiler-cli": "~10.1.5",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}

Error -
ERROR in node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts:51:41 - error TS2314: Generic type 'MapHandlerMap' requires 1 type argument(s).

51 subscribeToMapEvent(eventName: N): Observable ~~~~~
node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts:51:94 - error TS2314: Generic type 'MapHandlerMap' requires 1 type argument(s).

51 subscribeToMapEvent(eventName: N): Observable

can someone pls help?

thanks
Srikanth

Hi,

Try erasing node_modules + package.lock and run again npm install.

thanks for the reply, but the problem is not resolved...

thanks for the reply, but the problem is not resolved...

Did you make sure to stop ng process and run ng serve again?

thanks for the reply, but the problem is not resolved...

Did you make sure to stop ng process and run ng serve again?

Oh yes

1) I stopped
2) deleted node_modules & package-lock.json
(tried with "@types/googlemaps": "^3.37.0", "@types/googlemaps": "^3.38.0" , "@types/googlemaps": "^3.40.0")
3) npm install
4) ng serve

Thanks It worked with 3.39.12 :)

Tried with 3.38.0 and still getting the same error.
It has below line already.

subscribeToMapEvent(eventName: N): Observable

to who ever it worked, what is your @agm/core package version?

Tried with 3.38.0 and still getting the same error.
It has below line already.

subscribeToMapEvent(eventName: N): Observable

to who ever it worked, what is your @agm/core package version?

"@agm/core": "^3.0.0-beta.0",

For you to get a specific version of @types/googlemaps

set @types/googlemaps": "3.39.12" in package.json, and then do "npm install"

for more information on symbols used in package.json - https://bytearcher.com/articles/semver-explained-why-theres-a-caret-in-my-package-json/

hope this helps

thank you @cbodapati
It worked with @types/googlemaps": "3.39.12"

Just for the benefit for others
"@types/googlemaps": "3.39.12"

Instead of
@types/googlemaps": "^3.39.12"

Thanks guys, It worked with 3.39.12

I got ERROR :
node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts:51:41 - error TS2314: Generic type 'MapHandlerMap' requires 1 type argument(s).

51     subscribeToMapEvent<N extends keyof google.maps.MapHandlerMap>(eventName: N): Observable<google.maps.MapHandlerMap[N]>;
                                           ~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts:51:94 - error TS2314: Generic type 'MapHandlerMap<T>' requires 1 type argument(s).

51     subscribeToMapEvent<N extends keyof google.maps.MapHandlerMap>(eventName: N): Observable<google.maps.MapHandlerMap[N]>;

SOLUTION:

just inastall
npm install @types/[email protected] --save-dev
npm install @agm/core --save

"@agm/core": "^3.0.0-beta.0",
"@types/googlemaps": "^3.39.12",

the error was resolved by using the small change in package version and its working fine now .

ERROR in node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts:51:41 - error TS2314: Generic type 'MapHandlerMap' requires 1 type argument(s).

51 subscribeToMapEvent(eventName: N): Observable ~~~~~
node_modules/@agm/core/lib/services/google-maps-api-wrapper.d.ts:51:94 - error TS2314: Generic type 'MapHandlerMap' requires 1 type argument(s).

51 subscribeToMapEvent(eventName: N): Observable

please help me to rectify this error.

si pude resolver instalando el plugin npm i @types/[email protected]
Gracias

Was this page helpful?
0 / 5 - 0 ratings