Skip to content

Add index.ts with export for all bindings. #133

@lab360-ch

Description

@lab360-ch

Hi

Would it be possible to also generate an index.ts inside the bindings directory?

example

When I have the following structs:

#[derive(Serialize, Debug, TS)]
#[ts(
    export,
    export_to = "bindings/admin/login-response.ts",
    rename = "AdminLoginResponse"
)]
struct LoginResponse {
    access_token: String,
    expires_in: i64,
    token_type: String,
}

#[derive(Deserialize, Validate, Debug, TS)]
#[ts(
    export,
    export_to = "bindings/admin/login-request.ts",
    rename = "AdminLoginRequest"
)]
struct LoginRequest {
    #[validate(email(message = "invalid email"))]
    email: String,
    #[validate(length(min = 8))]
    password: String,
}

I would like to have a index.ts generated inside the bindings directory, that looks like:

export * from './admin/login-request';
export * from './admin/login-response';

So I could add the following configuration to my tsconfig.json:

{
  ...
  "compilerOptions": {
    ...
    "paths": {
      "@my-project/backend": ["backend/bindings/index.ts"],
    }
  }
}

this allows me to import all the exported types in my typescript code like this:

import { AdminLoginRequest, AdminLoginResponse } from '@my-project/backend';

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIThis issue/PR is related to or requires the implementation of the CLI tool

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions