Skip to content

[feature] Allow more general namespacing #30

@siefkenj

Description

@siefkenj

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions