You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error inheriting class B from class A that contains a method that takes a parameter of type B and returns this when decorated with multiple mixins
#42383
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.
I'm sorry for the long title but the issue is not easy to translate into words. Let me start a minimal code example.
typeConstructor<T={}>=new(...args: any[])=>T;classA{foo(b: B): this {returnthis;}}functionMixinA<TextendsConstructor<A>>(Base: T){returnclassMixinAextendsBase{};}functionMixinB<TextendsConstructor<A>>(Base: T){returnclassMixinBextendsBase{};}classBextendsMixinB(MixinA(A)){}// ERROR
The error that's being given is: Type 'B' recursively references itself as a base type
In my opinion this error doesn't make sense or am I mistaken? The error disappears when I
a) remove the use of class B from the foo method
b) remove the this return type from the foo method
c) Only decorate class A with 1 mixin. For some reason the error disappears when only one mixin is used.
d) change the required mixin constructor type to any: function MixinA<T extends Constructor<any>>(...) {...}
The first 2 options are not viable as they are incompatible with my use case and option d looses type safety within the mixin implementations.
🔎 Search Terms
mixins recursively references itself
🕗 Version & Regression Information
When testing in the playground it seems like this error occurred between versions 3.6.2 and 3.7.5
typeConstructor<T={}>=new(...args: any[])=>T;classA{foo(b: B): this {returnthis;}}functionMixinA<TextendsConstructor<A>>(Base: T){returnclassMixinAextendsBase{};}functionMixinB<TextendsConstructor<A>>(Base: T){returnclassMixinBextendsBase{};}classBextendsMixinB(MixinA(A)){}// ERROR
🙁 Actual behavior
Error Type 'B' recursively references itself as a base type. ts(2310)
🙂 Expected behavior
No error
The text was updated successfully, but these errors were encountered:
AlmostBearded
changed the title
Error inheriting class B from class A decorated with nested mixins and class A contains a method that takes parameter of type B and returns this
Error inheriting class B from class A that contains a method that takes parameter of type B and returns this when decorated with multiple mixins
Jan 17, 2021
AlmostBearded
changed the title
Error inheriting class B from class A that contains a method that takes parameter of type B and returns this when decorated with multiple mixins
Error inheriting class B from class A that contains a method that takes a parameter of type B and returns this when decorated with multiple mixins
Jan 17, 2021
Bug Report
I'm sorry for the long title but the issue is not easy to translate into words. Let me start a minimal code example.
The error that's being given is:
Type 'B' recursively references itself as a base type
In my opinion this error doesn't make sense or am I mistaken? The error disappears when I
a) remove the use of class B from the
foo
methodb) remove the
this
return type from thefoo
methodc) Only decorate class A with 1 mixin. For some reason the error disappears when only one mixin is used.
d) change the required mixin constructor type to
any
:function MixinA<T extends Constructor<any>>(...) {...}
The first 2 options are not viable as they are incompatible with my use case and option d looses type safety within the mixin implementations.
🔎 Search Terms
mixins recursively references itself
🕗 Version & Regression Information
When testing in the playground it seems like this error occurred between versions 3.6.2 and 3.7.5
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
Error
Type 'B' recursively references itself as a base type. ts(2310)
🙂 Expected behavior
No error
The text was updated successfully, but these errors were encountered: