Skip to content

Commit bbcfcdd

Browse files
committed
fix(typescript): include transitive_declarations
These were missing from node_module_library and break downstream ts_library which should include them in files[] Fixes bazelbuild/rules_typescript#381
1 parent c8e61c5 commit bbcfcdd

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

internal/npm_install/node_module_library.bzl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,19 @@ def _node_module_library_impl(ctx):
2929
# use in rules such as ts_devserver
3030
scripts = depset(ctx.files.scripts)
3131

32-
# declarations are a subset of sources that are decleration files
33-
declarations = depset([f for f in ctx.files.srcs if f.path.endswith(".d.ts")])
32+
# declarations are a subset of sources that are declaration files
33+
declarations = depset([
34+
f
35+
for f in ctx.files.srcs
36+
if f.path.endswith(".d.ts") and
37+
# exclude eg. external/npm/node_modules/protobufjs/node_modules/@types/node/index.d.ts
38+
# these would be duplicates of the typings provided directly in another dependency
39+
len(f.path.split("/node_modules/")) < 3
40+
])
41+
42+
# transitive_declarations are all .d.ts files in srcs plus those in direct & transitive dependencies
43+
transitive_declarations = depset(transitive = [declarations])
3444

35-
# transitive_declarations are all direct & transitive decleration files
36-
transitive_declarations = depset()
37-
for src in ctx.attr.srcs:
38-
if hasattr(src, "typescript"):
39-
transitive_declarations = depset(transitive = [transitive_declarations, src.typescript.transitive_declarations])
4045
for dep in ctx.attr.deps:
4146
if hasattr(dep, "typescript"):
4247
transitive_declarations = depset(transitive = [transitive_declarations, dep.typescript.transitive_declarations])

packages/typescript/WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ rules_nodejs_dev_dependencies()
4040
# With http_archive it only sees releases/download/*.tar.gz urls
4141
git_repository(
4242
name = "build_bazel_rules_typescript",
43-
commit = "66505d1e39bc1be973ffbb1e3f83df4d7e1373ef",
43+
commit = "b1fa8ad9d15a4b46da800b33333512e538c69bd4",
4444
remote = "https://github.com/bazelbuild/rules_typescript.git",
4545
)
4646

0 commit comments

Comments
 (0)