Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Types not found

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"
  }

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

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

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

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.

Thanks a lot

like image 391
user3471528 Avatar asked Jul 09 '26 06:07

user3471528


1 Answers

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"
    ]
}
like image 131
user3471528 Avatar answered Jul 11 '26 19:07

user3471528



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!