未找到类型 [英] Types not found

查看:47
本文介绍了未找到类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚更新了 angular-cli (v1.1) 并使用 ng new MyProj 创建了一个新项目.然后我在 project.json 文件中添加并安装了两个依赖项:

I just updated angular-cli (v1.1) and created a new project using ng new MyProj. Then I added and installed two dependencies to the project.json file:

"dependencies": {
    ...
    "toastr": "2.1.2",
    "spin": "0.0.1"
  },
  "devDependencies": {
    ...
    "@types/toastr": "2.1.32",
    "@types/spin": "2.3.30",
    ...
    "typescript": "~2.3.3"
  }

然后我更新了自动生成的 app.component.ts 添加这个构造函数:

Then I updated the autogenerated app.component.ts adding this constructor:

constructor() {
    toastr.success('Hi')
}

IDE(视觉工作室代码)不返回任何错误,但是当我使用 ng serve 为应用程序提供服务时,我收到以下错误:

The IDE (visual studio code) do not return any error but when I serve the application using ng serve I get the following error:

../A/src/app/app.component.ts 中的错误 (15,5): C找不到名称toastr".

ERROR in ../A/src/app/app.component.ts (15,5): C annot find name 'toastr'.

我真的不知道这有什么问题.

I really cannot figure out what is wrong with that.

非常感谢

推荐答案

我解决了从 tsconfig.app.json 中删除 types 的问题.这是新的配置:

I solved the problem removing types from tsconfig.app.json. This is the new configuration:

{
    "extends": "../tsconfig.json",
    "compilerOptions": {
        "outDir": "../out-tsc/app",
        "module": "es2015",
        "baseUrl": ""
    },
    "exclude": [
        "test.ts",
        "**/*.spec.ts"
    ]
}

这篇关于未找到类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆