Skip to content

Commit

Permalink
Fix missing ES types regression in 0.15 (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendrucker committed May 25, 2021
1 parent 05f9f3b commit b39bd98
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -19,9 +19,9 @@
"prepublishOnly": "npm run build",
"pretest": "npm run build && cpy \"./**/**\" \"../../../dist/test/fixtures/\" --parents --cwd=source/test/fixtures",
"test": "npm run lint && ava",
"build": "npm run clean && tsc && chmod +x dist/cli.js",
"build": "npm run clean && tsc --project tsconfig.tsd.json && chmod +x dist/cli.js",
"clean": "del-cli dist",
"lint": "tslint -p . --format stylish"
"lint": "tslint -p tsconfig.tsd.json --format stylish"
},
"files": [
"dist/index.js",
Expand Down
6 changes: 5 additions & 1 deletion source/lib/config.ts
Expand Up @@ -34,7 +34,7 @@ export default (pkg: {tsd?: RawConfig}, cwd: string): Config => {
compilerOptions: {
strict: true,
jsx: JsxEmit.React,
lib: ['es2017', 'dom', 'dom.iterable'],
lib: parseRawLibs(['es2017', 'dom', 'dom.iterable'], cwd),
module: ModuleKind.CommonJS,
target: ScriptTarget.ES2017,
esModuleInterop: true,
Expand Down Expand Up @@ -67,3 +67,7 @@ function parseCompilerConfigObject(compilerOptions: RawCompilerOptions, cwd: str
cwd
).options;
}

function parseRawLibs(libs: string[], cwd: string): string[] {
return parseCompilerConfigObject({lib: libs}, cwd).lib || [];
}
4 changes: 4 additions & 0 deletions source/test/fixtures/dom/index.test-d.ts
Expand Up @@ -5,3 +5,7 @@ const parent = document.createElement('div');
const child = document.createElement('p');

expectType<void>(append(parent, child));

const elementsCollection = document.getElementsByClassName('foo');
expectType<HTMLCollectionOf<Element>>(elementsCollection);
expectType<() => IterableIterator<Element>>(elementsCollection[Symbol.iterator]);
7 changes: 1 addition & 6 deletions source/test/fixtures/dom/package.json
@@ -1,8 +1,3 @@
{
"name": "foo",
"tsd": {
"compilerOptions": {
"lib": ["dom"]
}
}
"name": "foo"
}
@@ -1,3 +1,8 @@
{
"name": "foo"
"name": "foo",
"tsd": {
"compilerOptions": {
"lib": []
}
}
}
File renamed without changes.

0 comments on commit b39bd98

Please sign in to comment.