Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(typescript): produce .d.ts as default output rather than empty #2117

Merged
merged 1 commit into from
Aug 17, 2020
Merged
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
9 changes: 5 additions & 4 deletions packages/typescript/internal/ts_project.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ def _ts_project_impl(ctx):
outputs = json_outs + ctx.outputs.js_outs + ctx.outputs.map_outs + ctx.outputs.typings_outs + ctx.outputs.typing_maps_outs
if ctx.outputs.buildinfo_out:
outputs.append(ctx.outputs.buildinfo_out)
runtime_outputs = depset(json_outs + ctx.outputs.js_outs + ctx.outputs.map_outs)
runtime_outputs = json_outs + ctx.outputs.js_outs + ctx.outputs.map_outs
typings_outputs = ctx.outputs.typings_outs + ctx.outputs.typing_maps_outs + [s for s in ctx.files.srcs if s.path.endswith(".d.ts")]
default_outputs_depset = depset(runtime_outputs) if len(runtime_outputs) else depset(typings_outputs)

if len(outputs) > 0:
run_node(
Expand All @@ -139,14 +140,14 @@ def _ts_project_impl(ctx):
# Only the JavaScript outputs are intended for use in non-TS-aware
# dependents.
DefaultInfo(
files = runtime_outputs,
files = default_outputs_depset,
runfiles = ctx.runfiles(
transitive_files = runtime_outputs,
transitive_files = default_outputs_depset,
collect_default = True,
),
),
js_module_info(
sources = runtime_outputs,
sources = depset(runtime_outputs),
deps = ctx.attr.deps,
),
_TsConfigInfo(tsconfigs = depset([ctx.file.tsconfig] + ctx.files.extends, transitive = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("@build_bazel_rules_nodejs//:index.bzl", "generated_file_test")
load("//packages/typescript:index.bzl", "ts_project")

ts_project(
declaration = True,
emit_declaration_only = True,
)

generated_file_test(
name = "test",
src = "a.d.ts_",
generated = ":tsconfig",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const a: string;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const a: string = '';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"types": []
}
}