TypeStrong / typedoc

Documentation generator for TypeScript projects.
https://typedoc.org
Apache License 2.0
7.67k stars 692 forks source link

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

Closed NkemdiAnyiam closed 2 weeks ago

NkemdiAnyiam commented 2 weeks ago

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

Gerrit0 commented 2 weeks ago

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