Skip to content

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

Closed
@timotheeguerin

Description

@timotheeguerin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions