diff --git a/examples/global_dts/BUILD.bazel b/examples/global_dts/BUILD.bazel new file mode 100644 index 00000000..6b8ef792 --- /dev/null +++ b/examples/global_dts/BUILD.bazel @@ -0,0 +1,13 @@ +load("@aspect_rules_ts//ts:defs.bzl", "ts_project") + +ts_project( + name = "lib", + srcs = [ + "global.d.ts", + "index.ts", + ], + tsconfig = { + "declaration": True, + }, + visibility = ["//examples:__subpackages__"], +) diff --git a/examples/global_dts/global.d.ts b/examples/global_dts/global.d.ts new file mode 100644 index 00000000..793acd22 --- /dev/null +++ b/examples/global_dts/global.d.ts @@ -0,0 +1 @@ +declare function myGlobalFunction(a: number): string diff --git a/examples/global_dts/index.ts b/examples/global_dts/index.ts new file mode 100644 index 00000000..5472e85a --- /dev/null +++ b/examples/global_dts/index.ts @@ -0,0 +1 @@ +myGlobalFunction(42) diff --git a/ts/private/ts_config.bzl b/ts/private/ts_config.bzl index 8f11914f..56eb47cf 100644 --- a/ts/private/ts_config.bzl +++ b/ts/private/ts_config.bzl @@ -37,7 +37,7 @@ def _ts_config_impl(ctx): include_transitive_sources = True, include_declarations = True, include_npm_linked_packages = True, - ) + ), ] for dep in ctx.attr.deps: @@ -74,7 +74,8 @@ def _filter_input_files(files, allow_js, resolve_json_module): return [ f for f in files - if _lib.is_ts_src(f.basename, allow_js) or _lib.is_json_src(f.basename, resolve_json_module) + # include typescript, json & declaration sources + if _lib.is_ts_src(f.basename, allow_js) or _lib.is_json_src(f.basename, resolve_json_module) or _lib.is_typings_src(f.basename) ] def _write_tsconfig_rule(ctx):