Java: union of arrays produces a compilation failure
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 267
- Avg merge
- 1d 25m
- Merged PRs (30d)
- 14
Description
### Describe the bug
The following:
```ts
export type X = A[] | B[] | C;
```
Fails to compile in Java, because type erasure turns this into 2 arrays.
The following does work:
```ts
export type X = (A | B)[] | C;
```
jsii-compiler should reject the former.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Expected Behavior
If it passes the compiler it shouldn't fail packaging.
### Current Behavior
The opposite.
### Reproduction Steps
SEe description.
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### SDK version used
-
### Environment details (OS name and version, etc.)
-
Contributor guide
Research direction
Start by tracing the jsii-compiler validation path for exported union types and reproduce the two TypeScript declarations through Java packaging. Compare the accepted union-of-arrays case with the working parenthesized form, then add coverage showing that the former is rejected before packaging. Done means the compiler reports the invalid Java-erasure case clearly and the valid form still packages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100