Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions bazel/extract_types.bzl
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo")
load("@aspect_rules_js//js:providers.bzl", "JsInfo")

def _extract_types_impl(ctx):
"""Implementation of the `extract_types` rule."""
depsets = []
types_files = []

for dep in ctx.attr.deps:
if DeclarationInfo in dep:
depsets.append(dep[DeclarationInfo].transitive_declarations)
if JsInfo in dep:
types_files.extend(dep[JsInfo].transitive_types.to_list())
types_files.extend(dep[JsInfo].types.to_list())

types = depset(transitive = depsets)
types = depset([file for file in types_files if file.short_path.startswith(ctx.label.package)])

return [
DefaultInfo(files = types),
Expand Down
35 changes: 0 additions & 35 deletions bazel/extract_types_rjs.bzl

This file was deleted.

32 changes: 7 additions & 25 deletions bazel/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test")
load("//bazel:defaults.bzl", "ts_library")
load("//bazel:extract_types.bzl", "extract_types")
load("//bazel:extract_js_module_output.bzl", "extract_js_module_output")

ts_library(
ts_project(
name = "transitive_lib",
testonly = True,
srcs = ["transitive_file.ts"],
declaration = True,
tsconfig = "//bazel:tsconfig",
)

ts_library(
ts_project(
name = "test_lib",
testonly = True,
srcs = ["fixture.ts"],
declaration = True,
tsconfig = "//bazel:tsconfig",
deps = [":transitive_lib"],
)

Expand All @@ -28,30 +31,9 @@ extract_types(
deps = [":test_lib"],
)

extract_js_module_output(
name = "extract_js_module_output_target",
testonly = True,
forward_linker_mappings = True,
include_declarations = True,
include_default_files = True,
include_external_npm_packages = True,
provider = "JSModuleInfo",
deps = [
":test_lib",
":text_fixture",
],
)

nodejs_test(
name = "extract_types_test",
data = [":extract_types_target"],
entry_point = "extract_types_test.js",
templated_args = ["$(rootpaths :extract_types_target)"],
)

nodejs_test(
name = "extract_js_module_test",
data = [":extract_js_module_output_target"],
entry_point = "extract_js_module_test.js",
templated_args = ["$(rootpaths :extract_js_module_output_target)"],
)
20 changes: 0 additions & 20 deletions bazel/test/extract_js_module_test.js

This file was deleted.

4 changes: 0 additions & 4 deletions bazel/test/extract_types_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ const assert = require('assert');
const typeRootpaths = process.argv.slice(2);

assert.deepStrictEqual(typeRootpaths, [
// TypeScript types transitively added to every `ts_library` target. This might be
// cleaned up in the future, but is captured in this test as it rarely should change.
'../npm/node_modules/typescript/lib/tsserverlibrary.d.ts',
'../npm/node_modules/typescript/lib/typescript.d.ts',
// Actual workspace-local `d.ts` files.
'bazel/test/fixture.d.ts',
'bazel/test/transitive_file.d.ts',
Expand Down
Loading