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

Incorrect placement of default values when function not using the this parameter satisfies an interface that DOES use the this parameter #2698

Closed
NkemdiAnyiam opened this issue Sep 5, 2024 · 1 comment
Labels
bug Functionality does not match expectation

Comments

@NkemdiAnyiam
Copy link

NkemdiAnyiam commented Sep 5, 2024

Search terms

this, default value, satisfies

Expected Behavior

Given:

Example code for the above:

type Square = {
  color: 'red' | 'blue' | 'green';
};

type TAnimator = {
  (this: Square, numSpins: number, direction: 'clockwise' | 'counterclockwise'): string;
}

export const animator = function(numSpins: number = 2, direction: 'clockwise' | 'counterclockwise' = 'counterclockwise') {
  console.log(this.color, numSpins, direction);
  return 'Hello World';
} satisfies TAnimator;

animator.call({color: 'blue'}, 77);

The rendered documentation for the function should display the default values with the correct parameters like this (note that this image was produced by modifying my code to mimic the desired output):
image

Actual Behavior

The rendered documentation offsets the default values, starting by assigning the first default value to this:
image

Steps to reproduce the bug

Use the provided example code and generate the output. The typedoc.json configuration makes zero difference.

Environment

  • Typedoc version: 0.26.6
  • TypeScript version: 5.5.3
  • Node.js version: 20.16.0
  • OS: Windows 11
@NkemdiAnyiam NkemdiAnyiam added the bug Functionality does not match expectation label Sep 5, 2024
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Sep 6, 2024

Wow, that's a weird one... not entirely surprising as I had to do unfortunate hackery to make this parameters show up at all...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

2 participants