PeculiarVentures / graphene

A simple layer for interacting with PKCS #11 / PKCS11 / CryptoKI for Node in TypeScript. (Keywords: Javascript, PKCS#11, Crypto, Smart Card, HSM)
MIT License
169 stars 34 forks source link

Errors on TS transpilation #114

Closed jonasholtkamp closed 5 years ago

jonasholtkamp commented 5 years ago

The following issues occur if I run npm install followed by tsc. After consulting the package-lock.json @types/mocha is shipped with graphene-pk11, see also package.json. Looks to me like this should rather be a dev dependency than a production dependency.

$ npm install

> [path]
> npm run build

> [path]
> tsc

node_modules/@types/mocha/index.d.ts:2680:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'Lifecycle', but here has type 'HookFunction'.

2680 declare var beforeEach: Mocha.HookFunction;
                 ~~~~~~~~~~

node_modules/@types/mocha/index.d.ts:2698:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'afterEach' must be of type 'Lifecycle', but here has type 'HookFunction'.

2698 declare var afterEach: Mocha.HookFunction;
                 ~~~~~~~~~

node_modules/@types/mocha/index.d.ts:2714:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'describe' must be of type 'Describe', but here has type 'SuiteFunction'.

2714 declare var describe: Mocha.SuiteFunction;
                 ~~~~~~~~

node_modules/@types/mocha/index.d.ts:2735:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xdescribe' must be of type 'Describe', but here has type 'PendingSuiteFunction'.

2735 declare var xdescribe: Mocha.PendingSuiteFunction;
                 ~~~~~~~~~

node_modules/@types/mocha/index.d.ts:2749:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'it' must be of type 'It', but here has type 'TestFunction'.

2749 declare var it: Mocha.TestFunction;
                 ~~

node_modules/@types/mocha/index.d.ts:2763:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'test' must be of type 'It', but here has type 'TestFunction'.

2763 declare var test: Mocha.TestFunction;
                 ~~~~

node_modules/@types/mocha/index.d.ts:2770:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'xit' must be of type 'It', but here has type 'PendingTestFunction'.

2770 declare var xit: Mocha.PendingTestFunction;
                 ~~~

Found 7 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [path]@0.1.0 build: `tsc`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [path]@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     [path]/2019-08-12T13_39_15_634Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [path]@0.1.0 prepare: `npm run build`
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the [path]@0.1.0 prepare script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!    [path]/2019-08-12T13_39_15_663Z-debug.log

My (redacted) package.json:

{
  "version": "0.1.0",
  "main": "./lib/index.js",
  "scripts": {
    "build": "tsc",
    "test": "jest --coverage",
    "test.ci": "npm test -- --runInBand --ci",
    "test.watch": "npm test -- --watchAll",
    "eslint": "eslint \"{src,test}/**/*.{ts,js}\"",
    "eslint.fix": "eslint \"{src,test}/**/*.{ts,js}\" --fix",
    "prepare": "npm run build",
    "stryker": "stryker run"
  },
  "dependencies": {
    "graphene-pk11": "^2.1.2"
  },
  "devDependencies": {
    "@stryker-mutator/core": "^1.0.0",
    "@stryker-mutator/html-reporter": "^1.0.0",
    "@stryker-mutator/jest-runner": "^1.0.0",
    "@stryker-mutator/typescript": "^1.0.0",
    "@types/eslint": "^4.16.6",
    "@types/jest": "^24.0.13",
    "@types/node": "^12.0.1",
    "@typescript-eslint/eslint-plugin": "^1.9.0",
    "@typescript-eslint/parser": "^1.9.0",
    "eslint": "^5.16.0",
    "eslint-plugin-import": "^2.17.2",
    "eslint-plugin-jest": "^22.5.1",
    "eslint-plugin-node": "^9.0.1",
    "eslint-plugin-promise": "^4.1.1",
    "jest": "^24.8.0",
    "pre-commit": "^1.2.2",
    "ts-jest": "^24.0.2",
    "typescript": "^3.4.5"
  },
  "jest": {
    "preset": "ts-jest",
    "verbose": false,
    "coverageDirectory": "build/reports/coverage/",
    "collectCoverage": true,
    "collectCoverageFrom": [
      "src/**/*.ts"
    ],
    "coverageReporters": [
      "lcov",
      "html",
      "text-summary"
    ],
    "testEnvironment": "node",
    "testMatch": [
      "**/*.test.js"
    ],
    "resetModules": true,
    "restoreMocks": true
  },
  "pre-commit": [
    "eslint",
    "test"
  ]
}

tsconfig.json:

{
  "compilerOptions": {
    "resolveJsonModule": true,
    "strict": true,
    "module": "commonjs",
    "esModuleInterop": true,
    "target": "es2017",
    "moduleResolution": "node",
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "inlineSourceMap": false,
    "outDir": "lib"
  },
  "include": [
    "src/**/*",
  ],
  "exclude": [
    "test/**/*.test.ts",
  ],
}
microshine commented 5 years ago

New version + graphene-pk11@2.1.3 is available