Skip to content

Commit 9700b5e

Browse files
authored
feat: validate tsconfig outDir vs ts_project(out_dir)
1 parent c63fb54 commit 9700b5e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

ts/private/ts_project_options_validator.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ function main(_a) {
102102
}
103103
}
104104
}
105+
function check_out_dir() {
106+
var attr = 'out_dir'
107+
var optionVal = getTsOption('outDir')
108+
var attrIsFalsyOrUndefined = attrs[attr] === false || attrs[attr] === '' || attrs[attr] === undefined
109+
if (attrIsFalsyOrUndefined && optionVal !== undefined) {
110+
throw new Error(
111+
'When outDir is set in the tsconfig it must also be set in the ts_project' +
112+
' rule, so that the output directory is known to Bazel.'
113+
)
114+
}
115+
}
105116
var jsxEmit =
106117
((_b = {}),
107118
(_b[ts.JsxEmit.None] = 'none'),
@@ -163,6 +174,7 @@ function main(_a) {
163174
check('declaration')
164175
check('incremental')
165176
check('tsBuildInfoFile', 'ts_build_info_file')
177+
check_out_dir()
166178
check_nocheck()
167179
check_preserve_jsx()
168180
if (failures.length > 0) {
@@ -201,6 +213,8 @@ function main(_a) {
201213
attrs.declaration +
202214
'\n// declaration_map: ' +
203215
attrs.declaration_map +
216+
'\n// out_dir: ' +
217+
attrs.out_dir +
204218
'\n// incremental: ' +
205219
attrs.incremental +
206220
'\n// source_map: ' +

ts/private/ts_validate_options.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def _validate_action(ctx, tsconfig_inputs):
2828
allow_js = ctx.attr.allow_js,
2929
declaration = ctx.attr.declaration,
3030
declaration_map = ctx.attr.declaration_map,
31+
out_dir = ctx.attr.out_dir,
3132
preserve_jsx = ctx.attr.preserve_jsx,
3233
composite = ctx.attr.composite,
3334
no_emit = ctx.attr.no_emit,

0 commit comments

Comments
 (0)