Skip to content

Error elaboration says nothing due to circularity #54921

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

Open
andrewbranch opened this issue Jul 7, 2023 · 0 comments
Open

Error elaboration says nothing due to circularity #54921

andrewbranch opened this issue Jul 7, 2023 · 0 comments
Labels
Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Milestone

Comments

@andrewbranch
Copy link
Member

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.

@RyanCavanaugh RyanCavanaugh added Suggestion An idea for TypeScript Help Wanted You can do this Experience Enhancement Noncontroversial enhancements labels Jul 10, 2023
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Experience Enhancement Noncontroversial enhancements Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants