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

Regression in 0.25.3. Warning emitted when dealing with some union and intersection in function type assertions #2437

Closed
timotheeguerin opened this issue Nov 1, 2023 · 1 comment
Labels
bug Functionality does not match expectation

Comments

@timotheeguerin
Copy link

Search terms

Union, duplicate declaration, intersection

Expected Behavior

Using function assertion to mark some properties as not optional if the function returns true but that cause typedoc to emit warning since version 0.25.3. Reverting to 0.25.2 solves the issue.

I wouldn't expect a warning to be emitted here.

Actual Behavior

Warning about duplicate declaration with different docs.

[warning] prop has multiple declarations with a comment. An arbitrary comment will be used.
[info] The comments for prop are declared at:
        ./src/index.ts:2
        ./src/index.ts:2
[info] The comments for prop are declared at:
        ./src/index.ts:2
        ./src/index.ts:2
        ./src/index.ts:2
        ./src/index.ts:2
error Command failed with exit code 3.

Steps to reproduce the bug

export interface TemplatedTypeBase {
  /**
   * Doc here
   */
  prop?: string[];
}

export interface One extends TemplatedTypeBase {}

export interface Two extends TemplatedTypeBase {}

export type Type = One | Two;

// errors
export function isTemplateInstance(
  type: Type
): type is Type & { prop: string[] } {
  return true;
}

// also error
export function isTemplateInstance2(
  type: Type
): type is Type & Required<TemplatedTypeBase> {
  return true;
}

// this works
export function isTemplateInstance3(
  type: Type
): type is Type & TemplatedTypeBase {
  return true;
}

Repro PR: TypeStrong/typedoc-repros#35

Environment

  • Typedoc version: 0.25.3
  • TypeScript version: 5.2
  • Node.js version: v18.17.1
  • OS: osx
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Nov 11, 2023

Someone finally found a reproduction for #2358!

This didn't cause a warning in 0.25.2 because TypeDoc just gave up when encountering type is Type & ... and converted that type as Object. In 0.25.3, this is properly converted (but still not properly rendered, which is weird is properly rendered if I'd run the right build of the tool...)

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