Debo Akeredolu
Debo Akeredolu

Reputation: 150

Cannot find type definition file for '$'

I recently tried upgrading my Angular 4 project to angular 5 to be able to use the @angular/material datatable features but am having errors building my app after upgrading all angular dependencies to version 5.

I get the error:"ERROR in error TS2688: Cannot find type definition file for '$'"

I'm working with angular-cli and here is my package.json

  {
  "name": "app-web-ui",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@amcharts/amcharts3-angular": "^1.5.0",
    "@angular/animations": "^5.0.0",
    "@angular/cdk": "^5.2.0",
    "@angular/cli": "^1.5.0",
    "@angular/common": "5.0.0",
    "@angular/compiler": "^5.0.0",
    "@angular/compiler-cli": "^5.0.0",
    "@angular/core": "^5.0.0",
    "@angular/flex-layout": "^2.0.0-beta.8",
    "@angular/forms": "^5.0.0",
    "@angular/http": "^5.0.0",
    "@angular/material": "^5.0.0-rc0",
    "@angular/platform-browser": "^5.0.0",
    "@angular/platform-browser-dynamic": "^5.0.0",
    "@angular/router": "^5.0.0",
    "@ngui/datetime-picker": "^0.16.2",
    "@swimlane/ngx-datatable": "^11.1.7",
    "@types/angular": "^1.6.14",
    "@types/hammerjs": "^2.0.34",
    "@types/signalr": "^2.2.33",
    "angular2-draggable": "^1.0.2",
    "angular2-font-awesome": "^1.3.0",
    "angular2-fontawesome": "^5.2.1",
    "angular2-moment": "^1.8.0",
    "codelyzer": "^2.1.1",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "jasmine-spec-reporter": "^3.3.0",
    "karma": "^1.6.0",
    "moment": "^2.20.1",
    "ms-signalr-client": "^2.2.5",
    "ngresizable": "^1.0.0",
    "ngx-pagination": "^3.0.0",
    "rxjs": "^5.5.2",
    "s": "^0.1.1",
    "ts-node": "^2.1.2",
    "webpack": "^3.10.0",
    "webpack-sources": "^1.1.0",
    "zone.js": "^0.8.5"
  },
  "devDependencies": {
    "@types/jasmine": "^2.5.47",
    "@types/node": "^6.0.70",
    "codelyzer": "^2.0.1",
    "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-coverage-istanbul-reporter": "^0.2.3",
    "karma-jasmine": "^1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.1.1",
    "ts-node": "^2.0.0",
    "tslint": "^4.5.1",
    "typescript": "2.4.2"
  }
}

Error upon build: enter image description here

Has anyone gone through similar issues and figured out a solution?

Upvotes: 1

Views: 3383

Answers (1)

Debo Akeredolu
Debo Akeredolu

Reputation: 150

Found the problem. In my tsconfig.app.json file I had a "$" included in the types array for compilerOptions. I'm not sure how that got there but removing it fixed the issue.

I basically changed the src/tsconfig.app.json file from

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "baseUrl": "",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "types": ["JQuery", "$"]
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

to

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "baseUrl": "",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "types": ["JQuery"]
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

Upvotes: 2

Related Questions