Skip to content

feat: improve TypeScript type definitions with optional parameters #665

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

Merged
merged 2 commits into from
Aug 15, 2025

Conversation

UmbraCi
Copy link
Contributor

@UmbraCi UmbraCi commented Aug 15, 2025

Description

This PR improves the TypeScript type definitions for jsMind by making most configuration options optional, which provides better developer experience and matches the actual usage patterns shown in the official documentation.

Changes Made

Type Definition Improvements

  • Convert required fields to optional: Most configuration fields in are now optional (using syntax)
  • Enhanced flexibility: Only remains required, all other options are optional with sensible defaults
  • Better API usability: Developers can now use minimal configuration without being forced to specify all options

New Type Support

  • Extended option: Added support for value alongside existing and
  • Improved zoom configuration: Made zoom object properties optional for better flexibility

Documentation & Testing

  • Updated JSDoc comments: Reflect the new optional parameter structure
  • Enhanced test coverage: Added comprehensive tests for optional parameters and new type features
  • Type validation examples: Updated test fixtures to demonstrate proper usage patterns

Benefits

  1. Developer Experience: Easier to get started with jsMind using minimal configuration
  2. Type Safety: Better TypeScript support with proper optional parameter handling
  3. API Consistency: Matches the actual behavior where most options have sensible defaults
  4. Documentation Alignment: Type definitions now accurately reflect the official documentation examples

Breaking Changes

⚠️ None - This is a purely additive change that improves type definitions without affecting runtime behavior.

Testing

  • All existing tests pass
  • New type validation tests added
  • Optional parameter tests cover edge cases
  • TypeScript compilation verified

Related Issues

This addresses the need for more flexible TypeScript type definitions that better represent the actual API usage patterns.

Checklist

  • Code follows the project's style guidelines
  • Tests added for new functionality
  • Documentation updated
  • No breaking changes introduced
  • TypeScript types are accurate and comprehensive

- Convert required configuration fields to optional in JsMindRuntimeOptions
- Add support for 'visible' value in node_overflow option
- Update type definitions to match official documentation examples
- Enhance test coverage for optional parameters and new type features
- Improve API flexibility by making most options optional except container
- Update JSDoc comments to reflect optional parameter changes
Copy link
Owner

@hizzgdev hizzgdev left a comment

Choose a reason for hiding this comment

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

PTAL

…lementation

- Update direction parameter JSDoc in add_node, insert_node_before, insert_node_after, move_node functions
- Add support for numeric strings ('-1', '0', '1') and numbers (-1, 0, 1) in addition to string values
- Document that Direction.of() function supports multiple input types as shown in jsmind.common.js
- Improve API documentation accuracy and developer experience
@hizzgdev
Copy link
Owner

Thanks! @UmbraCi

@hizzgdev hizzgdev merged commit 92212a7 into hizzgdev:master Aug 15, 2025
4 checks passed
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.

2 participants