From cd08efed0169b1a33b42d14ea01836cac76cf1b8 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 28 May 2021 10:58:05 -0700 Subject: [PATCH] fix(typescript): repair error reporting when a ts_project is missing declaration=True Now prints this like it should: ``` ERROR: /home/alexeagle/Projects/rules_nodejs/examples/web_testing/BUILD.bazel:16:11: in deps attribute of ts_project rule //:tests: '//:lib' does not have mandatory providers: 'DeclarationInfo' or '_ValidOptionsInfo'. Since this rule was created by the macro 'ts_project_macro', the error might have been caused by the macro implementation ``` --- packages/typescript/internal/ts_project.bzl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/typescript/internal/ts_project.bzl b/packages/typescript/internal/ts_project.bzl index 0e0e658a1a..64f704bb0f 100644 --- a/packages/typescript/internal/ts_project.bzl +++ b/packages/typescript/internal/ts_project.bzl @@ -233,10 +233,11 @@ def _ts_project_impl(ctx): ])), ] - # Don't provide DeclarationInfo if there are no typings to provide. + # Only provide DeclarationInfo if there are some typings. # Improves error messaging if a ts_project needs declaration = True - if len(typings_outputs) or len(ctx.attr.deps): - providers.append(declaration_info(depset(typings_outputs), ctx.attr.deps)) + typings_in_deps = [d for d in ctx.attr.deps if DeclarationInfo in d] + if len(typings_outputs) or len(typings_in_deps): + providers.append(declaration_info(depset(typings_outputs), typings_in_deps)) providers.append(OutputGroupInfo(types = depset(typings_outputs))) return providers