Skip to content

Commit

Permalink
Fix processing of config files containing the rootDir option (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
BendingBender authored Jun 3, 2021
1 parent 6d0ce6c commit b749113
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 2 deletions.
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 @@ -410,3 +410,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, []);
});

0 comments on commit b749113

Please sign in to comment.