'@types included in 'typeRoots' but only working if explicitly included
I'm attempting to use the grecaptcha types package (@types/grecaptcha
), but even though in my tsconfig
, its setup as:
"typeRoots": [
"node_modules/@types"
],
When I try to utilize the included grecaptcha
object or RecaptchaV2
, I get errors on compile:
Cannot find namespace 'ReCaptchaV2'
Cannot find name 'grecaptcha'
If I explicitly include /// <reference path="../../../../node_modules/@types/grecaptcha/index.d.ts" />
to the top of my file, it works, but from all I can tell, I shouldn't have to do this.
It was suggested I check tsc --listFiles
, and the type files show up there. I'd love any additional advice on figuring out what's going on and correcting it.
I'm building an Angular project, and as I'm using angular-cli, I'm running typescript 2.4.2 if it matters.
Solution 1:[1]
Tried this and it is working fine now.
"typeRoots": ["node_modules/@types"],
"types": ["grecaptcha"],
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Rajiv K.R. |