From a1311fcd061b09e494704c98cf375c44aac6c28e Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Fri, 9 Apr 2021 16:20:32 -0700 Subject: [PATCH] fix(typescript): output path for .json in root package Fixes #2598 --- packages/typescript/internal/ts_project.bzl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/typescript/internal/ts_project.bzl b/packages/typescript/internal/ts_project.bzl index b154f4e583..5bb20dec0f 100644 --- a/packages/typescript/internal/ts_project.bzl +++ b/packages/typescript/internal/ts_project.bzl @@ -170,8 +170,9 @@ def _ts_project_impl(ctx): # NB: We don't have emit_declaration_only setting here, so use presence of any JS outputs as an equivalent. # tsc will only produce .json if it also produces .js if len(ctx.outputs.js_outs): + pkg_len = len(ctx.label.package) + 1 if len(ctx.label.package) else 0 json_outs = [ - ctx.actions.declare_file(_join(ctx.attr.out_dir, src.short_path[len(ctx.label.package) + 1:])) + ctx.actions.declare_file(_join(ctx.attr.out_dir, src.short_path[pkg_len:])) for src in ctx.files.srcs if src.basename.endswith(".json") ]