x)- [x] bug report -> please search issues before submitting
- [ ] feature request
@angular/cli: 1.0.0
node: 7.4.0
os: darwin x64
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.1
I have an existing app that uses google's 'gapi' and 'gapi.auth2.'
Installed using the following package.json:
"dependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@types/gapi": "0.0.31",
"@types/gapi.auth2": "0.0.35",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4",
"ng2-bootstrap": "1.6.0",
"angular2-jwt": "^0.2.0",
"bootstrap": "3.2.0",
"ng2-nouislider": "^1.5.2",
"nouislider": "^9.2.0",
"moment": "2.18.1"
},
"devDependencies": {
"@angular/cli": "1.0.0",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"@types/jwt-decode": "^1.4.28",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0"
}
}
running serve or build while trying to use the gapi as I have before:
"private googleToken: gapi.auth2.AuthResponse;"
Throws an error saying the gapi namespace cannot be found.
This works fine when not using the cli.
/my-app/src/app/security/components/google-sign-in/google-sign-in.ts (58,5): Cannot find name 'gapi'
I'd like it to actually serve/build the application.
Can you specify how you are importing google api gapi library code in your file?
Can you provide a detailed reproduction of how this error can be seen?
Closing as inactive.
Steps to reproduce:
1) Install @types/gapi as dev dep
2) Use any where in code
export class Test { googleUser: gapi.auth2.GoogleUser }
3) ng build
Found a solution!
Just add types to tsconfig.app.json
{
"compilerOptions": {
"types": ["gapi", "gapi.auth2"]
}
}
https://stackoverflow.com/questions/38091215/import-gapi-auth2-in-angular-2-typescript
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
Found a solution!
Just add types to tsconfig.app.json
https://stackoverflow.com/questions/38091215/import-gapi-auth2-in-angular-2-typescript