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

[feature] Allow more general namespacing #30

Open
siefkenj opened this issue Apr 12, 2024 · 0 comments
Open

[feature] Allow more general namespacing #30

siefkenj opened this issue Apr 12, 2024 · 0 comments

Comments

@siefkenj
Copy link
Owner

The proposal is to add a namespace_path attribute that would accept a syn::Path. The generated type would then be wrapped in the specified namespace (with :: indicating levels of the namespace).

For example:

#[derive(Tsify)]
#[tsify(namespace_path = My::Path)]
struct Foo { a: i32 }

would produce

declare namespace My {
  declare namespace Path {
    interface Foo { a: number }
  }
}

There should be a corresponding option to use a path as a namespace for a declared type. For example

#[declare]
#[tsify(path_as_namespace)]
type Foo = my::path::X;

would produce

export type Foo = my.path.X;

This would give a way to handle name collisions, addressing #16

Not sure what the best name for the attrs should be. It also doesn't follow Typescripts convention of using CamelCase to name namespaces, but a compromise needs to be made somewhere...

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

1 participant