formulahendry / formulahendry/vscode-code-runner
ts-node cannot load tsconfig.json correctly [Bug]
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 351
- PR merge metrics
- No merged PRs in 30d
Description
- VS Code Version: 1.44.0
- OS Version: macOS 10.15.4
- Code Runner Version: 0.9.17
**Describe the bug**
I encountered this problem in my typescript project.
In order to clearly illustrate this bug, I made a similar file structure in an empty folder.
Normally, the directory of tsconfig.json is the root directory of a typescript Project.
This is my config file:
```json
{
"compilerOptions": {
"module": "CommonJS",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "ES2018"
},
"compileOnSave": true
}
```
1.However, if code-runner.cwd is not set and code-runner.fileDirectoryAsCwd is false, it will use the path of root folder that is open in VS Code. And in this case, if tsconfig.json is in a subfolder, ts-node cannot load this configuration file automatically. (Notice, I have already set the target to ES2018)
And I figured out this is maybe ts-node only load tsconfig.json from Cwd. But see the second case.
2.If code-runner.cwd is not set and code-runner.fileDirectoryAsCwd is true, and move tsconfig.json to the root directory instead of a subfolder, ts-node can still load the tsconfig.json even it is in the parent directory of Cwd when you run the .ts file in the subfolder.

So maybe when .fileDirectoryAsCwd is true, ts-node can automatically search tsconfig.json in the parent directory?? However, things aren't this easy.
3.If code-runner.cwd is not set and code-runner.fileDirectoryAsCwd is false, and tsconfig.json is in the root directory, now open the subfolder in the vscode and run the code, ts-node can still load tsconfig.json even Cwd is the directory of this subfolder and this config file is out of sight.

So please tell me, what is going on?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.