-
Notifications
You must be signed in to change notification settings - Fork 734
Export all types referenced through other exported APIs, enforce #1978
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR systematically exports internal types throughout the codebase by capitalizing their names (e.g., usage → Usage, fileIncludeReason → FileIncludeReason). The changes also add a new custom linter unexportedapi to detect exported APIs that reference unexported types, helping maintain API consistency going forward.
Key changes:
- Export numerous internal types across multiple packages (vfs, project, compiler, checker, execute, etc.)
- Add
unexportedapicustom linter with comprehensive test coverage - Update all references to use the new exported names
Reviewed Changes
Copilot reviewed 57 out of 57 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
internal/vfs/utilities.go |
Exports Usage type and related constants |
internal/repo/paths.go |
Exports SkippableTest interface |
internal/project/*.go |
Exports multiple types: PatternsAndIgnored, SnapshotFS, Overlay, ExtendedConfigCache, ProjectCollectionBuilder, CheckerPool |
internal/compiler/*.go |
Exports FileIncludeReason type and updates all references |
internal/execute/incremental/*.go |
Exports FileInfo, DiagnosticsOrBuildInfoDiagnosticsWithFileName |
internal/execute/build/*.go |
Exports BuildTask type |
internal/execute/tsctests/*.go |
Exports TestSys type |
internal/checker/*.go |
Exports NodeBuilderImpl, EmitResolver |
internal/ast/ast.go |
Exports MutableNode type |
internal/ls/*.go |
Exports ReferenceEntry, DefinitionKind, SortText, ExportInfoMap |
internal/pprof/pprof.go |
Exports ProfileSession |
internal/fourslash/fourslash.go |
Simplifies AnyTextEdits from type alias to direct variable |
internal/format/*.go |
Exports FormattingContext |
_tools/customlint/*.go |
Adds new unexportedapi linter with comprehensive tests |
|
FYI @camc314 |
Getting this lint rule prototype out of my git stash.
Exported APIs containing unexported elements is generally annoying, because it means consuming code can't write down the type name but can do things with it (even still creating values of that type via generic helpers!). It also means people doing funky stuff like tsgolint have to work around APIs that aren't fully declared.
This PR adds a lint rule to find these cases and complain, then fixes everything.