I have a MY_FILE.ts file like that:
const someFunction = (param: MY_NAMESPACE.PARAM) : boolean => { // DO SOMETHING };
The param type is accessed through a namespace called MY_NAMESPACE that I declare on a MY_NAMESPACE.d.ts file. Like this:
src/MY_NAMESPACE.d.ts
declare namespace MY_NAMESPACE {
type PARAM: SOME_TYPE
}
I need to run that MY_FILE.ts file, which contains a script.
This works fine:
npx babel-node src/MY_FILE.ts --extensions ".ts"
And this does not work (and I expected it to work just fine):
npx ts-node src/MY_FILE.ts
I get this error: error TS2503: Cannot find namespace MY_NAMESPACE
Note: In my real case, the MY_NAMESPACE is called TYPES.
How can I make it work with ts-node ?

I had a similar issue. The problem was, that
ts-nodeis ignoring theinclude-option of thetsconfig.jsonand only following imports/refs in the starting file (see https://github.com/TypeStrong/ts-node#help-my-types-are-missing).I solved the issue by using the
filesoption ofts-nodein thetsconfig.json.There are other solutions for it (triple-slash directives, typeRoots). Just read the link above.