Fix ES2015 built-in type errors in consumers by adding lib reference directive to published declarations#558
Fix ES2015 built-in type errors in consumers by adding lib reference directive to published declarations#558Copilot wants to merge 4 commits into
Conversation
Agent-Logs-Url: https://github.com/nevware21/ts-utils/sessions/2aef322b-e961-4a68-9320-06e44706e006 Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #558 +/- ##
=======================================
Coverage 99.46% 99.46%
=======================================
Files 145 145
Lines 4271 4271
Branches 938 938
=======================================
Hits 4248 4248
Misses 23 23
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR makes the required TypeScript standard library typings explicit across the library build and test tsconfig files by declaring ES2015 (and ESNext for ESNext tests) alongside DOM, preventing missing built-in type errors during compilation.
Changes:
- Add
"lib": ["ES2015", "DOM"]to the sharedlib/tsconfig.base.jsonso it propagates to the library build configs viaextends. - Add
"lib": ["ES2015", "DOM"]to the ES5-oriented test tsconfigs (Node + Karma runner configs). - Add
"lib": ["ESNext", "DOM"]to the ESNext test tsconfig.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/tsconfig.base.json | Declares ES2015 + DOM libs for the base compiler config used by library builds. |
| lib/test/tsconfig.worker.karma.json | Declares ES2015 + DOM libs for worker Karma test compilation. |
| lib/test/tsconfig.test.karma.json | Declares ES2015 + DOM libs for browser Karma test compilation. |
| lib/test/tsconfig.test.json | Declares ES2015 + DOM libs for Node/common test compilation via ts-mocha. |
| lib/test/tsconfig.test.esnext.json | Declares ESNext + DOM libs for ESNext test compilation. |
|
@copilot This is only addressing the local test resources and not the actual reported issue. |
…ELOG Agent-Logs-Url: https://github.com/nevware21/ts-utils/sessions/241c832b-e34d-4648-abcd-efe1276dc2a1 Co-authored-by: nev21 <82737406+nev21@users.noreply.github.com>
Addressed in commit 337e0e8. The actual fix is a The implementation:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
nevware21-bot
left a comment
There was a problem hiding this comment.
Approved by nevware21-bot
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Consumers using
"lib": ["ES5", "DOM"](or omittinglibentirely) get TypeScript errors likeCannot find name 'Symbol'/Cannot find name 'Iterator'because the package's published.d.tsfile references ES2015 built-ins without declaring that dependency to TypeScript.Root Cause
The bundled declaration file (
lib/dist/types/ts-utils.d.ts) exposes ES2015 types such asSymbol,Iterator<T>,Iterable<T>,IterableIterator<T>, andPromise<T>in its public API surface. Without a/// <reference lib="es2015" />directive in the published file, consumers must manually add"lib": ["ES2015"]to their owntsconfig.json— otherwise TypeScript cannot resolve these types.Changes
lib/src/index.tsandlib/src/polyfills.ts— adds/// <reference lib="es2015" />to the source entry points so TypeScript includes the directive in generated.d.tsfiles and validates against ES2015 types at build timelib/scripts/setTsReferences.js— new post-processing script that prepends/// <reference lib="es2015" />to the api-extractor bundled output (lib/dist/types/ts-utils.d.ts); this is required because api-extractor strips/// <reference lib="..." />directives from its rolluppackage.json— updates thedtsgenscript toapi-extractor run --local --verbose && node lib/scripts/setTsReferences.jsso the post-processing runs automatically as part of every buildlib/tsconfig.base.json— adds"lib": ["ES2015", "DOM"]; propagates to both the ES5 and ES6 build configs viaextendslib/test/tsconfig.test.json,lib/test/tsconfig.test.karma.json,lib/test/tsconfig.worker.karma.json— add"lib": ["ES2015", "DOM"]lib/test/tsconfig.test.esnext.json— adds"lib": ["ESNext", "DOM"]CHANGELOG.md— adds bug fix entry for v0.13.0The net effect is that consumers who import from
@nevware21/ts-utilsautomatically get the ES2015 type definitions included by TypeScript — no change to their owntsconfig.jsonis required.DOMis included alongsideES2015in all tsconfig files because the public API exports types likeWindow,Document,Navigator, andHistory(fromhelpers/environment.ts), which require the DOM lib to resolve.This does not change the JavaScript runtime target or emit.