LIN*_*NGS 6 typescript typescript-typings angular
我是Typescript和Angular 2的新手.我需要安装一个npm依赖项并在我的angular 2应用程序中使用它.
依赖关系是https://www.npmjs.com/package/ng2-stomp-service
我已经安装了必要的软件包,但我需要将以下内容添加到我的typings.d.ts文件中
declare module 'stompjs';
declare module 'sockjs-client';
Run Code Online (Sandbox Code Playgroud)
我无法typings.d.ts在项目中找到该文件.
到目前为止,我已尝试过以下内容,
npm install typings --global
npm install @types/stompjs
npm isntall @types/sockjs-client
typings install dt~stompjs --save
typings install dt~sockjs-client --save
Run Code Online (Sandbox Code Playgroud)
我有typings.json内容的文件,
{
"dependencies": {
"sockjs-client": "registry:dt/sockjs-client#1.0.3+20160727010356",
"stompjs": "registry:dt/stompjs#2.3.0+20161111105645"
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行我的角度2应用程序与npm start它抛出错误如下
ERROR in D:/Userfiles/subramanians/projects/hand-cricket/node_modules/ng2-stomp-service/dist/stomp.service.ts (27,2): Member 'config' implicitly has an 'any' type.
ERROR in D:/Userfiles/subramanians/projects/hand-cricket/node_modules/ng2-stomp-service/dist/stomp.service.ts (36,2): Member 'queuePromises' implicitly has an 'any[]' type.
ERROR in D:/Userfiles/subramanians/projects/hand-cricket/node_modules/ng2-stomp-service/dist/stomp.service.ts (83,32): Parameter 'str' implicitly has an 'any' type.
ERROR in D:/Userfiles/subramanians/projects/hand-cricket/node_modules/ng2-stomp-service/dist/stomp.service.ts (132,53): Parameter 'response' implicitly has an 'any' type.
ERROR in D:/Userfiles/subramanians/projects/hand-cricket/node_modules/ng2-stomp-service/dist/stomp.service.ts (27,2): Member 'config' implicitly has an 'any' type.
ERROR in D:/Userfiles/subramanians/projects/hand-cricket/node_modules/ng2-stomp-service/dist/stomp.service.ts (36,2): Member 'queuePromises' implicitly has an 'any[]' type.
ERROR in D:/Userfiles/subramanians/projects/hand-cricket/node_modules/ng2-stomp-service/dist/stomp.service.ts (83,32): Parameter 'str' implicitly has an 'any' type.
ERROR in D:/Userfiles/subramanians/projects/hand-cricket/node_modules/ng2-stomp-service/dist/stomp.service.ts (132,53): Parameter 'response' implicitly has an 'any' type.
Run Code Online (Sandbox Code Playgroud)
我不确定是什么导致了这个问题,我猜这是因为我还没有宣布模块 typings.d.ts
请指教.谢谢.
Ama*_*hez 12
我对这次谈话的两分钱:
在您的tsconfig.json文件中,确保您具有正确的Types.d.ts文件路径。
“ typeRoots”:[“ node_modules / @ types”,“ ../src/typings.d.ts”],
您的 Typescript 编译器似乎尝试从node_modules目录编译文件。
请确保您的tsconfig.json文件中有此排除规则:
{
"compilerOptions": {},
"exclude": [
"node_modules"
]
}
Run Code Online (Sandbox Code Playgroud)
顺便提一句。@types您只需要和之一typings。第二个已弃用,您所需要的只是@types在开发依赖项中包含适当的包。希望能帮助到你!
编辑:我认为 npm 包中不应该有任何 Typescript 文件,因此我在此存储库的 github 上创建了一个修复主题: https: //github.com/devsullo/ng2-STOMP-Over-WebSocket/issues/ 5
| 归档时间: |
|
| 查看次数: |
16426 次 |
| 最近记录: |