Skip to content

Commit f5b69ed

Browse files
Add dom lib by default
1 parent d2284a1 commit f5b69ed

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

source/lib/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default (pkg: {tsd?: RawConfig}, cwd: string): Config => {
3434
compilerOptions: {
3535
strict: true,
3636
jsx: JsxEmit.React,
37-
lib: ['lib.es2017.d.ts'],
37+
lib: ['es2017', 'dom'],
3838
module: ModuleKind.CommonJS,
3939
target: ScriptTarget.ES2017,
4040
esModuleInterop: true,

source/test/fixtures/dom/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default function(parent: HTMLElement, child: HTMLElement): void;

source/test/fixtures/dom/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
exports.default = (parent, child) => {
2+
parent.appendChild(child);
3+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {expectType} from '../../../..';
2+
import append from '.';
3+
4+
const parent = document.createElement('div');
5+
const child = document.createElement('p');
6+
7+
expectType<void>(append(parent, child));

source/test/fixtures/dom/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "foo",
3+
"tsd": {
4+
"compilerOptions": {
5+
"lib": ["dom"]
6+
}
7+
}
8+
}

source/test/test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ test('add support for esm with esModuleInterop', async t => {
111111
verify(t, diagnostics, []);
112112
});
113113

114+
test('add DOM support by default', async t => {
115+
const diagnostics = await tsd({
116+
cwd: path.join(__dirname, 'fixtures/dom')
117+
});
118+
119+
verify(t, diagnostics, []);
120+
});
121+
114122
test('a lib option in package.json overrdides a lib option in tsconfig.json', async t => {
115123
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/lib-config/lib-from-package-json-overrides-tsconfig-json')});
116124

0 commit comments

Comments
 (0)