patterntypescriptCritical
ts-node ignores d.ts files while tsc successfully compiles the project
Viewed 0 times
projectwhilefilesthecompilessuccessfullynodetscignores
Problem
Having compiled my TypeScript project successfully, I intended to run it in VS Code's debug mode using
Project structure is:
The definition file
So, trying to run it with
How to resolve it globally? I've found that
My TypeScript version is 3.0.1
ts-node. Problem is, ts-node can't find d.ts files I created (while tsc has no problem with it).Project structure is:
/
conf/
dist/
src/
types/
package.json
tsconfig.jsontsconfig.json relevant entries are:{
"compilerOptions": {
"target": "es2017",
"module": "commonjs",
// "lib": [],
"sourceMap": true,
"outDir": "dist",
"rootDir": "src",
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"*": [
"node_modules/*",
"src/types/*"
]
},
// "rootDirs": [],
// "typeRoots": [],
// "types": [],
},
"include": [
"src/**/*"
]
}
The definition file
ts-node can't find is src/types/global.d.ts:import { App } from '../App';
declare global {
namespace NodeJS {
interface Global {
app: App;
}
}
}
So, trying to run it with
ts-node I see:TSError: ⨯ Unable to compile TypeScript:
src/boot.ts(15,59): error TS2339: Property 'app' does not exist on type 'Global'.How to resolve it globally? I've found that
/// does the trick but I'd have to repeat it in every file using global.app.My TypeScript version is 3.0.1
Solution
Starting with ts-node in 7.0.0, does not Load files from
tsconfig.json on startup. Instead, you should specificy --files like thists-node --files src/boot.ts
Context
Stack Overflow Q#51610583, score: 151
Revisions (0)
No revisions yet.