Skip to content

Commit

Permalink
feat(typescript): add OutputGroupInfo to ts_project with type definit…
Browse files Browse the repository at this point in the history
…ions

fix bazel-contrib#1978
  • Loading branch information
Long Ho committed Jul 1, 2020
1 parent c1d4885 commit d4fa8a7
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/typescript/internal/ts_project.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def _ts_project_impl(ctx):
# Improves error messaging if a ts_project needs declaration = True
if len(typings_outputs) or len(ctx.attr.deps):
providers.append(declaration_info(depset(typings_outputs), ctx.attr.deps))
providers.append(OutputGroupInfo(types = depset(typings_outputs)))

return providers

Expand Down
23 changes: 23 additions & 0 deletions packages/typescript/test/ts_project/output_group/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
load("//packages/typescript:index.bzl", "ts_project")

# This uses defaults for all attributes.
# It will find `index.ts` and produce `index.js`
ts_project(
name = "tsconfig",
srcs = ["index.ts"],
declaration = True,
)

filegroup(
name = "types",
srcs = [":tsconfig"],
output_group = "types",
)

generated_file_test(
name = "test",
src = "index.golden.d.ts",
# Refers to the output from ts_project above
generated = ":types",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const a: string;
1 change: 1 addition & 0 deletions packages/typescript/test/ts_project/output_group/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const a: string = 'hello';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"types": [],
"declaration": true
}
}

0 comments on commit d4fa8a7

Please sign in to comment.