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

[Bug]: typescript 5.5.2 cannot find input files with source tsconfig.json #644

Open
gzm0 opened this issue Jun 26, 2024 · 8 comments
Open
Labels
bug Something isn't working

Comments

@gzm0
Copy link
Contributor

gzm0 commented Jun 26, 2024

What happened?

Minimal reproducible example below.

With TS 5.5.2, sources cannot be found:

bazel build //...
INFO: Analyzed target //:test (91 packages loaded, 2863 targets configured).
WARNING: /home/tos/.cache/bazel/_bazel_tos/287294dcdaea82c1370bff9bd5064654/external/aspect_rules_ts~~ext~npm_typescript/BUILD.bazel:32:17: input 'package' of @@aspect_rules_ts~~ext~npm_typescript//:.aspect_rules_js/node_modules/typescript is a directory; dependency checking of directories is unsound
ERROR: /home/tos/dh/personal/hack/tsc/BUILD.bazel:3:11: Transpiling TypeScript project @@//:test [tsc -p tsconfig.json] failed: (Exit 2): tsc.sh failed: error executing TsProject command (from target //:test) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/aspect_rules_ts~~ext~npm_typescript/tsc.sh --skipLibCheck --project tsconfig.json --outDir . --rootDir .

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
error TS18003: No inputs were found in config file '/home/tos/.cache/bazel/_bazel_tos/287294dcdaea82c1370bff9bd5064654/sandbox/linux-sandbox/984/execroot/_main/bazel-out/k8-fastbuild/bin/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["/home/tos/.cache/bazel/_bazel_tos/287294dcdaea82c1370bff9bd5064654/sandbox/linux-sandbox/984/execroot/_main/bazel-out/k8-fastbuild/bin"]'.
Target //:test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.016s, Critical Path: 0.30s
INFO: 4 processes: 3 internal, 1 local.
ERROR: Build did NOT complete successfully

When downgrading to 5.4.5:

bazel build //...
INFO: Analyzed target //:test (90 packages loaded, 2863 targets configured).
WARNING: /home/tos/.cache/bazel/_bazel_tos/287294dcdaea82c1370bff9bd5064654/external/aspect_rules_ts~~ext~npm_typescript/BUILD.bazel:32:17: input 'package' of @@aspect_rules_ts~~ext~npm_typescript//:.aspect_rules_js/node_modules/typescript is a directory; dependency checking of directories is unsound
INFO: Found 1 target...
Target //:test up-to-date:
  bazel-bin/test.js
INFO: Elapsed time: 0.931s, Critical Path: 0.14s
INFO: 2 processes: 1 internal, 1 local.
INFO: Build completed successfully, 2 total actions

Version

Development (host) and target OS/architectures:

Output of bazel --version:

bazel --version
bazel 7.2.1

Version of the Aspect rules, or other relevant rules from your
WORKSPACE or MODULE.bazel file:

bazel_dep(name = "aspect_rules_ts", version = "2.4.2")

rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)

rules_ts_ext.deps(
    # TS 5.5.2, broken:
    ts_version="5.5.2",
    ts_integrity="sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew=="
    # TS 5.4.5, works:
    #ts_version="5.4.5",
    #ts_integrity="sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ=="
)

use_repo(rules_ts_ext, "npm_typescript")

Language(s) and/or frameworks involved:

None

How to reproduce

MODULE.bazel from above.

BUILD.bazel:

load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

ts_project(
    name = "test",
    srcs = ["test.ts"],
)

tsconfig.json

{}

.bazelrc

common --@aspect_rules_ts//ts:skipLibCheck=always
common --@aspect_rules_ts//ts:default_to_tsc_transpiler

test.ts

console.log("foo");

Then run bazel build //:test

Any other information?

The tsconfig.json must be a source file.

If you do (and optionally delete tsconfig.json), the issue vanishes.

 ts_project(
     name = "test",
     srcs = ["test.ts"],
+    tsconfig = {},
 )
@gzm0 gzm0 added the bug Something isn't working label Jun 26, 2024
@gzm0
Copy link
Contributor Author

gzm0 commented Jun 26, 2024

Further investigation shows that the difference between a source tsconfig.json and a generated tsconfig.json is the files parameter. If I add it to tsconfig.json ({ "files": ["test.ts"] }), everything compiles again.

@gzm0
Copy link
Contributor Author

gzm0 commented Jun 26, 2024

My gut tells me that microsoft/TypeScript#58042 could have changed how relative paths with symlinks are resolved but I cannot find any evidence of that.

I'm currently double-checking that I cannot reproduce this issue without rules_ts.

@gzm0
Copy link
Contributor Author

gzm0 commented Jun 26, 2024

I have double checked that when running bare typescript (npx tsc), the error does not occur.

@gzm0
Copy link
Contributor Author

gzm0 commented Jun 26, 2024

Specifying exclude: [] fixes the issue. It looks like typescript 5.5 adds the outDir passed via command line to exclude.

typescript 5.4 doesn't do that as can be shown experimentally (by setting a bogus include pattern):

TS 5.4:

error TS18003: No inputs were found in config file '/home/tos/.cache/bazel/_bazel_tos/287294dcdaea82c1370bff9bd5064654/sandbox/linux-sandbox/1051/execroot/_main/bazel-out/k8-fastbuild/bin/src/tsconfig.json'. Specified 'include' paths were '["**/*.tsx"]' and 'exclude' paths were '[]'.

TS 5.5 (note the differently reported exclude pattern):

error TS18003: No inputs were found in config file '/home/tos/.cache/bazel/_bazel_tos/287294dcdaea82c1370bff9bd5064654/sandbox/linux-sandbox/1054/execroot/_main/bazel-out/k8-fastbuild/bin/src/tsconfig.json'. Specified 'include' paths were '["**/*.tsx"]' and 'exclude' paths were '["/home/tos/.cache/bazel/_bazel_tos/287294dcdaea82c1370bff9bd5064654/sandbox/linux-sandbox/1054/execroot/_main/bazel-out/k8-fastbuild/bin/src"]'.

So a workaround is to override exclude manually.

@alexeagle
Copy link
Member

I filed this upstream: microsoft/TypeScript#59036

@gzm0
Copy link
Contributor Author

gzm0 commented Jun 27, 2024

TY @alexeagle. Please LMK if there is anything I can help.

For discoverability:

workaround

add exclude: [] to your tsconfig.json.

@alexeagle
Copy link
Member

I'll adopt that workaround to land the new version mirroring: #643

We'll see if there's progress from TS team, if not then I'll have to detect the error message and print the workaround :(

@alexeagle
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants