Skip to content

Conversation

@jkschneider
Copy link
Member

@jkschneider jkschneider commented Jan 17, 2026

Summary

  • Changes RightPadded<T extends J> and LeftPadded<T extends J> from wrapper objects with an .element property to intersection types where the padded value IS the element with padding mixed in
  • Aligns the TypeScript model more closely with the Java model and simplifies property access
  • Adds function overloads for visitLeftPadded/visitRightPadded with improved type safety (primitives never return undefined)
  • Fixes various issues discovered during the migration:
    • Fixed unwrap() in comparator.ts for intersection types
    • Added guards for missing padding in formatting methods
    • Fixed WhitespaceReconciler to use ID comparison for stopAfter functionality
    • Added hasSameKind override in semantic comparator for void/undefined equivalence

This changes `RightPadded<T extends J>` and `LeftPadded<T extends J>` from
wrapper objects with an `element` property to intersection types where the
padded value IS the element with padding mixed in:

- `RightPadded<T extends J>` = `T & RightPaddingMixin`
- `LeftPadded<T extends J>` = `T & LeftPaddingMixin`

This aligns the TypeScript model more closely with the Java model and
simplifies property access (no more `.element` for J nodes).

Key changes:
- Updated type definitions in tree.ts for intersection-based padding
- Fixed visitor methods to handle intersection types correctly
- Added function overloads for visitLeftPadded/visitRightPadded with
  type-safe return types (primitives never return undefined)
- Fixed unwrap() in comparator.ts for intersection types (parens.tree
  instead of parens.tree.element)
- Added guards for missing padding in formatting methods
- Fixed WhitespaceReconciler to use ID comparison instead of reference
  equality for stopAfter functionality
- Added hasSameKind override in semantic comparator for void/undefined
  equivalence
@jkschneider jkschneider force-pushed the jkschneider/js-flat-padding branch from 648060e to 5cd8271 Compare January 17, 2026 00:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants