Skip to content

No circularity error for self referential get accessor annotations #48031

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

Closed
DanielRosenwasser opened this issue Feb 25, 2022 · 2 comments · Fixed by #48050
Closed

No circularity error for self referential get accessor annotations #48031

DanielRosenwasser opened this issue Feb 25, 2022 · 2 comments · Fixed by #48050
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@DanielRosenwasser
Copy link
Member

declare class C {
    // TypeScript correctly reports an error here.
    foo: typeof this.foo;
    // TypeScript does not report an error here.
    get bar(): typeof this.bar;
}

Expected

An error on both foo and bar.

'foo' is referenced directly or indirectly in its own type annotation.
'bar' is referenced directly or indirectly in its own type annotation.

Actual

Just an error on bar.

'bar' is referenced directly or indirectly in its own type annotation.
@DanielRosenwasser DanielRosenwasser changed the title No circularity error for get accessors No circularity error for self referential get accessor annotations Feb 25, 2022
@fatcerberus
Copy link

The actual error(s) I'm seeing are rather weirder than this issue would suggest.

  • 'foo' is referenced directly or indirectly in its own type annotation.
  • 'bar' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
  • Public property 'foo' of exported class has or is using private name 'this'.
  • Return type of public getter 'bar' from exported class has or is using private name 'this'.

Playground

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Feb 26, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Feb 26, 2022
@RyanCavanaugh RyanCavanaugh added the Help Wanted You can do this label Feb 26, 2022
@fatcerberus
Copy link

I don't see the bug? The error on bar is slightly different from the one on foo, but both have self-referential type errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants