Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing ES types regression in 0.15 #100

Merged
merged 5 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
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
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: ['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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{
"name": "foo",
"tsd": {
"compilerOptions": {
"lib": ["dom"]
}
}
"name": "foo"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"name": "foo"
"name": "foo",
"tsd": {
"compilerOptions": {
"lib": []
}
}
}
File renamed without changes.