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

Bug: Generics are not handled correctly in TypeScript definition output #39

Open
mattatz opened this issue Jul 23, 2024 · 1 comment
Open

Comments

@mattatz
Copy link

mattatz commented Jul 23, 2024

Thank you for updating Tsify project! 😃

I encountered an issue while using the tsify_next::Tsify derive macro.
When defining a struct with generics, the generated TypeScript definition does not handle the generics correctly.

Specifically, when I define:

#[derive(tsify_next::Tsify)]
pub struct Polyline<const D: usize> {
    pub points: Vec<Point<f64, D>>,
}

the index.d.ts file incorrectly outputs:

export interface Polyline {
    points: Point<number, D>[];
}

The generic D is not handled properly, which causes type definition issues in TypeScript.

@siefkenj
Copy link
Owner

Yes, it appears const generics should be handled differently!

If you're interested in attempting a PR for this feature, please let me know.

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

No branches or pull requests

2 participants