diff --git a/source/lib/config.ts b/source/lib/config.ts index 78a8db85..fb6ba9df 100644 --- a/source/lib/config.ts +++ b/source/lib/config.ts @@ -39,7 +39,8 @@ export default (pkg: {tsd?: RawConfig}, cwd: string): Config => { target: ScriptTarget.ES2017, ...tsConfigCompilerOptions, ...packageJsonCompilerOptions, - moduleResolution: ModuleResolutionKind.NodeJs + moduleResolution: ModuleResolutionKind.NodeJs, + skipLibCheck: false } }; }; diff --git a/source/test/fixtures/missing-import/index.d.ts b/source/test/fixtures/missing-import/index.d.ts new file mode 100644 index 00000000..d426396f --- /dev/null +++ b/source/test/fixtures/missing-import/index.d.ts @@ -0,0 +1,4 @@ +export type LiteralUnion< + LiteralType extends BaseType, + BaseType extends Primitive +> = LiteralType | (BaseType & {_?: never}); diff --git a/source/test/fixtures/missing-import/index.js b/source/test/fixtures/missing-import/index.js new file mode 100644 index 00000000..bc010a3d --- /dev/null +++ b/source/test/fixtures/missing-import/index.js @@ -0,0 +1 @@ +// Nothing here diff --git a/source/test/fixtures/missing-import/index.test-d.ts b/source/test/fixtures/missing-import/index.test-d.ts new file mode 100644 index 00000000..362c4616 --- /dev/null +++ b/source/test/fixtures/missing-import/index.test-d.ts @@ -0,0 +1,8 @@ +import {expectType} from '../../..'; +import {LiteralUnion} from '.'; + +type Pet = LiteralUnion<'dog' | 'cat', string>; + +expectType('dog'); +expectType('cat'); +expectType('unicorn'); diff --git a/source/test/fixtures/missing-import/package.json b/source/test/fixtures/missing-import/package.json new file mode 100644 index 00000000..de6dc1db --- /dev/null +++ b/source/test/fixtures/missing-import/package.json @@ -0,0 +1,3 @@ +{ + "name": "foo" +} diff --git a/source/test/test.ts b/source/test/test.ts index 60b92f55..f9f164d6 100644 --- a/source/test/test.ts +++ b/source/test/test.ts @@ -233,3 +233,14 @@ test('expectError for values', async t => { t.true(diagnostics[0].message === 'Expected an error, but found none.'); t.true(diagnostics[0].severity === 'error'); }); + +test('missing import', async t => { + const diagnostics = await m({cwd: path.join(__dirname, 'fixtures/missing-import')}); + + t.true(diagnostics.length === 1); + + t.true(diagnostics[0].column === 18); + t.true(diagnostics[0].line === 3); + t.true(diagnostics[0].message === 'Cannot find name \'Primitive\'.'); + t.true(diagnostics[0].severity === 'error'); +});