NejcZdovc / ng2-select2

Select 2 wraper for angular2
MIT License
123 stars 93 forks source link

ERROR in /node_modules/ng2-select2/ng2-select2.component.d.ts (12,14): Cannot find name 'Select2Options'. #124

Closed imsatish36 closed 6 years ago

imsatish36 commented 6 years ago

This package works properly with existing node_modules folder in my project. But, if I remove the folder and install the packages using npm install, I get the following error ERROR in /node_modules/ng2-select2/ng2-select2.component.d.ts (12,14): Cannot find name 'Select2Options'

My package.json looks something like this "dependencies": { "angular/common": "2.4.10", "angular/compiler": "~2.4.10", "angular/core": "2.4.10", "angular/forms": "2.4.10", "angular/http": "2.4.10", "angular/platform-browser": "2.4.10", "angular/platform-browser-dynamic": "2.4.10", "angular/router": "3.3.1", "types/select2": "^4.0.45", "jquery": "^3.3.1", "ng2-select2": "^1.0.0-beta.11", "select2": "4.0.4", "typings": "2.1.1", "web-animations-js": "2.3.1", "zone.js": "0.7.8" }, "devDependencies": { "angular/cli": "1.4.9", "angular/compiler-cli": "^2.3.1", "types/jasmine": "2.5.38", "types/jquery": "^3.3.1", "types/node": "6.0.42", "fs-extra": "4.0.1", "grunt": "1.0.1", "grunt-cache-bust": "1.6.0", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "2.0.0", "karma-cli": "1.0.1", "karma-jasmine": "1.0.2", "karma-remap-istanbul": "0.2.1", "protractor": "~4.0.13", "ts-node": "1.2.1", "tslint": "4.3.0", "typescript": "^2.8.3" }

Anyone is having idea about this issue? Is there anything that I am missing? Thank you.

imsatish36 commented 6 years ago

So, finally I got a reason for this error. The interface Select2Options is removed/renamed to Options in the latest version 4.0.45 of the @types/select2. That's why I was getting this error. To resolve this issue, I simply downgrade the @types/select2 package to 4.0.44 by running npm install @ types/select2@4.0.44 --save and this worked for me.

But, guess what? @NejcZdovc already released the new version of ng2-select2 which is 1.0.0-beta.12 20 hours ago. and managed to change the dependencies in the package itself. So, you can happily ignore the workaround done by me. Happy coding...!!!