TypeScript-as-JSDoc and updates - #269
Open
brettz9 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR modernizes the project’s TypeScript typing story (via TypeScript-as-JSDoc + generated declaration files) while refactoring the runtime to expose a JSONPathClass for monkey-patching, alongside dependency/tooling updates and corresponding test adjustments.
Changes:
- Refactor core runtime to use a
JSONPathClassimplementation (and update Node/browser adapters and tests accordingly). - Adopt TS checking for JS (
allowJs/checkJs) and switch from a hand-writtensrc/jsonpath.d.tsto generateddist/*.d.ts(including*.d.ctsfor CJS typing). - Update lint/build config and dev dependencies; refresh/expand tests to align with stricter typings.
Reviewed changes
Copilot reviewed 29 out of 47 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Enables JS type-checking and declaration generation settings for the repo. |
| tsconfig-prod.json | Adds a production TS config to emit declaration files. |
| test/test.type-operators.js | Updates tests to use imported callback types and tighter JSDoc annotations. |
| test/test.toPath.js | Uses Chai lengthOf assertion style for array length checks. |
| test/test.safe-eval.js | Adds JSDoc imports/types and TS-expect-error markers for VM/security tests. |
| test/test.performance.js | Refactors test data setup and adds JSDoc types to satisfy checkJs. |
| test/test.path_expressions.js | Updates reference URL to HTTPS. |
| test/test.intermixed.arr.js | Adds type casts for spread use under checkJs. |
| test/test.examples.js | Updates reference URL, refactors expected building, and adds JSDoc typing. |
| test/test.eval.js | Updates VM access to JSONPathClass.prototype.* and adds JSDoc imports/types. |
| test/test.errors.js | Adds TS-expect-error for intentionally invalid argument test. |
| test/test.cli.js | Adds cast for stderr typing under checkJs. |
| test/test.callback.js | Tightens callback param typing and result typing for checkJs. |
| test/test.at_and_dollar.js | Avoids implicit globals by typing globalThis usage for tests. |
| test/test.api.js | Adds many new regression tests and types jsonpath() results as JSONPathClass. |
| test/test.all.js | Re-formats expected objects (likely lint/style driven). |
| test-helpers/node-env.js | Exposes JSONPathClass on globalThis for tests. |
| test-helpers/checkVM.js | Introduces VmType typedef and type annotations for VM iteration. |
| src/Safe-Script.js | Adds JSDoc typing throughout safe-eval implementation and improves error construction. |
| src/jsonpath.js | Major refactor: introduces JSONPathClass, moves methods, tightens types, and changes monkey-patching surface. |
| src/jsonpath.d.ts | Removes the old hand-authored declaration file in favor of generated typings. |
| src/jsonpath-node.js | Moves vm monkey-patching target to JSONPathClass.prototype and adds typedef re-exports. |
| src/jsonpath-node.cts | Adds CJS typing entry for Node build. |
| src/jsonpath-browser.js | Moves browser Script monkey-patching to JSONPathClass.prototype and adds typedef re-exports. |
| rollup.config.js | Updates JSDoc typing for Rollup config and TS checking compatibility. |
| pnpm-workspace.yaml | Adds minimumReleaseAgeExclude exceptions for specific packages. |
| package.json | Updates exports/types mapping to generated dist typings; updates devDeps; adds build/attw scripts. |
| eslint.config.js | Updates config typing, import plugin rule names (import-x/*), and test globals. |
| dist/Safe-Script.d.ts | Adds generated declaration output for Safe-Script. |
| dist/jsonpath.d.ts | Adds generated declaration output for the main entry. |
| dist/jsonpath-node.d.ts | Adds generated declaration output for the Node entry. |
| dist/jsonpath-node.d.cts | Adds generated CJS declaration entry for Node. |
| dist/jsonpath-browser.d.ts | Adds generated declaration output for the browser entry. |
| dist/index-browser-umd.min.cjs | Updates built/minified UMD bundle output. |
| dist/index-browser-esm.min.js | Updates built/minified ESM bundle output. |
| demo/tsconfig.json | Adds demo-specific TS config (DOM libs) for checkJs friendliness. |
| demo/index.js | Tightens DOM element typing and adjusts URL/history usage for type checking. |
| bin/jsonpath-cli.js | Switches CLI to import the Node implementation from src/ and adds JSONValue typing. |
| badges/tests-badge.svg | Updates test badge counts. |
| .ncurc.cjs | Adds npm-check-updates configuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR description
@80avin : If you could take a look, I figure with you maintaining now, that I should get your approval first. There is a lot of diff noise, but I think it is worth adopting.
BREAKING CHANGES:
anytounknownto ensure type safety (by forcing type casts of the results on the user).JSONPathClassexportOther changes:
Fixes #114 ; closes #113 ; closes #115 .
Checklist
npm test, ensuring linting passes