Skip to content

Commit

Permalink
update typecheck_only example
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedard committed Sep 5, 2024
1 parent 5e870be commit 428e74b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
25 changes: 11 additions & 14 deletions examples/typecheck_only/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
"""Only type-checks the input file, but does no transpilation or output any typings files.
As such, it cannot run as a Bazel action under `bazel build`, as Bazel will only run actions when
their outputs are requested.
Therefore this is a test target and should be run with `bazel test`.
Therefore type-checking is done with a validation action within the `ts_project` rule.
"""

load("@npm//examples:typescript/package_json.bzl", "bin")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

bin.tsc_test(
ts_project(
name = "typecheck_only",
args = [
"--noEmit",
"$(location check-me.ts)",
srcs = [
"check-me.ts",
"lib.js",
],
data = ["check-me.ts"],
# It should fail because we made a typing mistake
# TypeScript ReturnCode:
# OutputGeneratedWithErrors = 2, // .js and .map generated with semantic errors
expected_exit_code = 2,
tsconfig = {
"compilerOptions": {
"noEmit": True,
},
},
)
3 changes: 2 additions & 1 deletion examples/typecheck_only/check-me.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
const a: number = 'a-string'
// Ensure importing from .js works
export * from './lib'
1 change: 1 addition & 0 deletions examples/typecheck_only/lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const a = 42

0 comments on commit 428e74b

Please sign in to comment.