From e6b6276b5fc0d994da5563204227f1ad020600ac Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Tue, 11 Jan 2022 16:57:51 -0800 Subject: [PATCH] fix(typescript): better error when transpiler is used and no declarations are emitted Fixes #3209 --- packages/typescript/index.bzl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/typescript/index.bzl b/packages/typescript/index.bzl index 800c1d7920..7f9ef4ff81 100644 --- a/packages/typescript/index.bzl +++ b/packages/typescript/index.bzl @@ -549,11 +549,19 @@ def ts_project( ) if not len(tsc_js_outs) and not len(typings_outs): - fail("""ts_project target "//{}:{}" is configured to produce no outputs. - -Note that ts_project must know the srcs in advance in order to predeclare the outputs. -Check the srcs attribute to see that some .ts files are present (or .js files with allow_js=True). -""".format(native.package_name(), name)) + label = "//{}:{}".format(native.package_name(), name) + if transpiler: + no_outs_msg = "ts_project target %s with custom transpiler needs `declaration = True`." % label + else: + no_outs_msg = """ts_project target %s is configured to produce no outputs. + +This might be because +- you configured it with `noEmit` +- the `srcs` are empty +""" % label + fail(no_outs_msg + """ +This is an error because Bazel does not run actions unless their outputs are needed for the requested targets to build. +""") _ts_project( name = tsc_target_name,