Tighten TS defs and add Arc module types - #840
Merged
Merged
Conversation
Adds a new declaration file for `two.js/extras/jsm/arc` and broad TypeScript definition improvements across shapes, effects, renderers, registry, and core APIs. This aligns typings with runtime behavior (e.g., optional `clone` parents, `release` overloads, `makeTexture` input types, renderer constructor params, and ZUI overloads), and updates the TypeScript test file to cover the new and corrected type contracts.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
There are verified type/runtime mismatches in the new/modified declarations (notably Arc.clone contract vs runtime) and a couple of typing inaccuracies that should be corrected before merging.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR expands and tightens Two.js TypeScript declarations to better reflect runtime behavior, including adding a new declaration for the two.js/extras/jsm/arc module and extending the TypeScript compilation test to exercise the updated contracts.
Changes:
- Added
two.js/extras/jsm/arcTypeScript declarations and updated the TS test to import/useArc. - Tightened core typings (e.g.,
Two#releaseoverloads,Two#makeTextureinput types) and improved type coverage for cloning APIs across shapes/effects. - Refined extra / renderer typings (e.g., ZUI overloads, renderer constructor parameter objects) and added
Registry#contains.
File summaries
| File | Description |
|---|---|
| tests/typescript/index.ts | Extends TS compilation coverage for new/updated type contracts (Arc, ZUI, renderers, release/makeTexture, clones). |
| src/two.d.ts | Refines release overloads and narrows makeTexture input types. |
| src/text.d.ts | Adds a Text#clone(parent?) signature to match runtime. |
| src/shapes/star.d.ts | Makes clone(parent) optional. |
| src/shapes/rounded-rectangle.d.ts | Adds clone(parent?) signature and imports Group for typing. |
| src/shapes/rectangle.d.ts | Makes clone(parent) optional. |
| src/shapes/polygon.d.ts | Adds radius and makes clone(parent) optional. |
| src/shapes/points.d.ts | Makes clone(parent) optional. |
| src/shapes/ellipse.d.ts | Adds clone(parent?) signature and imports Group for typing. |
| src/shapes/circle.d.ts | Makes clone(parent) optional. |
| src/shapes/arc-segment.d.ts | Makes clone(parent) optional. |
| src/renderers/webgl.d.ts | Requires a parameter object and tightens the constructor param shape. |
| src/renderers/svg.d.ts | Requires a parameter object and tightens the constructor param shape. |
| src/renderers/canvas.d.ts | Requires a parameter object and tightens the constructor param shape. |
| src/registry.d.ts | Adds contains(id): boolean to Registry typings. |
| src/effects/image.d.ts | Adds Image#clone(parent?) signature and imports Group for typing. |
| src/effects/image-sequence.d.ts | Makes clone(parent) optional. |
| src/effects/gradient.d.ts | Fixes Gradient.fromObject stops typing to accept Stop or stop-like objects. |
| extras/jsm/zui.d.ts | Tightens ZUI constructor and adds overloads for coordinate conversion and limits. |
| extras/jsm/arc.d.ts | Introduces new Arc module declarations. |
Review details
- Files reviewed: 1/20 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Adds a new declaration file for
two.js/extras/jsm/arcand broad TypeScript definition improvements across shapes, effects, renderers, registry, and core APIs. This aligns typings with runtime behavior (e.g., optionalcloneparents,releaseoverloads,makeTextureinput types, renderer constructor params, and ZUI overloads), and updates the TypeScript test file to cover the new and corrected type contracts.