https://github.com/angular/angular
Raw File
Tip revision: f817e304053716d6a957c5c4863ea549ca9fbccd authored by Andrew Scott on 10 November 2021, 23:53:08 UTC
release: cut the v13.1.0-next.1 release (#44141)
Tip revision: f817e30
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