https://github.com/angular/angular
Revision 6f1c941dfec8cf0ea0ccbb0fda76f3d960fd843b authored by Andrew Kushnir on 09 March 2022, 16:53:23 UTC, committed by GitHub on 09 March 2022, 16:53:23 UTC
1 parent 9bce9ce
Raw File
Tip revision: 6f1c941dfec8cf0ea0ccbb0fda76f3d960fd843b authored by Andrew Kushnir on 09 March 2022, 16:53:23 UTC
release: cut the v13.2.6 release (#45299)
Tip revision: 6f1c941
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