-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
Bug Report
Given (this is just the smaller repro I could come up with, not real code):
const p = <T>(fn: () => T): T => {return null as any}
const Base = <T>(val: T): {new(): T} => {
return null as any;
}
class C extends Base({
x: p<C[]>(() => [])
}) { }With TS 4.3.2 it gives the errors:
Type 'C' recursively references itself as a base type.ts(2310)
'C' is referenced directly or indirectly in its own base expression.ts(2506)
where as there's no such error with TS 4.2.4
If the p function parameter is changed from fn: () => T to fn: () => any or x: p<C[]>(() => []) is changed to x: p<C[]>(() => [] as any) then it does not give that error anymore.
Real impact:
This impacts a library that used to be able to do self-referenced models:
class TreeNode extends Model({ children: prop<TreeNode[]>(() => []), x: prop(0) }) {}but with the new version it is not possible anymore
Alternative repro:
abstract class Base2 {
abstract root() : Derived
}
class Derived extends class extends Base2 {
root() {
return undefined as any
}
}
{}🕗 Version & Regression Information
- This changed between versions 4.2.4 and 4.3.2
⏯ Playground Link
yseymour, xaviergonz, evelant, dsherret, colinhacks and 2 morexaviergonz, colinhacks, javiergonzalezGenially and vlazh
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue