formulahendry / formulahendry/vscode-code-runner

ts-node cannot load tsconfig.json correctly [Bug]

Open
#595 0 comments 0 reactions 0 assignees View on GitHub
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)
Screen Shot 2020-04-10 at 11 17 17 PM
Screen Shot 2020-04-10 at 9 23 26 PM
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.
![image](https://user-images.githubusercontent.com/17922721/79001820-cab3cc80-7b81-11ea-96bf-17421a475110.png)
Screen Shot 2020-04-10 at 9 35 30 PM
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.
Screen Shot 2020-04-10 at 11 17 17 PM
Screen Shot 2020-04-10 at 10 54 52 PM
Screen Shot 2020-04-10 at 10 55 32 PM

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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.