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

Missing whitespace in type parameters (beta) #2882

Closed
pjeby opened this issue Mar 1, 2025 · 6 comments
Closed

Missing whitespace in type parameters (beta) #2882

pjeby opened this issue Mar 1, 2025 · 6 comments
Milestone

Comments

@pjeby
Copy link
Contributor

pjeby commented Mar 1, 2025

Search terms

type parameters, whitespace, spacing

Expected Behavior

There should be spaces in type parameter declarations

Actual Behavior

They were removed from src/lib/output/themes/default/partials/typeParameters.tsx in cfef3d7, causing type parameters to glomp together with their extends, making the result unreadable.

Steps to reproduce the bug

Document something with a type parameter with an extends

Environment

  • Typedoc version: 0.28 beta
  • TypeScript version: 5.2.2
  • Node.js version: 18.20.2
  • OS: Windows
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 1, 2025

Well that's unfortunate, switching formatters shouldn't have resulted in different generated output... didn't think I needed to test rendering for that change.

Gerrit0 added a commit that referenced this issue Mar 1, 2025
@Gerrit0 Gerrit0 added this to the v0.28.0 milestone Mar 1, 2025
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 1, 2025

I ran master/beta through a visual regression after that change and it seems to be matching now (ignoring the rendering artifacts that always show up as differences for some reason)

@Gerrit0 Gerrit0 closed this as completed Mar 1, 2025
Gerrit0 added a commit that referenced this issue Mar 3, 2025
This should hopefully help avoid issues like #2882 creeping in
while also remaining small enough that it isn't a pain to maintain.
@pjeby
Copy link
Contributor Author

pjeby commented Mar 4, 2025

There are more places this is happening - various tsd-signature-symbol renders are missing critical whitespace in src/lib/output/themes/default/partials/typeDetails.tsx.

I wouldn't be surprised if there are other lurkers of this type. (This one showed up for me when something rendered as a variable with methods -- the methods were listed as name:function, which is a little weird because when rendered as a function instead of a variable those properties show as methods rather than properties of type function.)

@phoneticallySAARTHaK
Copy link

phoneticallySAARTHaK commented Mar 5, 2025

I have only seen it in typeDetails file. Noticing the pattern, \S <\/ this regex lists the affected lines in cfef3d7^, though it may not be exhaustive.

...

14 results - 4 files

src/lib/output/themes/lib.tsx:
  111                      <>
  112:                         {item.flags.isConst && const }
  113                          {item.varianceModifier ? `${item.varianceModifier} ` : ""}

  133                          <>
  134:                              extends 
  135                              {context.type(item.type)}

src/lib/output/themes/default/partials/typeDetails.tsx:
  276                          {context.reflectionFlags(child.getSignature)}
  277:                         get 
  278                          {child.name}
  279                          {anchorLinkIfPresent(context, child)}
  280:                         (): 
  281                          {context.type(child.getSignature.type)}

  290                          {context.reflectionFlags(child.setSignature)}
  291:                         set 
  292                          {child.name}

  297                                  {item.name}
  298:                                 : 
  299                                  {context.type(item.type)}

  301                          ))}
  302:                         ): 
  303                          {context.type(child.setSignature.type)}

  316              
317: {index.flags.isReadonly && readonly } 318 [ src/lib/output/themes/default/partials/typeParameters.tsx: 15 {anchorLinkIfPresent(context, item)} 16: {item.flags.isConst && const } 17 {item.varianceModifier && ( 18: {item.varianceModifier} 19 )} 22 <> 23: extends 24 {context.type(item.type)} src/lib/output/themes/default/templates/reflection.tsx: 37 38: {hasTypeParameters(props.model) && <> {context.typeParameters(props.model.typeParameters)} } 39 {props.model instanceof DeclarationReflection && ( 86
87: {index.flags.isReadonly && readonly } 88 [ 93 ))} 94: ]: 95 {context.type(index.type)}

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 5, 2025

Turns out there is a dprint bug for this: dprint/dprint-plugin-typescript#476

@Gerrit0 Gerrit0 reopened this Mar 6, 2025
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 9, 2025

rg '[^ ] <[/a-z]|[a-z]> [^ ]' -g '*.tsx' found a few additional cases to review, as dprint incorrectly removes whitespace at the start as well.

Gerrit0 added a commit that referenced this issue Mar 9, 2025
@Gerrit0 Gerrit0 closed this as completed Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants