During my unit testing, I encountered a challenge with code that relies on interfaces and classes not available for import but can be included in intellisense through d.ts files. Despite specifying the "include" property in my tsconfig to cover those files, TypeScript throws errors indicating it couldn't compile due to a lack of access to the interfaces I need.
This is how my tsconfig looks:
{
"compilerOptions": {
"target": "es6",
"module": "CommonJS",
"esModuleInterop": true,
"sourceMap": false,
"downlevelIteration": true,
},
"include":
[
"_MainSource/**/*",
"Tests/**/*",
"@typeDefs/**/*"
],
}
The error message I'm stuck with states:
error TS2503: Cannot find namespace 'RPG'.
My current testing command looks like this:
mocha -r ts-node/register Tests/**/*.ts
In an effort to resolve this, I attempted adding 'ts-node --files' to my test command leading me to try:
mocha -r ts-node/register 'ts-node --files' Tests/**/*.ts
This change resulted in new errors claiming TS cannot locate ts-node (despite its installation) and the initial command functions correctly for code lacking the RPG namespace dependency.