From 9d7827bb6815ec082d7758496925eb35eaceaad6 Mon Sep 17 00:00:00 2001 From: Brian Li Date: Tue, 12 Jan 2021 16:02:30 -0800 Subject: [PATCH] fix(typescript): capture js files in outputs of ts_project if allow_js --- packages/typescript/internal/ts_project.bzl | 2 +- packages/typescript/test/ts_project/allow_js/BUILD.bazel | 2 +- packages/typescript/test/ts_project/allow_js/verify.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/typescript/internal/ts_project.bzl b/packages/typescript/internal/ts_project.bzl index 60e1cca1f3..ee49db42da 100644 --- a/packages/typescript/internal/ts_project.bzl +++ b/packages/typescript/internal/ts_project.bzl @@ -669,7 +669,7 @@ def ts_project_macro( typing_maps_outs = [] if not emit_declaration_only: - js_outs.extend(_out_paths(srcs, out_dir, root_dir, False, ".js")) + js_outs.extend(_out_paths(srcs, out_dir, root_dir, allow_js, ".js")) if source_map and not emit_declaration_only: map_outs.extend(_out_paths(srcs, out_dir, root_dir, False, ".js.map")) if declaration or composite: diff --git a/packages/typescript/test/ts_project/allow_js/BUILD.bazel b/packages/typescript/test/ts_project/allow_js/BUILD.bazel index f70437b271..f182823665 100644 --- a/packages/typescript/test/ts_project/allow_js/BUILD.bazel +++ b/packages/typescript/test/ts_project/allow_js/BUILD.bazel @@ -1,7 +1,7 @@ load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test") load("//packages/typescript:index.bzl", "ts_project") -# Ensure that a.js produces outDir/a.js and outDir/a.d.ts +# Ensure that a.js produces outDir/a.js, outDir/a.d.ts, and outDir/a.d.ts.map SRCS = [ "a.js", ] diff --git a/packages/typescript/test/ts_project/allow_js/verify.js b/packages/typescript/test/ts_project/allow_js/verify.js index 6e1a196bca..32b419ff19 100644 --- a/packages/typescript/test/ts_project/allow_js/verify.js +++ b/packages/typescript/test/ts_project/allow_js/verify.js @@ -1,6 +1,7 @@ const assert = require('assert'); const types_files = process.argv.slice(2, 4); -const code_files = process.argv.slice(4, 6); +const code_file = process.argv[4]; assert.ok(types_files.some(f => f.endsWith('out/a.d.ts')), 'Missing a.d.ts'); assert.ok(types_files.some(f => f.endsWith('out/a.d.ts.map')), 'Missing a.d.ts.map'); +assert.ok(code_file.endsWith('out/a.js'), 'Missing a.js');