Skip to content

Commit

Permalink
feat: validate tsconfig outDir vs ts_project(out_dir)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mivr authored Jan 7, 2025
1 parent c63fb54 commit 9700b5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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: ' +
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

0 comments on commit 9700b5e

Please sign in to comment.