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
{{ message }}
Repository navigation
Repeated mapped type inference causes incorrect typeToString results #23897
class Foo<A> {
a: A;
}
class ObjectFoo<A> extends Foo<A> {
constructor(private b: { [k in keyof A]: Foo<A[k]> }) {
super();
}
}
const a = new ObjectFoo({ b: new Foo<string>() });
const obj = new ObjectFoo({ a });
Nathan Shively-Sanders (@sandersn) didn't we explcitly limit reverse mapped type output to one level deep for lack of a better method of stopping infinite recursion? Is this potentially related?
This is a pretty big deal breaker for my validator library 😢 https://github.com/Jomik/cerberus
Is it not possible to either display more layers, 9 or so. Or detect recursion and display that rather than "any"?
In my case of a recursive type exhibiting this error (#25860), sounds like displaying it with some kind of ellipsis or placeholder type would be nicer than just dropping down to any—that's a misleading type, given that it actually removes information from the display of the type. Not sure what concerns there would be though since I don't know how these serialized types ultimately get used, but in the case of VSCode type display the current behavior isn't great.
Ellipsis isn't great, in my opinion, unless some kind of "truncate" flag was enabled or something.
Having the type hidden in ellipsis slows down a developer when they have to figure out what's in the ellipsis. (TS 3.0 seems to do that for types that are too long at the moment and it slows me down quite a bit when having to figure out what's truncated)
Displaying the detected recursive type (without expansion) would be much better than any or ..., for generic types that have not had concrete types substituted in the parameters.
However, if it can somehow deduce that there's no infinite recursion, or that it stops at a reasonable depth, when a concrete type has been substituted in, it should just display the full type.
declarefunctionschema<T>(value : T) : ({field : T});//Should be { field : { field : boolean }}//But is { field : any }constx=schema(schema(true));//No matter how many times I call schema<>(),//It should show the full type//because it isn't an infinitely recursive type.//In this case, it's just 4 levels deepconsty=schema(schema(schema(schema(true))));
Edit: Looks like my issue is related to this one, #26228
As for ellipsis not being great (in my opinion), #26238
Activity
RyanCavanaugh commentedon Jun 28, 2018
Better repro from #25295
weswigham commentedon Jun 28, 2018
Nathan Shively-Sanders (@sandersn) didn't we explcitly limit reverse mapped type output to one level deep for lack of a better method of stopping infinite recursion? Is this potentially related?
Jomik commentedon Jun 29, 2018
This is a pretty big deal breaker for my validator library 😢 https://github.com/Jomik/cerberus
Is it not possible to either display more layers, 9 or so. Or detect recursion and display that rather than "any"?
osdiab commentedon Jul 22, 2018
In my case of a recursive type exhibiting this error (#25860), sounds like displaying it with some kind of ellipsis or placeholder type would be nicer than just dropping down to
any—that's a misleading type, given that it actually removes information from the display of the type. Not sure what concerns there would be though since I don't know how these serialized types ultimately get used, but in the case of VSCode type display the current behavior isn't great.AnyhowStep commentedon Aug 21, 2018
Ellipsis isn't great, in my opinion, unless some kind of "truncate" flag was enabled or something.
Having the type hidden in ellipsis slows down a developer when they have to figure out what's in the ellipsis. (TS 3.0 seems to do that for types that are too long at the moment and it slows me down quite a bit when having to figure out what's truncated)
Displaying the detected recursive type (without expansion) would be much better than
anyor..., for generic types that have not had concrete types substituted in the parameters.I think TS already does this,
However, if it can somehow deduce that there's no infinite recursion, or that it stops at a reasonable depth, when a concrete type has been substituted in, it should just display the full type.
Edit: Looks like my issue is related to this one, #26228
As for ellipsis not being great (in my opinion), #26238
KaelWD commentedon Sep 1, 2018
I seem to be getting the opposite of this. VSCode shows what I expect the type to be, but tsc thinks it's



neverI'll try to get a simple repro together,
VExpansionPanelContentInstanceis a Vue component with some circular references.codeaid commentedon Sep 28, 2018
Same here. Here's some code to give a rough idea of what I have going on (not tested):
At this point
Stateis showing as3 remaining items
weswigham commentedon Nov 13, 2018
Oooo GitHub not picking up on the word "doesn't" before "fix". 🌞
RyanCavanaugh commentedon Dec 3, 2025
Closing language service bugs related to the 6.0 implementation. For more information, see #62827