If you know how to fix the issue, make a pull request instead.
@types/jasminewd2 with the version 2.0.7 package and had problems.ERROR in node_modules/@types/jasminewd2/index.d.ts(8,23): error TS2688: Cannot find type definition file for 'jasmine/v2'
my package.json for information:
{
"name": "ionic-stencil-essential",
"version": "1.2.0",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^7.2.2",
"@angular/core": "^7.2.2",
"@angular/forms": "^7.2.2",
"@angular/http": "^7.2.2",
"@angular/platform-browser": "^7.2.2",
"@angular/platform-browser-dynamic": "^7.2.2",
"@angular/router": "^7.2.2",
"@ionic-native/core": "5.0.0",
"@ionic-native/splash-screen": "5.0.0",
"@ionic-native/status-bar": "5.0.0",
"@ionic/angular": "4.3.0",
"chart.js": "^2.8.0",
"cordova-plugin-device": "^2.0.2",
"cordova-plugin-ionic-keyboard": "^2.1.3",
"cordova-plugin-ionic-webview": "4.0.0",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"core-js": "^2.5.4",
"jasminewd2": "^2.2.0",
"ng2-charts": "^1.4.1",
"node-sass": "^4.12.0",
"postcss-loader": "^3.0.0",
"rxjs": "~6.4.0",
"rxjs-compat": "^6.5.3",
"tslib": "^1.9.0",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular-devkit/architect": "~0.13.8",
"@angular-devkit/build-angular": "~0.13.8",
"@angular-devkit/core": "~7.3.8",
"@angular-devkit/schematics": "~7.3.8",
"@angular/cli": "~7.3.8",
"@angular/compiler": "~7.2.2",
"@angular/compiler-cli": "~7.2.2",
"@angular/language-service": "~7.2.2",
"@ionic/angular-toolkit": "~1.5.1",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "2.0.0",
"@types/node": "~10.14.2",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~8.1.0",
"tslint": "~5.16.0",
"typescript": "~3.1.6"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-device": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {}
},
"platforms": []
}
}
i rollback to the precedent version.
@mkashi Sorry for the disturbance. Yes, I made the change causing the issue 馃槦
The thing is that jasminewd2 is supporting jasmine v2 only and shouldn't be used with jasmine 3. It's stated here:
jasminewd2 is an adapter for Jasmine 2.x, and uses the package jasmine. It is published to npm as jasminewd2.
When I updated types for jasmine 3 it broke the existing types for jasminewd2, which is completely fine as those are not expected to be compatible, so I was unable to merge PR. To mitigate that I modified type reference to point to types from jasmine v2 with mind that package packer is smart enough to understand that it's a dependency on jasmine v2:
Apparently, that syntax doesn't work 馃槩
So the question is whether it's possible at all to somehow reference types from older dependency version when declaring types. What is the approach for that? @mrcrane Do you know the answer? If not, could you please tag somebody who works on linting/packaging infrastructure?
Thanks.
Related: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/38412
CC: @kolodny
Thanks for reporting this, @mkashi! We're looking into this now.
Unfortunately, we don't currently offer a way to do what you wanted here.
I've filed https://github.com/microsoft/dtslint/issues/253 to track the work to enable this.
In the meantime, while I see the benefit of the FunctionMatchers type that you added, you'll need to remove it for now so that you can change the types reference back to jasmine.
Any info on how to fix this? Or when it will be addressed to make it work again? Thanks
Any info on how to fix this? Or when it will be addressed to make it work again? Thanks
I reverted versions:
"@types/jasmine": "3.4.0",
"@types/jasminewd2": "2.0.6",
A quick update on the issue. I created a hotfix PR #38737 to make jasminewd2 types compatible with older jasmine version as well latest one. This fix is temporary and should be replaced going forward. At least it should prevent disturbance people who accidentally updated package and have no clue what's going on.
Correct fix should make jasminewd2 to depend on jasmine v2 types and people should never install it together with jasmine v3 (like it was suggested above). I faced the following blockers when trying to do it:
path override should be used in tsconfig.json (see here). The issue is that most likely types should be rewritten to be in ES style to use imports:Also, /// <reference types=".." /> will not work with path mapping, so dependencies must use import.
- according to the comment above packager itself doesn't support the feature: https://github.com/microsoft/dtslint/issues/253.
If some of these assumptions are wrong and there are no blockers to proceed further - please reply. I'm not very experienced in type project setup, so might be wrong 馃槈
UPD: Fix is published, update to @types/[email protected] or later to get it sorted out. 馃洜 鉁旓笍
@zvirja Thanks for putting together that fix!
I did some more digging based on that documentation you linked, and I think I came up with a real solution.
First, as that documentation shows, you can get a reference to 'jasmine' to specifically refer to jasmine/v2 by adding the following to the tsconfig:
"paths": {
"jasmine": [ "jasmine/v2" ]
},
Next, you can change the triple slash reference to import 'jasmine';. This has the same effect, but makes the type definition file a module instead of a collection of global declarations. To ensure that the module doesn't export anything, I suggest adding export {}; as well.
Now, you'll see some errors, because some types are not available in the same way as before. To fix this, as inspired by the global-modifying-module template, you can wrap everything but the import and export lines in a declare global block and remove all of the existing declare modifiers.
When everything is set up this way, I believe the types publisher will be able to publish @types/jasminewd2 with a package.json that specifies "@types/jasmine": "^2".
As a side note, I noticed that in the README for jasminewd2 itself, it mentions that @types/jasminewd2 doesn't provide a declaration for the exported init function. You should be able to do that now with export function init(controlFlow: {}, webDriver: {}): void (or make it more specific - I don't actually know what the argument types would be).
@uniqueiniquity Thank you very much for the analysis and advises - looks promising!
I performed extra investigation and apparently situation is much worse 馃槩 Angular is shipping incompatible versions by default:
So if I add limit to the existing types and publish new package, it will break all the existing Angular solutions. Whole planet will curse me 馃槰
I don't really know what is the solution for this, as I never used protractor and jasminewd2 - is it even required today given that we have async/await?
@vikerman @sjelin @cnishina @juliemr As developers of jasminewd2, could you please describe the situation with jasmine 3 and protractor? If you are not current maintainers - could you please tag somebody who could advise the future direction?
Thanks!
Most helpful comment
I reverted versions:
"@types/jasmine": "3.4.0",
"@types/jasminewd2": "2.0.6",