Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@inline and @inlineType not usable with @typedef #2916

Closed
stwlam opened this issue Mar 23, 2025 · 2 comments
Closed

@inline and @inlineType not usable with @typedef #2916

stwlam opened this issue Mar 23, 2025 · 2 comments

Comments

@stwlam
Copy link

stwlam commented Mar 23, 2025

I wasn't sure whether to report this as a bug or feature request since @inline, etc. aren't explicitly marked as supporting @typedef. But since @typedefs are converted to type aliases or interfaces, it seems it should have worked out of the box.

Search terms

inline, expand, typedef

Expected Behavior

The @inline tag may be placed on type aliases and interfaces. When a type is annotated with @inline and the type is referenced, TypeDoc will attempt to inline the referenced type within the other type.

Actual Behavior

The referenced type and type definition itself fall back to any:

Image

Image

Steps to reproduce the bug

/**
 * @typedef HelloProps
 * @inline
 * @property {string} name Name property docs
 */

/**
 * Hello component - HelloProps will be inlined here as
 * if you had written `Hello(props: { name: string })`
 * @param {HelloProps} props
 */
export function hello(props) {
  return "Hello {props.name}!";
}

Moving the placement of @inline to above @typedef or below the @property has it get ignored entirely (perhaps expected).

Environment

  • Typedoc version: 0.28.1
  • TypeScript version: 5.6.3
  • Node.js version: 22.14.0
  • OS: Ubuntu 22.04.5
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 24, 2025

Switching to feature type -- @typedef, despite being converted as a type alias, takes an entirely different code path because it is special and doesn't follow the normal structure that TypeDoc relies on for type aliases. It should be relatively straightforward to add support for @inline.

I'd kind of expect @expand to work already as that tag is used when rendering, at which point TypeDoc has unified both typedef and type aliases into a common reflection structure...

@Gerrit0 Gerrit0 added help wanted Contributions are especially encouraged good first issue Easier issue for first time contributors labels Mar 24, 2025
@Gerrit0 Gerrit0 added the js This issue relates to better TS-in-JS support label Apr 7, 2025
@Gerrit0 Gerrit0 changed the title @inline, @expand, etc. not usable with @typedef @inline, and @inlineType not usable with @typedef Apr 7, 2025
@Gerrit0 Gerrit0 changed the title @inline, and @inlineType not usable with @typedef @inline and @inlineType not usable with @typedef Apr 7, 2025
@Gerrit0 Gerrit0 added design-limitation and removed help wanted Contributions are especially encouraged good first issue Easier issue for first time contributors js This issue relates to better TS-in-JS support labels Apr 7, 2025
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 7, 2025

After further review, so far as I can tell there is absolutely no way for TypeDoc to support this with @inline because of a limitation of TypeScript's JSDoc parser. It does not support additional tags within the description of a typedef alias.

TypeDoc respects TypeScript's rules for how to parse typedef comments, and there is no place in which @inline can be placed in the typedef comment where TypeScript considers it to be a part of the typedef comment.

(after typedef -- ends parse of @typedef, so TypeDoc's any was correct)
Image

(after properties -- not a part of the typedef declaration, TS allows multiple typedefs in a single comment)
Image

(before typedef -- not a part of the typedef declaration, ditto)
Image


You can, however, use @inlineType HelloProps in the comment for hello to inline the type.

Image

@Gerrit0 Gerrit0 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 7, 2025
Gerrit0 added a commit that referenced this issue Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants