aspect-build / aspect-build/rules_ts

ts_project doesn't seem to support JS sources

Open
#73 9 comments 2 reactions 0 assignees View on GitHub
documentation
Dominant language
Starlark
Stars
138
Forks
87
Avg merge
2d 8h
Merged PRs (30d)
3

Description

If I use a JS source and a custom transpiler with `ts_project` like this:

```
load("@aspect_rules_swc//swc:defs.bzl", "swc_transpiler")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
ts_project(
name = "src",
srcs = [
"index.js",
],
allow_js = True,
declaration = True,
transpiler = swc_transpiler,
tsconfig = "//:tsconfig",
)
```

The JS is excluded and the length of `js_outs` doesn't match the length of srcs resulting in an error:

```
Error in fail: ERROR: illegal state: transpile_srcs has length 1 but js_outs has length 0
```

If instead I use the default `tsc` then it's unhappy because it would overwrite the copied source file:

```
error TS5055: Cannot write file 'src/index.js' because it would overwrite input file.
```

If I then set out an `out_dir` to something like `"foo"` it throws an error saying that:

```
output 'src/foo/index.d.ts' was not created
```

From the above it's not clear how I should be using `ts_project` with JS source files. Am I holding it wrong?

Thanks!

Contributor guide

Open the contributing guide

Research direction

Start with ts_project in ts/defs.bzl and trace how allow_js, declaration, out_dir, js_outs, and a custom transpiler are handled for the shown index.js input. Reproduce the configurations using the provided tsconfig and swc_transpiler loads; done means JS sources work without the length mismatch, overwrite, or missing-output errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.