File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ load ("@aspect_rules_js//js:providers.bzl" , "JsInfo" )
2+
3+ def _extract_types_impl (ctx ):
4+ """Implementation of the `extract_types` rule."""
5+ depsets = []
6+
7+ for dep in ctx .attr .deps :
8+ if JsInfo in dep :
9+ depsets .append (dep [JsInfo ].transitive_types )
10+ depsets .append (dep [JsInfo ].types )
11+
12+ types = depset (transitive = depsets )
13+
14+ return [
15+ DefaultInfo (files = types ),
16+ ]
17+
18+ extract_types = rule (
19+ implementation = _extract_types_impl ,
20+ doc = """
21+ Rule that collects all direct and transitive type definitions of specified targets. The
22+ definitons are then exposed through the `DefaultInfo` provider, allowing for easy
23+ consumption in other rules.
24+
25+ This rule can be helpful if TypeScript typings are shipped along with bundled runtime code.
26+ """ ,
27+ attrs = {
28+ "deps" : attr .label_list (
29+ doc = """List of targets for which all direct and transitive type definitions
30+ should be collected.""" ,
31+ allow_files = True ,
32+ mandatory = True ,
33+ ),
34+ },
35+ )
You can’t perform that action at this time.
0 commit comments