[api-extractor] ae-forgotten-export for casted base class
Is this a feature or a bug?
- [ ] Feature
- [x] Bug
Please describe the actual behavior. Even when all involved types are exported, I get an ae-forgotten-export error when extending a casted base class.
If the issue is a bug, how can we reproduce it? Please provide detailed steps and include a GitHub branch if applicable. Your issue will get resolved faster if you can make it easy to investigate.
export interface IBase {}
export class Base implements IBase {}
export class Something extends (Base as new() => IBase) {}
This results in an error message: "(ae-forgotten-export) The symbol "Something_base" needs to be exported by the entry point index.d.ts" It looks like when I cast the base class to the interface, it doesn't know how to interpret the type.
What is the expected behavior? I'm not sure how it should extract necessarily (maybe that part could be considered a feature?), but at least I shouldn't get the error if all involved types are exported.
If this is a bug, please provide the tool version, Node.js version, and OS.
- Tool: api-extractor
- Tool Version: 7.4.2 and 7.3.8
- Node Version: 10.16.0
- Is this a LTS version? Yes
- Have you tested on a LTS version?
- OS: Windows 10
@iclanton @octogonz Does this look familiar?
Yes Something_base is a synthetic symbol emitted in the .d.ts file, but not part of the original code. API Extractor currently doesn't recognize this situation. We should improve that.
That said, /why/ design an API like this? :-) It is pretty strange.
Why is a fair question. In the example case, I didn't want to expose all public functionality of Base in Something, only the IBase members.
Why the restriction? - Base is useful on its own, and by casting it to IBase it can have additional TypeScript type restrictions added by limiting it to types from IBase. However, it's not the only solution to that problem.