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

feat: validate tsconfig outDir vs ts_project(out_dir) #730

Merged
merged 23 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c60761a
Add a failing test for tsconfig exclude validation
Mivr Nov 1, 2024
1d71c3f
Remove analysistime test as we are expecting a build time failure
Mivr Nov 4, 2024
eb00478
Add tsconfig validation for exclude option while using out_dir
Mivr Nov 4, 2024
1f9748d
Fix validator and examples
Mivr Nov 4, 2024
8a7e569
Remove TODO as validation is now added
Mivr Nov 4, 2024
4613d4e
Merge branch 'aspect-build:main' into main
Mivr Dec 3, 2024
44a0940
Revert not needed excludes in tests
Mivr Dec 3, 2024
afc1dad
Add check for declaration dir and root dir with exclude usage
Mivr Dec 3, 2024
541c5c1
Merge branch 'aspect-build:main' into main
Mivr Dec 9, 2024
a5c9575
MR comments
Mivr Dec 9, 2024
337fbff
Add out_dir attribute validation
Mivr Dec 9, 2024
17297a5
Add a bats test for validation
Mivr Dec 16, 2024
bd07d75
Merge branch 'aspect-build:main' into main
Mivr Dec 22, 2024
3226a2f
Revert "Add out_dir attribute validation"
Mivr Jan 6, 2025
302bebb
Revert "Add a bats test for validation"
Mivr Jan 6, 2025
6794228
Revert not needed changes, add only out_dir parameter validation
Mivr Jan 6, 2025
74e52e7
Revert not needed exclude
Mivr Jan 6, 2025
d673bdb
Revert comment removed
Mivr Jan 6, 2025
3731be7
Make the check to only trigger when build will fail anyway
Mivr Jan 6, 2025
5bbadc2
Clean up the logic
Mivr Jan 6, 2025
a0a43f2
Merge branch 'aspect-build:main' into main
Mivr Jan 6, 2025
7bde70e
Use a new function to check the out_dir attr to avoid too complex logic
Mivr Jan 6, 2025
dd338bf
Revert not needed changes
Mivr Jan 6, 2025
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
14 changes: 14 additions & 0 deletions ts/private/ts_project_options_validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ function main(_a) {
}
}
}
function check_out_dir() {
var attr = 'out_dir'
var optionVal = getTsOption('outDir')
var attrIsFalsyOrUndefined = attrs[attr] === false || attrs[attr] === '' || attrs[attr] === undefined
if (attrIsFalsyOrUndefined && optionVal !== undefined) {
throw new Error(
'When outDir is set in the tsconfig it must also be set in the ts_project' +
' rule, so that the output directory is known to Bazel.'
)
}
}
var jsxEmit =
((_b = {}),
(_b[ts.JsxEmit.None] = 'none'),
Expand Down Expand Up @@ -163,6 +174,7 @@ function main(_a) {
check('declaration')
check('incremental')
check('tsBuildInfoFile', 'ts_build_info_file')
check_out_dir()
check_nocheck()
check_preserve_jsx()
if (failures.length > 0) {
Expand Down Expand Up @@ -201,6 +213,8 @@ function main(_a) {
attrs.declaration +
'\n// declaration_map: ' +
attrs.declaration_map +
'\n// out_dir: ' +
attrs.out_dir +
'\n// incremental: ' +
attrs.incremental +
'\n// source_map: ' +
jbedard marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
1 change: 1 addition & 0 deletions ts/private/ts_validate_options.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def _validate_action(ctx, tsconfig_inputs):
allow_js = ctx.attr.allow_js,
declaration = ctx.attr.declaration,
declaration_map = ctx.attr.declaration_map,
out_dir = ctx.attr.out_dir,
preserve_jsx = ctx.attr.preserve_jsx,
composite = ctx.attr.composite,
no_emit = ctx.attr.no_emit,
Expand Down
Loading