feat(js): generate types attribute on js_library package targets#208
Open
rdark wants to merge 1 commit intoaspect-build:mainfrom
Open
feat(js): generate types attribute on js_library package targets#208rdark wants to merge 1 commit intoaspect-build:mainfrom
rdark wants to merge 1 commit intoaspect-build:mainfrom
Conversation
|
When a js_library package target wraps a ts_project source rule that contains TypeScript source files (.ts, .tsx, etc.), generate a `types` attribute listing those files. This ensures TypeScript sources propagate through JsInfo.transitive_types so downstream ts_project targets can type-check in Bazel's sandbox without manual `# keep` annotations. Only js_library (not npm_package) package targets receive the types attribute, and only when the associated source rule has transpilable TypeScript files. - Use isTranspiledSourceFileType (not isTranspiledSourceFileExt) to exclude .d.ts declaration files from types - Incremental test (pnpm_workspace-incremental) only targets app/ dir, so lib/c/BUILD.out must match BUILD.in (no types) - Add types expectation to runner/tests/crossresolve-pnpm-names
5c1ccee to
ae45b19
Compare
fifitrixabelle
approved these changes
Mar 10, 2026
Member
|
I don't think we'd want this when the types are already in the Shouldn't this also only include |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
When
js_libraryis used as a package target (viajs_package_rule_kinddirective), gazelle now generates atypesattribute containing TypeScript source files (.ts,.cts,.mts,.tsx,.jsx) from the associatedts_projectrule.The
typesattribute propagates TypeScript source files throughJsInfo.transitive_types, enabling downstreamts_projecttargets to type-check correctly in Bazel's sandbox without manual# keepcomments on thetypesattribute.Changes
language/js/kinds.go: Added"types": truetoJsLibraryKind.MergeableAttrsso gazelle manages the attribute during mergelanguage/js/generate.go:rule.RuletoaddPackageRuleso it can inspectts_project_infoTsProjectInfo.sourcesand set astypesonjs_librarypackage targetsBUILD.outfiles to include expectedtypesattributeBehavior
packageTargetKind == JsLibraryKind(notnpm_package)typeswhen there is an associated source rule with TypeScript filessrcRule) are unaffectedsrcsonts_projectMotivation
In monorepos using
js_libraryas the package target, thetypesattribute must be manually maintained with# keepcomments since gazelle doesn't generate it. This is error-prone and creates maintenance burden.