Skip to content

Commit

Permalink
fix: do not declare _typecheck[_test] target when using tsc as transp…
Browse files Browse the repository at this point in the history
…iler

Fix aspect-build#719
  • Loading branch information
jbedard committed Oct 18, 2024
1 parent a6a7588 commit b1d987e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
34 changes: 31 additions & 3 deletions examples/transpiler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ build_test(
targets = [
# babel ts_project
":babel",
":babel_typecheck",
":babel_types",
# babel outputted js
"big.js", # NOTE: does not implement out_dir in this test
# tsc outputted dts
Expand Down Expand Up @@ -122,6 +122,36 @@ build_test(
],
)

# custom js & dts transpilers, tsc will not run for typechecking when only requesting transpiled files.
# Tagging as manual should prevent the typecheck from running even when requesting
# transpiler output files.
ts_project(
name = "typecheck_fail-custom_transpilers",
srcs = ["typecheck_fail.ts"],
declaration = True,
declaration_transpiler = partial.make(
tsc_dts,
args = ["--noCheck"],
out_dir = "build-typecheck_fail-custom_transpilers",
),
out_dir = "build-typecheck_fail-custom_transpilers",
source_map = True,
tags = ["manual"],
transpiler = partial.make(
tsc_js,
args = ["--noCheck"],
out_dir = "build-typecheck_fail-custom_transpilers",
),
)

build_test(
name = "typecheck_fail-custom_transpilers_test",
targets = [
":typecheck_fail-custom_transpilers",
":typecheck_fail-custom_transpilers_types",
],
)

# custom js & dts transpilers, tsc still run for typechecking
ts_project(
name = "custom_transpilers",
Expand Down Expand Up @@ -214,7 +244,6 @@ build_test(
targets = [
":custom_dts_transpiler",
":custom_dts_transpiler_types",
":custom_dts_transpiler_typecheck",
"build-custom_dts_transpiler/a.js",
"build-custom_dts_transpiler/a.d.ts",
],
Expand Down Expand Up @@ -243,7 +272,6 @@ build_test(
name = "custom_dts_transpiler-no_declarations-test",
targets = [
":custom_dts_transpiler-no_declarations",
":custom_dts_transpiler-no_declarations_typecheck",
"build-custom_dts_transpiler-no_declarations/a.js",
],
)
Expand Down
4 changes: 2 additions & 2 deletions examples/transpiler/tsc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def tsc_dts(name, srcs, out_dir, **kwargs):
name = name,
srcs = srcs + ["tsconfig.json"],
outs = ["%s/%s" % (out_dir, src.replace(".ts", ".d.ts")) for src in srcs],
args = [
args = kwargs.pop("args", []) + [
"-p %s/tsconfig.json" % native.package_name(),
"--emitDeclarationOnly",
"--outDir %s/%s" % (native.package_name(), out_dir),
Expand All @@ -22,7 +22,7 @@ def tsc_js(name, srcs, out_dir, **kwargs):
name = name,
srcs = srcs + ["tsconfig.json"],
outs = ["%s/%s" % (out_dir, src.replace(".ts", ".js")) for src in srcs],
args = [
args = kwargs.pop("args", []) + [
"-p %s/tsconfig.json" % native.package_name(),
"--declaration",
"false",
Expand Down
2 changes: 1 addition & 1 deletion ts/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def ts_project(
)

# If the primary target does not output dts files then type-checking has a separate target.
if not emit_tsc_js or not emit_tsc_dts:
if not emit_tsc_js and not emit_tsc_dts:
typecheck_target_name = "%s_typecheck" % name
test_target_name = "%s_typecheck_test" % name

Expand Down

0 comments on commit b1d987e

Please sign in to comment.