Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix processing of config files containing the rootDir option #117

Merged
merged 5 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions source/lib/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as path from 'path';
import {
JsxEmit,
ScriptTarget,
Expand Down Expand Up @@ -56,7 +55,7 @@ function getOptionsFromTsConfig(cwd: string): CompilerOptions {
return parseJsonSourceFileConfigFileContent(
readJsonConfigFile(configPath, sys.readFile),
sys,
path.basename(configPath),
cwd,
undefined,
configPath,
).options;
Expand Down
4 changes: 4 additions & 0 deletions source/test/fixtures/root-dir/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "test",
"types": "ts-dist/index.d.ts"
}
1 change: 1 addition & 0 deletions source/test/fixtures/root-dir/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const a = 2;
4 changes: 4 additions & 0 deletions source/test/fixtures/root-dir/test-d/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {expectType} from '../../../..';
import {a} from '../src';

expectType<2>(a);
1 change: 1 addition & 0 deletions source/test/fixtures/root-dir/ts-dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const a = 2;
4 changes: 4 additions & 0 deletions source/test/fixtures/root-dir/ts-dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';
exports.__esModule = true;
exports.a = void 0;
exports.a = 2;
12 changes: 12 additions & 0 deletions source/test/fixtures/root-dir/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "ts-dist"
},
"include": [
"src"
],
"exclude": [
"**/ts-dist/**"
]
}
6 changes: 6 additions & 0 deletions source/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,9 @@ test('errors in libs from node_modules are not reported', async t => {
[3, 18, 'error', 'Cannot find name \'Bar\'.']
]);
});

test('allow specifying `rootDir` option in `tsconfig.json`', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/root-dir')});

verify(t, diagnostics, []);
});