@@ -161,16 +161,7 @@ def _ts_project_impl(ctx):
161161 inputs .extend (depset (transitive = deps_depsets ).to_list ())
162162
163163 # Gather TsConfig info from both the direct (tsconfig) and indirect (extends) attribute
164- tsconfig_inputs = []
165- if TsConfigInfo in ctx .attr .tsconfig :
166- tsconfig_inputs .extend (ctx .attr .tsconfig [TsConfigInfo ].deps )
167- else :
168- tsconfig_inputs .append (ctx .file .tsconfig )
169- if hasattr (ctx .attr , "extends" ) and ctx .attr .extends :
170- if TsConfigInfo in ctx .attr .extends :
171- tsconfig_inputs .extend (ctx .attr .extends [TsConfigInfo ].deps )
172- else :
173- tsconfig_inputs .extend (ctx .attr .extends .files .to_list ())
164+ tsconfig_inputs = _tsconfig_inputs (ctx )
174165 inputs .extend (tsconfig_inputs )
175166
176167 # We do not try to predeclare json_outs, because their output locations generally conflict with their path in the source tree.
@@ -249,6 +240,20 @@ def _ts_project_impl(ctx):
249240
250241 return providers
251242
243+ def _tsconfig_inputs (ctx ):
244+ """Returns all transitively referenced tsconfig files from "tsconfig" and "extends" attributes."""
245+ inputs = []
246+ if TsConfigInfo in ctx .attr .tsconfig :
247+ inputs .extend (ctx .attr .tsconfig [TsConfigInfo ].deps )
248+ else :
249+ inputs .append (ctx .file .tsconfig )
250+ if hasattr (ctx .attr , "extends" ) and ctx .attr .extends :
251+ if TsConfigInfo in ctx .attr .extends :
252+ inputs .extend (ctx .attr .extends [TsConfigInfo ].deps )
253+ else :
254+ inputs .extend (ctx .attr .extends .files .to_list ())
255+ return inputs
256+
252257ts_project = rule (
253258 implementation = _ts_project_impl ,
254259 attrs = dict (_ATTRS , ** _OUTPUTS ),
@@ -271,11 +276,7 @@ def _validate_options_impl(ctx):
271276 ts_build_info_file = ctx .attr .ts_build_info_file ,
272277 ).to_json ()])
273278
274- inputs = ctx .files .extends [:]
275- if TsConfigInfo in ctx .attr .tsconfig :
276- inputs .extend (ctx .attr .tsconfig [TsConfigInfo ].deps )
277- else :
278- inputs .append (ctx .file .tsconfig )
279+ inputs = _tsconfig_inputs (ctx )
279280
280281 run_node (
281282 ctx ,
0 commit comments