https://github.com/angular/angular
Raw File
Tip revision: a301b36f1f711ab956e37c4aee0010b44d9810ef authored by Andrew Kushnir on 09 March 2022, 17:04:59 UTC
release: cut the v14.0.0-next.6 release (#45301)
Tip revision: a301b36
extract_typings_rule.bzl
"""Starlark file that exposes a rule for extracting type definitions of dependencies."""

load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo")

def _extract_typings_rule_impl(ctx):
    """Implementation of the `extract_typings` rule."""
    transitive_depsets = []

    for dep in ctx.attr.deps:
        # Based on whether declarations should be collected, extract direct
        # and transitive declaration files using the `DeclarationInfo` provider.
        if DeclarationInfo in dep:
            transitive_depsets.append(dep[DeclarationInfo].transitive_declarations)

    return [DefaultInfo(files = depset(transitive = transitive_depsets))]

# TODO: Move into shared dev-infra package.
extract_typings = rule(
    implementation = _extract_typings_rule_impl,
    doc = """Rule that extracts all transitive typings of dependencies""",
    attrs = {
        "deps": attr.label_list(
            allow_files = True,
        ),
    },
)
back to top