Skip to content

Commit

Permalink
fix(typescript): better error when transpiler is used and no declarat…
Browse files Browse the repository at this point in the history
…ions are emitted

Fixes #3209
  • Loading branch information
alexeagle authored and gregmagolan committed Jan 12, 2022
1 parent fcbe1e6 commit 72c3662
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/typescript/index.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 72c3662

Please sign in to comment.