Skip to content

Commit

Permalink
fix(typescript): repair error reporting when a ts_project is missing …
Browse files Browse the repository at this point in the history
…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
```
  • Loading branch information
alexeagle committed May 28, 2021
1 parent 3c4ef58 commit cd08efe
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/typescript/internal/ts_project.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cd08efe

Please sign in to comment.