protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Example TypeScript fails to transpile

Open sschalley opened this issue 7 years ago • 4 comments

  • NPM: 3.10.8
  • Node Version: 7.0.0
  • Protractor Version: 5.1.2
  • Angular Version: 3
  • Operating System and Version Windows 7

Are some of the dependencies in the package.json file out of sync? When following the instructions in the protractor\exampleTypescript\README.md file I get the following transpile error messages:

When down loading Protractor and following the README.md in the Failure messages:

node_modules/@types/jasmine/index.d.ts(26,41): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).
node_modules/@types/jasmine/index.d.ts(27,39): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).
node_modules/@types/jasmine/index.d.ts(152,24): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).

node_modules/@types/jasmine/index.d.ts(334,14): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).

node_modules/@types/jasmine/index.d.ts(435,24): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).

node_modules/@types/jasmine/index.d.ts(448,30): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).
node_modules/@types/jasmine/index.d.ts(448,30): error TS2314: Generic type 'Matchers<T>' requires 1 type argument(s).

node_modules/@types/jasminewd2/index.d.ts(23,13): error TS2428: All declarations of 'Matchers' must have identical ty
pe parameters.
node_modules/@types/jasminewd2/index.d.ts(47,13): error TS2430: Interface 'ArrayLikeMatchers<T>' incorrectly extends
interface 'Matchers<ArrayLike<T>>'.
  Types of property 'toBe' are incompatible.
    Type '(expected: any, expectationFailOutput?: any) => Promise<void>' is not assignable to type '{ (expected: any,
 expectationFailOutput?: any): boolean; (expected: any, expectationFailOutput?: ...'.
      Type 'Promise<void>' is not assignable to type 'boolean'.
node_modules/@types/jasminewd2/index.d.ts(48,20): error TS2304: Cannot find name 'Expected'.
node_modules/@types/jasminewd2/index.d.ts(49,23): error TS2304: Cannot find name 'Expected'.

To correct the above errors I modified the following in the package.json file:

  1. Changed "@types/jasmine": "2.5.41" to "@types/jasmine: "2.5.51"
  2. Changed "typescript": "2.0.0" to "typescript": "2.1"
  3. Execute npm install and nmp test

sschalley avatar Oct 03 '17 20:10 sschalley

Also worth mentioning is that in the 'Getting started' section of README.md document in https://github.com/angular/protractor/tree/master/exampleTypescript, it is implied that the 'npm install' should first be run in protractor directory and then, in the next step, in the exampleTypescript directory. I found this not working since there is an error displayed:

npm ERR! path C:\Users\nmilo\Documents\development\protractor\node_modules\adm-zip
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\nmilo\Documents\development\protractor\node_modules\adm-zip' -> 'C:\Users\nmilo\Documents\development\protractor\node_modules\.adm-zip.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\nmilo\AppData\Roaming\npm-cache\_logs\2018-03-29T00_04_07_093Z-debug.log

Running 'npm install' first in the exampleTypescript directory and then in the protractor directory works.

nmilosevic avatar Mar 29 '18 00:03 nmilosevic

2021 and I'm having this issue. Any fix?

budescode avatar Apr 28 '21 10:04 budescode

I updated the npm using npm update and voila issue resolved

Kritika7 avatar May 03 '21 06:05 Kritika7

Updating @types/jasminewd2 fixed the issue for me

Sarah-JJ avatar Jun 04 '21 13:06 Sarah-JJ