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
Regression in advanced nested types in TS 3.2 #29168
Error since TS 3.2. The exact error varies from one variable to another, but it seems that when there is nesting, TS infers the first property correctly (let's say it's TestString), but fails on the next ones because it checks with the same inference as the first property (TestString), while it could be another one (TestObject).
properties of a JSON schema can be another JSON Schema, so it can be nested ;
{ [k: string]: any; } is added because the lib doesn't support all the features of the JSON schema standard, and I want the lib to allow standard JSON schemas without breaking.
I'm afraid that I don't know the exact feature that caused the regression, but I think the problem is that the string literal inference is being lost, probably due to the intersection with { [k: string]: any; }. For example, this works:
I'm surprised by the releases management of TypeScript. If there is a regression, shouldn't a patch be planned even it was not planned before?
Because what is told here, in the real world, means that: people using Angular and the lib mentioned (which is a quite used one) will update to Angular 7.2 soon, which will also update to TypeScript 3.2 through the Angular CLI, and then the compilation of their apps will break... And they won't be able to update to TypeScript 3.3 as it will need some time for Angular to support it (and it's not even released...).
I mean, if we end up putting a patch release we'd consider having the fix in it should it be ready, but we don't generally cut patch releases for old versions of TS once the new version is out (and 3.3 is probably sometime in the next two or three weeks). The effort required to port a change to all the possible versions (and then test it) makes it pretty infeasible for us to keep maintaining older minor releases.
We usually decide depending on the proximity of the next release, the effort, and the impact of the issue. I've been pretty liberal on porting high-impact fixes over.
Activity
jack-williams commentedon Dec 27, 2018
I'm afraid that I don't know the exact feature that caused the regression, but I think the problem is that the string literal inference is being lost, probably due to the intersection with
{ [k: string]: any; }. For example, this works:Think I tracked the new behaviour to this PR #27849.
PR up at #29174.
cyrilletuzi commentedon Dec 27, 2018
Yes it works if nested types are casted:
cyrilletuzi commentedon Dec 28, 2018
Wesley Wigham (@weswigham) As this is a regression, shouldn't this be planned as a patch update to TS 3.2?
weswigham commentedon Dec 28, 2018
AFAIK we don't have another patch release planned before 3.3, but I could be wrong.
cyrilletuzi commentedon Jan 2, 2019
I'm surprised by the releases management of TypeScript. If there is a regression, shouldn't a patch be planned even it was not planned before?
Because what is told here, in the real world, means that: people using Angular and the lib mentioned (which is a quite used one) will update to Angular 7.2 soon, which will also update to TypeScript 3.2 through the Angular CLI, and then the compilation of their apps will break... And they won't be able to update to TypeScript 3.3 as it will need some time for Angular to support it (and it's not even released...).
weswigham commentedon Jan 2, 2019
I mean, if we end up putting a patch release we'd consider having the fix in it should it be ready, but we don't generally cut patch releases for old versions of TS once the new version is out (and 3.3 is probably sometime in the next two or three weeks). The effort required to port a change to all the possible versions (and then test it) makes it pretty infeasible for us to keep maintaining older minor releases.
Daniel Rosenwasser (@DanielRosenwasser) would know more about our release plans.
DanielRosenwasser commentedon Jan 10, 2019
We usually decide depending on the proximity of the next release, the effort, and the impact of the issue. I've been pretty liberal on porting high-impact fixes over.
Add regression test for #29168
cyrilletuzi commentedon Feb 4, 2019
Closing, as it seems to be fixed by #29478.