Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not declare _typecheck[_test] target when using tsc as transpiler #721

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading