Skip to content
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

Fix Generics for LayoutManager #225

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

JumpLink
Copy link
Collaborator

@JumpLink JumpLink commented Nov 13, 2024

Description

Implements generic type support for St.Widget to provide proper type checking for layout managers. This change allows TypeScript to correctly infer and check layout manager types when using St.Widget with different layout managers.

Related Issue

Fixes #145

@KSXGitHub Can you try to test and review this changes?

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Type definition update

Validation

The changes demonstrate proper generic type usage with St.Widget.

Test Location: examples/st-15-layout-manager/main.ts

Test Case:

export class GridLayoutWidget extends St.Widget<Clutter.GridLayout> {
    static {
        GObject.registerClass({
            GTypeName: 'GridLayoutWidget',
        }, this);
    }
    constructor() {
        super({
            layout_manager: new Clutter.GridLayout()
        });
        // TypeScript now properly recognizes layout_manager methods
        this.layout_manager.attach(
            new St.Label({ text: 'Test' }),
            0, 0, 1, 1
        );
    }
}

Expected Behavior:

  1. Type generator correctly adds generic support for St.Widget
  2. TypeScript properly infers layout manager types
  3. IDE provides correct type checking and autocompletion for layout manager methods

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • The implementation matches other generic type implementations (like Gtk)
  • Added tests to verify generic type generation

@JumpLink JumpLink changed the title Fix generics for LayoutManager, fixes #145 Fix generics for LayoutManager Nov 13, 2024
@JumpLink JumpLink changed the title Fix generics for LayoutManager Fix Generics for LayoutManager Nov 13, 2024
@KSXGitHub
Copy link

What TypeScript definitions does this code generate?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants