More consistently backport type system fixes #38237
Labels
Declined
The issue was declined as something which matches the TypeScript vision
Suggestion
An idea for TypeScript
Search Terms
backport, fixes, type system
Suggestion
When a type system bug is introduced in version
X
, and later fixed in versionX+n
,the fix should be backported all the way to
X
(or at least a reasonable number of past releases).Use Cases
This feature request is mostly for library authors with source code in native TypeScript.
When a new version of TypeScript is released, library authors have to scramble to check that it doesn't break their .d.ts files (handwritten or tsc-generated). If it is broken, they have to somehow fix it so that it works on existing versions of TS, and also the new version.
Over time, the result is a lot of duplicated .d.ts files that may go out of sync, and are prone to mistakes.
Surprisingly, JS library authors will have an easier time with this problem, since they will probably already be writing their own .d.ts files and use
typesVersions
.Examples
Playground
Since the fix in 3.8.3 was not backported to 3.5.1, 3.6.3, 3.7.4, my options are the following,
Only support 3.3.3
This is bad because over time, the library will just become more and more irrelevant
Only support 3.8.3
This is bad because it alienates old users, or extra effort has to be put in to backport new features
Find a way to write the type such that it works on all versions of TS
This is bad because it is not always possible, or may require significant effort to shuffle types around.
And you also have to write compile-time (type-level) tests for each TS version you want to support, to make sure the fix works for all versions of TS.
Write a custom .d.ts file for 3.5.1, 3.6.3, 3.7.5 and use
typesVersions
This is bad because you now have to write one set of .d.ts per TS version.
Requires compile-time tests for each handwritten set of .d.ts files, and tsc-generated files.
Very error-prone.
Use
downlevel-dts
, hope it does not produce broken emit for older TS versions, and usetypesVersions
Also bad because "generate output that does not break on older releases due to introduced compiler bugs" is probably not a use case
downlevel-dts
was intended to solve.Generated output still needs to be fixed by humans.
Requires compile-time tests for each set of
downlevel-dts
.d.ts files, and tsc-generated files.Very error-prone.
In some cases, it's possible that an entire library becomes completely useless because type system fixes were not backported, and new bugs were introduced.
A
A
(not backported)B
The library is stuck on TS 3.3.3 because 3.5.1 has bug
A
, and 3.6.3 has bugB
.The library author has to somehow find a workaround for both bugs to support 3.5.1 and 3.6.3.
The problem gets worse as new versions are added.
I'm actually running into such a problem, at this point.
Exhibit A: Playground
Exhibit B: #38235
Bugs with each TS version,
So, I'm stuck on TS 3.3.3 because any later version gives me some kind of bug I have to work around.
In other cases, a project may find it impossible to update their TS version.
A
A
(not backported)B
The project is stuck on TS 3.3.3 if library
L
triggers bugA
, and libraryM
triggers bugB
.L
.M
.The project now needs to wait for a new TS version that fixes both
A
andB
in the same release, or wait forL
andM
to find workarounds... Or find other libraries that support the new TS version.The more libraries the project uses, the greater the chance of being unable to update their TS version.
Checklist
My suggestion meets these guidelines:
I understand that asking for type system fixes to be backported many versions increases the burden on the TS team, but it makes life easier for library authors.
And also makes life easier for library consumers, I suppose.
Imagine filing a bug report like,
"Your library does not work for TS version
X
",and then being told,
"Downgrade TS to
X-k
".And then downgrading causes errors for 10 other libraries due to other compiler bugs with fixes that were not backported.
The text was updated successfully, but these errors were encountered: