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
As you can see in the following screenshot, this.data.roles
is an array of strings
On that line the error I get is this one
- 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"
]
}
- 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 :-)