Cannot privately inherit a non-exported class from a different file
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 267
- Avg merge
- 1d 25m
- Merged PRs (30d)
- 14
Description
### Describe the bug
The issue is that:
```ts
class Private { }
export class Public extends Private { }
```
Is allowed, while:
```ts
// private.ts
export class Private { }
// index.ts
import { Private } from './private';
export class Public extends Private { }
```
Is not.
I've been told the workaround is to tag the private type with `@internal`, but the current error message looks like:
```
lib/gen/private/webaclgen.generated.ts:71:1 - error JSII9002: Unable to resolve type "@aws-cdk/aws-wafv2.WebAclGen". It may be @internal or not exported from the module's entry point (as configured in "package.json" as "main").
71 export class WebAclGen extends Resource implements IWebAcl {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
72 public static fromWebAclAttributes(scope: Construct, id: string, attrs: WebAclAttributes): IWebAcl {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
116 }
~~~
117 }
~
```
Which seems to imply that `@internal` is a Bad Thing and should be avoided.
### Expected Behavior
See above.
### Current Behavior
See above.
### Reproduction Steps
See above.
### 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 reproducing the two TypeScript inheritance examples and inspect the diagnostic reported at lib/gen/private/webaclgen.generated.ts:71, along with the package.json main entry point mentioned in the error. Trace how cross-file non-exported classes and @internal types are classified; done means the examples receive consistent, accurate handling and the diagnostic clearly explains the supported workaround.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100