Open benkaiser opened 5 years ago
Can you post the contents of the .d.ts file? Does the compiler actually emit your comment there?
Here is the .d.ts file that gets generated:
import * as React from 'react';
import Route from 'react-router/Route';
import { RouteProps, Route as _Route } from 'react-router';
/**
* Props for Base Route
*
* @internal
*/
export interface IBaseRouteProps extends RouteProps {
componentRenderedCallback?: (component: React.ReactNode) => void;
}
/**
* Extension of Route from react-router including componentCallback changes
*
* @internal
*/
export declare class BaseRoute extends Route<IBaseRouteProps> {
render(): React.ReactNode;
}
declare const _default: typeof _Route;
/**
* Cast export so it can be consumed correctly
*
* @internal
*/
export default _default;
@benkaiser what's happening is that API Extractor follows the various symbol aliases, looking for the original declaration:
export { default as _BaseRoute } from './BaseRoute';
export default _default;
declare const _default: typeof _Route;
It stops when it gets to (3), however this line is generated by the TypeScript compiler when it expands your line export default BaseRoute as any as typeof _Route;
from the source file. The compiler-generated line does not have a TSDoc comment; instead your docs are attached to the export default _default;
statement.
Ideally API Extractor should probably look for comments along the way, and use those if the original declaration does not have a comment.
However, as a workaround, you can simplify your declaration so that the compiler doesn't have to break it apart for you:
/**
* Cast export so it can be consumed correctly
*
* @internal
*/
const _default: typeof _Route = BaseRoute as any;
export default _default;
Ideally API Extractor should probably look for comments along the way, and use those if the original declaration does not have a comment.
However, there is a challenge that a declaration can be reached via different symbol alias chains (e.g. if BaseRoute
gets exported/imported using several different names). The first path that API Extractor traverses to reach the declaration may not be the one used by the package entry point. So this feature would need to keep track of how the symbol was reached, and only pick up TSDoc comments found along the "official" alias chain that actually gets exported.
Thanks @octogonz , that workaround worked perfectly!
Here is the example file (class bodies stripped for brevity):
Which results in generated documentation of: