generated from bazel-contrib/rules-template
-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support --noEmit for type-checking as a validation action
- Loading branch information
1 parent
ed84211
commit 652e569
Showing
13 changed files
with
182 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
load "common.bats" | ||
|
||
setup() { | ||
cd $BATS_FILE_TMPDIR | ||
} | ||
|
||
teardown() { | ||
bazel shutdown | ||
rm -rf $BATS_FILE_TMPDIR/* | ||
} | ||
|
||
|
||
@test 'When tsc is only used for type-checking with a type-error, should pass when validations are disabled' { | ||
workspace | ||
|
||
echo "export const a: string = 1;" > ./source.ts | ||
tsconfig --declaration | ||
ts_project --transpiler-mock --declaration --src "source.ts" | ||
|
||
run bazel build :foo --norun_validations | ||
assert_success | ||
run cat bazel-bin/source.js | ||
assert_success | ||
# Mock transpiler just copies source input to output | ||
assert_output -p 'export const a: string = 1;' | ||
} | ||
|
||
@test 'When tsc is only used for type-checking with a type-error, should fail when validations are enabled' { | ||
workspace | ||
|
||
echo "export const a: string = 1;" > ./source.ts | ||
tsconfig --no-emit | ||
ts_project --no-emit --src "source.ts" | ||
|
||
run bazel build :foo --run_validations | ||
assert_failure | ||
assert_output -p "error TS2322: Type 'number' is not assignable to type 'string'" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
load("@aspect_rules_ts//ts:defs.bzl", "ts_project") | ||
load("@bazel_skylib//rules:write_file.bzl", "write_file") | ||
|
||
write_file( | ||
name = "gen_ts", | ||
out = "a.ts", | ||
content = [ | ||
"export const a: number = 42", | ||
], | ||
) | ||
|
||
ts_project( | ||
name = "no-emit", | ||
srcs = ["a.ts"], | ||
no_emit = True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
// Workaround https://github.com/microsoft/TypeScript/issues/59036 | ||
"exclude": [], | ||
"compilerOptions": { | ||
"noEmit": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.