Skip to content

Commit b39bd98

Browse files
authored
Fix missing ES types regression in 0.15 (#100)
1 parent 05f9f3b commit b39bd98

File tree

6 files changed

+18
-10
lines changed

6 files changed

+18
-10
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"prepublishOnly": "npm run build",
2020
"pretest": "npm run build && cpy \"./**/**\" \"../../../dist/test/fixtures/\" --parents --cwd=source/test/fixtures",
2121
"test": "npm run lint && ava",
22-
"build": "npm run clean && tsc && chmod +x dist/cli.js",
22+
"build": "npm run clean && tsc --project tsconfig.tsd.json && chmod +x dist/cli.js",
2323
"clean": "del-cli dist",
24-
"lint": "tslint -p . --format stylish"
24+
"lint": "tslint -p tsconfig.tsd.json --format stylish"
2525
},
2626
"files": [
2727
"dist/index.js",

source/lib/config.ts

Lines changed: 5 additions & 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: ['es2017', 'dom', 'dom.iterable'],
37+
lib: parseRawLibs(['es2017', 'dom', 'dom.iterable'], cwd),
3838
module: ModuleKind.CommonJS,
3939
target: ScriptTarget.ES2017,
4040
esModuleInterop: true,
@@ -67,3 +67,7 @@ function parseCompilerConfigObject(compilerOptions: RawCompilerOptions, cwd: str
6767
cwd
6868
).options;
6969
}
70+
71+
function parseRawLibs(libs: string[], cwd: string): string[] {
72+
return parseCompilerConfigObject({lib: libs}, cwd).lib || [];
73+
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ const parent = document.createElement('div');
55
const child = document.createElement('p');
66

77
expectType<void>(append(parent, child));
8+
9+
const elementsCollection = document.getElementsByClassName('foo');
10+
expectType<HTMLCollectionOf<Element>>(elementsCollection);
11+
expectType<() => IterableIterator<Element>>(elementsCollection[Symbol.iterator]);

source/test/fixtures/dom/package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
{
2-
"name": "foo",
3-
"tsd": {
4-
"compilerOptions": {
5-
"lib": ["dom"]
6-
}
7-
}
2+
"name": "foo"
83
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"name": "foo"
2+
"name": "foo",
3+
"tsd": {
4+
"compilerOptions": {
5+
"lib": []
6+
}
7+
}
38
}
File renamed without changes.

0 commit comments

Comments
 (0)