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 committed 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
@@ -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
@@ -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
@@ -0,0 +1 @@
export const a = 2;
4 changes: 4 additions & 0 deletions source/test/fixtures/root-dir/test-d/index.test-d.ts
@@ -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
@@ -0,0 +1 @@
export declare const a = 2;
4 changes: 4 additions & 0 deletions source/test/fixtures/root-dir/ts-dist/index.js
@@ -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
@@ -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
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.