https://github.com/angular/angular
Raw File
Tip revision: 54d09a6bc0e1b7c870ef79c4b32295e223ca8030 authored by Alex Rickabaugh on 16 February 2022, 23:48:40 UTC
release: cut the v13.2.3 release (#45116)
Tip revision: 54d09a6
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