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

Support project-only exports #58891

Closed
6 tasks done
MichaelMitchell-at opened this issue Jun 17, 2024 · 2 comments
Closed
6 tasks done

Support project-only exports #58891

MichaelMitchell-at opened this issue Jun 17, 2024 · 2 comments
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript

Comments

@MichaelMitchell-at
Copy link

MichaelMitchell-at commented Jun 17, 2024

πŸ” Search Terms

project only exports isolated declarations

βœ… Viability Checklist

⭐ Suggestion

Introduce a keyword/syntax for declaring that an export should only be visible to other files within the same project. Ideally this would also cause the export to be elided from declaration emit which would also allow it to be exempt from the requirements of isolated declarations.

πŸ“ƒ Motivating Example

Use cases:

  • Exports only used in tests, e.g. mocking, stubbing .
  • Relieve some of the burden of providing explicit type annotations for more complex types which are only used internally within a project.
  • Potential to optimize dependency graph of composite projects: If A depends on B which uses C internally, A should be able to start typechecking if declarations for B have been emitted without waiting for declarations of C to be emitted (There would need to be follow-up tooling be built that can perform such an analysis. Right now the build system we use naively assumes that type dependencies are transitive).
  • May address Suggestion: making exports visible only to the same directory with JSDoc @package tagΒ #41425 if equivalent JSDoc tag is provided.
  • May help with a subset of the cases where Support for opting out of jsdoc @typedef exportsΒ #46011 might be an issue.

πŸ’» Use Cases

  1. See above
  2. n/a
  3. Wrap exports in a class and make them private. Other files in the project can access the private member via index['_notation']. Other projects can still technically access the members but they will be typed as any.
@fatcerberus
Copy link

Similar issues: #58250, #41316, #5228, and maybe #35554

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature labels Jun 18, 2024
@MichaelMitchell-at
Copy link
Author

Actually I think @internal jsdoc tags with the "stripInternal": true tsconfig setting accomplish what I'm looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting More Feedback This means we'd like to hear from more people who would be helped by this feature Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants