Skip to content

Error elaboration says nothing due to circularity #54921

Open
@andrewbranch

Description

@andrewbranch

Bug Report

⏯ Playground Link

Playground link with relevant code

💻 Code

// @target: esnext

export interface ReadonlySparseArray<T> {

    slice(start?: number, end?: number): SparseArray<T>;
  
    every<S extends T>(
        predicate: (value: T, index: number) => value is S,
    ): this is ReadonlySparseArray<S>;
  
    flatMap<U>(callback: (value: T, index: number) => U | readonly U[] | ReadonlySparseArray<U>): U[];
  }
  
export interface SparseArray<T> extends ReadonlySparseArray<T> {}

const _a: ReadonlySparseArray<string> = ['a'];
const _b: SparseArray<string> = ['a'];

🙁 Actual behavior

_b:

Type 'string[]' is not assignable to type 'SparseArray<string>'.
  Types of property 'slice' are incompatible.
    Type '(start?: number | undefined, end?: number | undefined) => string[]' is not assignable to type '(start?: number | undefined, end?: number | undefined) => SparseArray<string>'.ts(2322)

In trying to tell you why string[] is not assignable to SparseArray<string>, the elaboration references two signatures which are identical except for their return types: string[] and SparseArray<string>, which lands you right back where you started.

This particular example occurs in #50351, which is a separately buggy behavior, so this repro may stop reproing if that gets fixed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @andrewbranch@RyanCavanaugh

        Issue actions

          Error elaboration says nothing due to circularity · Issue #54921 · microsoft/TypeScript