问题描述
karma test-runner 错误 TS2503:找不到命名空间“gapi”
ng 测试的跟踪
28 01 2021 14:50:25.878:INFO [karma-server]: Karma v5.2.3 server started at http://localhost:9876/
28 01 2021 14:50:25.878:INFO [launcher]: Launching browsers Firefox with concurrency unlimited
28 01 2021 14:50:25.880:INFO [launcher]: Starting browser Firefox
✔ browser application bundle generation complete.
Error: src/app/auth/AuthModule.ts:12:21 - error TS2503: Cannot find namespace 'gapi'.
12 import GoogleUser = gapi.auth2.GoogleUser;
AuthModule.ts
代码段(在运行应用程序和内部 webstorm
时正确解析)
/// <reference path="../../../node_modules/@types/gapi.auth2/index.d.ts" />
import GoogleUser = gapi.auth2.GoogleUser;
package.json
片段
"dependencies": {
...
"@types/gapi": "0.0.39","@types/gapi.auth2": "0.0.52"
...
}