Skip to content

Commit 6305db3

Browse files
Alex Eaglealexeagle
Alex Eagle
authored andcommitted
fix(typescript): don't include _valid_options marker file in outs
Tested by building //packages/angular:npm_package and don't get an extra .d.ts file in the package. Also tested the negative case by making an invalid option and check that it's still reported. Fixes #2078
1 parent e72c145 commit 6305db3

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

packages/typescript/internal/ts_project.bzl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo", "NpmPackage
44
load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "module_mappings_aspect")
55
load(":ts_config.bzl", "TsConfigInfo", "write_tsconfig")
66

7+
_ValidOptionsInfo = provider()
8+
79
_DEFAULT_TSC = (
810
# BEGIN-INTERNAL
911
"@npm" +
@@ -14,7 +16,14 @@ _DEFAULT_TSC = (
1416
_ATTRS = {
1517
"args": attr.string_list(),
1618
"declaration_dir": attr.string(),
17-
"deps": attr.label_list(providers = [DeclarationInfo], aspects = [module_mappings_aspect]),
19+
"deps": attr.label_list(
20+
providers = [
21+
# Provide one or the other of these
22+
[DeclarationInfo],
23+
[_ValidOptionsInfo],
24+
],
25+
aspects = [module_mappings_aspect],
26+
),
1827
"extends": attr.label_list(allow_files = [".json"]),
1928
"link_workspace_root": attr.bool(),
2029
"out_dir": attr.string(),
@@ -95,6 +104,7 @@ def _ts_project_impl(ctx):
95104
])
96105

97106
deps_depsets = []
107+
inputs = ctx.files.srcs[:]
98108
for dep in ctx.attr.deps:
99109
if TsConfigInfo in dep:
100110
deps_depsets.append(dep[TsConfigInfo].deps)
@@ -104,8 +114,10 @@ def _ts_project_impl(ctx):
104114
deps_depsets.append(dep[NpmPackageInfo].sources)
105115
if DeclarationInfo in dep:
106116
deps_depsets.append(dep[DeclarationInfo].transitive_declarations)
117+
if _ValidOptionsInfo in dep:
118+
inputs.append(dep[_ValidOptionsInfo].marker)
107119

108-
inputs = ctx.files.srcs + depset(transitive = deps_depsets).to_list()
120+
inputs.extend(depset(transitive = deps_depsets).to_list())
109121

110122
# Gather TsConfig info from both the direct (tsconfig) and indirect (extends) attribute
111123
if TsConfigInfo in ctx.attr.tsconfig:
@@ -224,9 +236,7 @@ def _validate_options_impl(ctx):
224236
executable = "validator",
225237
)
226238
return [
227-
DeclarationInfo(
228-
transitive_declarations = depset([marker]),
229-
),
239+
_ValidOptionsInfo(marker = marker),
230240
]
231241

232242
validate_options = rule(

0 commit comments

Comments
 (0)