You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to type export a class. Doing so impacts how it can be used (it becomes impossible to access statics, use instanceof, extend it, etc) but this is not reflected in the API report.
Repro steps
reexport a class as a type only export.
For example, define a class:
exportclassFoo{}
then when reexporting it (for example in index.ts):
export{typeFoo}from"foo";
Expected result: API report somehow indicates that the class has only been type exported.
Actual result: No change in the API report from adding type to the export.
Since TypeScript does not provide a nice syntax for type only exporting a class inline, I think the best way for API Extractor to handle this might be to include a comment on the class saying it is type-only. Given the limitation (other bug linked below) supporting this in rollups, I think such a comment would be extra useful.
This is related to #3616 where this same approach results in incorrect rollups.
That thread implies the use-case for this pattern is hiding the constructor: while I also benefit from that, my use-case is preventing subclassing, and disallowing access to statics (which instanceof implicitly uses). I was a bit surprised that API extractor allows this, but I think its a useful feature.
The fact that it does not work correctly in rollups is unfortunate, however my project does not use API extractor rollups (due to them breaking nominal typing when used with multiple import paths) so that does not apply to us.
Standard questions
Please answer these questions to help us investigate your issue more quickly:
Summary
It is possible to
type
export a class. Doing so impacts how it can be used (it becomes impossible to access statics, use instanceof, extend it, etc) but this is not reflected in the API report.Repro steps
reexport a class as a type only export.
For example, define a class:
then when reexporting it (for example in index.ts):
Expected result: API report somehow indicates that the class has only been type exported.
Actual result: No change in the API report from adding
type
to the export.Details
This was encountered in microsoft/FluidFramework#21351
Since TypeScript does not provide a nice syntax for type only exporting a class inline, I think the best way for API Extractor to handle this might be to include a comment on the class saying it is type-only. Given the limitation (other bug linked below) supporting this in rollups, I think such a comment would be extra useful.
This is related to #3616 where this same approach results in incorrect rollups.
That thread implies the use-case for this pattern is hiding the constructor: while I also benefit from that, my use-case is preventing subclassing, and disallowing access to statics (which instanceof implicitly uses). I was a bit surprised that API extractor allows this, but I think its a useful feature.
The fact that it does not work correctly in rollups is unfortunate, however my project does not use API extractor rollups (due to them breaking nominal typing when used with multiple import paths) so that does not apply to us.
Standard questions
Please answer these questions to help us investigate your issue more quickly:
@microsoft/api-extractor
version?node -v
)?The text was updated successfully, but these errors were encountered: