Skip to content

Commit

Permalink
Add dom lib by default
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren committed May 10, 2021
1 parent d2284a1 commit f5b69ed
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default (pkg: {tsd?: RawConfig}, cwd: string): Config => {
compilerOptions: {
strict: true,
jsx: JsxEmit.React,
lib: ['lib.es2017.d.ts'],
lib: ['es2017', 'dom'],
module: ModuleKind.CommonJS,
target: ScriptTarget.ES2017,
esModuleInterop: true,
Expand Down
1 change: 1 addition & 0 deletions source/test/fixtures/dom/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default function(parent: HTMLElement, child: HTMLElement): void;
3 changes: 3 additions & 0 deletions source/test/fixtures/dom/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports.default = (parent, child) => {
parent.appendChild(child);
};
7 changes: 7 additions & 0 deletions source/test/fixtures/dom/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {expectType} from '../../../..';
import append from '.';

const parent = document.createElement('div');
const child = document.createElement('p');

expectType<void>(append(parent, child));
8 changes: 8 additions & 0 deletions source/test/fixtures/dom/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "foo",
"tsd": {
"compilerOptions": {
"lib": ["dom"]
}
}
}
8 changes: 8 additions & 0 deletions source/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ test('add support for esm with esModuleInterop', async t => {
verify(t, diagnostics, []);
});

test('add DOM support by default', async t => {
const diagnostics = await tsd({
cwd: path.join(__dirname, 'fixtures/dom')
});

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

test('a lib option in package.json overrdides a lib option in tsconfig.json', async t => {
const diagnostics = await tsd({cwd: path.join(__dirname, 'fixtures/lib-config/lib-from-package-json-overrides-tsconfig-json')});

Expand Down

0 comments on commit f5b69ed

Please sign in to comment.