0

I am writing to ask a clarification on a strange behaviour occurred today while working:

I am working on a Node JS application written by someone else in plain javascript. I started introducing typescript incrementally, very gradually.

I started by installing typescript as a dependency, adding a tsconfig.json file and translating some little file from .js to .ts. Everything worked well, untill a strange problem came out only in a specific point of some absolutely untouched code.

The problem happens here, on line 44

enter image description here

As you can see in the following screenshot, this.data.roles is an array of strings

enter image description here

On that line the error I get is this one

enter image description here

  1. The problem happens only if I run the application with ts-node. If I run the code using just note it works properly. Can it be something related to my tsconfig.json?

    {
      "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "isolatedModules": true, 
        "strict": false, 
        "esModuleInterop": true, 
      },
      "include": [
        "node_modules",
        "src"
      ]
    }
  1. If I change the code to this it works

const uniqueRoles = [...this.data.roles];

What can be the cause of such behaviour? This is just for personal knoweledge since the problem is solved :-)

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.