Home > Mobile >  Typescript: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDire
Typescript: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDire

Time:06-16

I've an npm command line application that i've built not so long ago and it worked fine. Now that i've updated it, and due to changes in the versions of typescript over the period, i'm getting an error when i want to run this package which says:

Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.

Here is the package.json file:

{
  "name": "initialiseur",
  "version": "4.0.4",
  "main": "src index.ts",
  "author": "@crispengari",
  "license": "MIT",
  "bin": "src/index.ts",
  "description": "THIS IS A BOILER PLATE THAT INITIALIZE A NODE EXPRESS BACKEND FOR TYPESCRIPT AND JAVASCRIPT",
  "scripts": {
    "watch": "tsc -w",
    "start": "ts-node src/index.ts",
    "dev": "nodemon dist/index.ts",
    "start:fast": "tsnd --respawn src/index.ts"
  },
  "dependencies": {
    "@types/inquirer": "^7.3.3",
    "@types/node": "^17.0.42",
    "@types/npm": "^7.19.0",
    "chalk": "^4.1.2",
    "cors": "^2.8.5",
    "cross-fetch": "^3.1.5",
    "dotenv": "^10.0.0",
    "inquirer": "^8.1.2",
    "node-fetch": "^3.2.6",
    "octokit": "^1.7.2",
    "ts-node": "^10.8.1",
    "typescript": "^4.6.5"
  },
  "devDependencies": {
    "@types/node-fetch": "^2.6.1",
    "nodemon": "^2.0.12",
    "ts-node-dev": "^2.0.0"
  },
  "bugs": {
    "url": "https://github.com/CrispenGari/initialiseur/issues"
  },
  "homepage": "https://github.com/CrispenGari/initialiseur#readme",
  "keywords": [
    "node.ts",
    "node.js",
    "typescript",
    "ts",
    "nodejs-backend",
    "javascript",
    "js",
    "express",
    "backend"
  ]
}

When i'm testing it locally by running:

npm start

# or 
yarn start

Everything is working fine, but after publishing it to npm to start it i run the following command:

npx initialiseur

Then I'm getting the error from a command line. The whole error is as follows:

C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:42536
        ts.Debug.assert(typeof typeReferenceDirectiveName === "string", "Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.");
                 ^
Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
    at Object.resolveTypeReferenceDirective (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:42536:18)
    at C:\Users\crisp\AppData\Roaming\npm\node_modules\ts-node\src\resolver-functions.ts:131:51
    at Array.map (<anonymous>)
    at Object.resolveTypeReferenceDirectives (C:\Users\crisp\AppData\Roaming\npm\node_modules\ts-node\src\resolver-functions.ts:130:31)
    at actualResolveTypeReferenceDirectiveNamesWorker (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:116673:163)
    at resolveTypeReferenceDirectiveNamesWorker (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:116973:26)
    at processTypeReferenceDirectives (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:118455:31)
    at findSourceFileWorker (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:118340:21)
    at findSourceFile (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:118195:26)
    at processImportedModules (C:\Users\crisp\AppData\Roaming\npm\node_modules\initialiseur\node_modules\typescript\lib\typescript.js:118601:25)

From the above error i can tell that the problem maybe comming from typescript, I'v tried changing version of typescript but still it's not working. In my src/index.ts it looks as follows:


#!/usr/bin/env ts-node
import path from "path";
import inquirer from "inquirer";
import { writeFile, readFile } from "fs/promises";

....


CodePudding user response:

Try updating all you packages including typescript

To update typescript: npm i typescript@latest

Here is a package to check for updates: https://www.npmjs.com/package/npm-check-updates

CodePudding user response:

Getting the same as of a couple of days.

Reverting ts-node to v10.6.0 fixes it for me.

  • Related