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

Re-export type from another module #50122

Closed
5 tasks done
magic-akari opened this issue Aug 1, 2022 · 2 comments
Closed
5 tasks done

Re-export type from another module #50122

magic-akari opened this issue Aug 1, 2022 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@magic-akari
Copy link
Contributor

Suggestion

πŸ” Search Terms

  • TS1383
  • re-export type

List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.

βœ… Viability Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

⭐ Suggestion

Allow re-export type.

We can use export from statement in JavaScript..

export { foo } from "mod"

and in TypeScript, we can export type from another module.

export type { foo } "mod";
// or
export { type foo } from "mod";

Note: They are different when transforming to JavaScript.
The first statement will be removed and the second will be export {} from "mod" or import "mod".

When it comes to re-export, for example,

export * from "mod";

If we try to write

export type * from "mod";

We will get a TS1383 error.

Only named exports may use 'export type'.

πŸ“ƒ Motivating Example

To be added.

I have no strong need for it, just as a record.

πŸ’» Use Cases

export * from "mod" will generate runtime export statement. To avoid this, one has to list all the type.

export type { foo, bar, baz, ...and more } from "mod";
@whzx5byb
Copy link

whzx5byb commented Aug 1, 2022

Duplicate of #37238

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Aug 4, 2022
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants