project createSourceFile ignores compilerOptions rootDir
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
Version: `17.0.1`
I want to give my project a baseDir or cwd so all project apis will use it as a relative path
For example, create a project relative to dir `src` so when i call
```ts
project.createSourceFile('test.ts', '');
```
The file will be created under `src/test.ts`
**To Reproduce**
I tried using all of the following compilerOptions props with no luck:
```ts
import { Project } from "ts-morph";
const dir = 'src';
const project = new Project({
compilerOptions: {
rootDir: dir,
baseUrl: dir,
sourceRoot: dir,
rootDirs: [dir]
}
});
project.createSourceFile("test.ts", ``);
project.save
```
**Expected behavior**
I'd expect the `test.ts` file to be created in the `src` directory
Contributor guide
Research direction
Start at the Project.createSourceFile entry point and trace how the supplied file path is resolved against compilerOptions. Reproduce the example with rootDir set to src; done means project.createSourceFile("test.ts", "") creates src/test.ts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100