Typescript type errors with 3.0.6

I have upgraded my NestJS/Typescript project to couchbase JS SDK 3.0.6, which I know has changed the way types are declared (https://issues.couchbase.com/browse/JSCBC-686).

Since then the ts compilation fails, complaining about unknown types:

node_modules/couchbase/types.d.ts:8:19 - error TS2304: Cannot find name 'integer'.

8         timeout?: integer;
                ~~~~~~~
node_modules/couchbase/types.d.ts:12:19 - error TS2304: Cannot find name 'integer'.

12         timeout?: integer;
                 ~~~~~~~
node_modules/couchbase/types.d.ts:18:19 - error TS2304: Cannot find name 'integer'.

18         timeout?: integer;
                 ~~~~~~~

I’ve tried quite a few things to tweak in particular my tsconfig.json, as advised on e.g. https://stackoverflow.com/questions/50088838/react-typescript-application-gets-ts2304-cannot-find-name-text and https://stackoverflow.com/questions/33332394/angular-and-typescript-cant-find-names-error-cannot-find-name/33359873#33359873

Here’s my package.json:

{
  "name": "msgateway",
  "version": "2.0.1",
  "description": "MSG ",
  "author": "Jeremiah Chienda<jeremiah.chienda@oneacrefund.org>",
  "license": "MIT",
  "scripts": {
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "start:roster-dataset": "node dist/roster-dataset.main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "sync-gateway:config": "node src/sync-gateway/config.js",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:ci": "jest --coverage --ci --reporters=default --reporters=jest-junit --forceExit",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "jest --config ./test/jest-e2e.json"
  },
  "dependencies": {
    "@godaddy/terminus": "~4.4.1",
    "@nestjs/bull": "~0.1.2",
    "@nestjs/common": "~6.11.11",
    "@nestjs/config": "~0.5.0",
    "@nestjs/core": "~6.11.11",
    "@nestjs/microservices": "~6.11.11",
    "@nestjs/platform-express": "~6.11.11",
    "@nestjs/schedule": "~0.4.0",
    "@nestjs/swagger": "~4.5.12",
    "@nestjs/terminus": "~6.5.6",
    "@types/couchbase": "^2.4.2",
    "axios": "~0.19.2",
    "bull": "~3.16.0",
    "couchbase": "3.0.6",
    "deep-equal": "~2.0.3",
    "dotenv": "~8.2.0",
    "lodash": "~4.17.19",
    "moment": "~2.27.0",
    "nano-equal": "~2.0.2",
    "nest-schedule": "~0.6.4",
    "nestjs-pino": "~1.2.0",
    "pino": "~6.4.1",
    "pretty-error": "~2.1.1",
    "reflect-metadata": "~0.1.13",
    "rimraf": "~3.0.2",
    "rxjs": "~6.6.0",
    "seedrandom": "~3.0.5",
    "swagger-ui-express": "~4.1.4",
    "tough-cookie": "~4.0.0",
    "util": "~0.12.3",
    "uuid": "~3.4.0"
  },
  "devDependencies": {
    "@compodoc/compodoc": "~1.1.11",
    "@nestjs/cli": "~6.14.2",
    "@nestjs/schematics": "~6.9.4",
    "@nestjs/testing": "~6.11.11",
    "@types/bull": "~3.14.0",
    "@types/cron": "~1.7.2",
    "@types/express": "~4.17.7",
    "@types/jest": "26.0.7",
    "@types/lodash": "~4.14.158",
    "@types/node": "~14.0.26",
    "@types/seedrandom": "~2.4.28",
    "@types/supertest": "~2.0.10",
    "@types/tough-cookie": "~4.0.0",
    "@types/uuid": "~3.4.9",
    "@typescript-eslint/eslint-plugin": "~3.7.0",
    "@typescript-eslint/parser": "~3.7.0",
    "core-js": "^3.6.5",
    "eslint": "~7.5.0",
    "eslint-config-prettier": "~6.11.0",
    "eslint-plugin-import": "~2.22.0",
    "jest": "~26.1.0",
    "jest-junit": "~11.0.1",
    "prettier": "~2.0.5",
    "supertest": "~4.0.2",
    "ts-jest": "~26.1.3",
    "ts-loader": "~8.0.1",
    "ts-node": "~8.10.2",
    "tsconfig-paths": "~3.9.0",
    "typescript": "~3.9.7"
  },
  "optionalDependencies": {
    "fsevents": "*"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".spec.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "coverageDirectory": "../coverage",
    "coverageReporters": [
      "text",
      "cobertura",
      "lcov",
      "json"
    ],
    "testEnvironment": "node"
  }
}

And my tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2017",
    "lib": ["es5", "dom", "es6", "dom.iterable", "scripthost"],
    "typeRoots": [
      "../node_modules/@types"
    ],
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  },
  "exclude": ["node_modules", "dist"]
}

Any suggestions?

1 Like

Hey @Yann_Jouanique,

Indeed it appears some of our JSDoc’s have an integer type being used when it otherwise should be ‘Number’. I’ve filed an issue for this here https://issues.couchbase.com/browse/JSCBC-797 and we will get it fixed asap.

Cheers, Brett

2 Likes

Thanks for the quick turn-around on this!

Any timeline on the 3.0.7 release?

Hey @Yann_Jouanique,

Node.js SDK 3.0.7 is scheduled for Nov 2nd. You can find the patch for generation of accurate type definitions here:
http://review.couchbase.org/c/couchnode/+/138776

Cheers, Brett