Skip to content

Conversation

@trusktr
Copy link
Owner

@trusktr trusktr commented Dec 18, 2025

small sample of making everything in PosterizeNode.js have TS-compatible type definitions

Related issue: #XXXX

Description

Shows how to format definitions that are compatible in downstream TS projects.

I have checked the doc generator, but this change may possibly break compatibility with that if the doc tool does not support TS-compatible JSDoc. If that's the case, we would need to either update that tool (possibly lots of work) or choose a different tool.

Copilot AI review requested due to automatic review settings December 18, 2025 04:17
@github-actions
Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 355.56
84.51
355.56
84.51
+0 B
+0 B
WebGPU 617.29
171.26
617.29
171.26
+0 B
+0 B
WebGPU Nodes 615.89
171.01
615.89
171.01
+0 B
+0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 487.73
119.38
487.73
119.38
+0 B
+0 B
WebGPU 688.74
187.04
688.74
187.04
+0 B
+0 B
WebGPU Nodes 638.58
174.23
638.58
174.23
+0 B
+0 B

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR proposes adding TypeScript-compatible type definitions to PosterizeNode.js as a sample implementation. The changes aim to improve TypeScript compatibility by introducing JSDoc @import syntax for type references and using @type annotations with function signatures instead of @function tags.

Key changes:

  • Adds a JSDoc @import statement to reference the Node type from the core module
  • Replaces the @function tag with a @type annotation that includes the full function signature for the posterize TSL function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,5 +1,6 @@
import TempNode from '../core/TempNode.js';
import { nodeProxy } from '../tsl/TSLBase.js';
/** @import Node from '../core/Node.js' */
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an extra space before the closing comment delimiter. The correct JSDoc @import syntax should have no extra spaces.

Suggested change
/** @import Node from '../core/Node.js' */
/** @import Node from '../core/Node.js' */

Copilot uses AI. Check for mistakes.
Comment on lines 62 to 64
* @param {Node} sourceNode - The input color.
* @param {Node} stepsNode - Controls the intensity of the posterization effect. A lower number results in a more blocky appearance.
* @returns {PosterizeNode}
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using @type to define a function signature, the @param and @returns tags become redundant and may confuse TypeScript-compatible tooling. When @type fully describes the function signature including parameters and return type, the separate @param and @returns tags should be removed to avoid duplication and potential inconsistency.

Suggested change
* @param {Node} sourceNode - The input color.
* @param {Node} stepsNode - Controls the intensity of the posterization effect. A lower number results in a more blocky appearance.
* @returns {PosterizeNode}

Copilot uses AI. Check for mistakes.
@@ -1,5 +1,6 @@
import TempNode from '../core/TempNode.js';
import { nodeProxy } from '../tsl/TSLBase.js';
/** @import Node from '../core/Node.js' */
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This @import syntax is not used anywhere else in the codebase and introduces a new pattern that is inconsistent with the existing documentation style. All other node files use @type annotations for Node references without @import statements. Additionally, Node types are already available through existing imports, making this @import unnecessary for JSDoc type checking.

Suggested change
/** @import Node from '../core/Node.js' */

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant