compatibility previous typescript versions
Allow me to use the latest and greatest version of Typescript but allow me to specify the minimum TS version I want the emitted declaration files to be compatible with.
For example I might want to use the latest version of Typescript so that I could use the // @ts-expect-error in my tests but I might want my compiled package to be usable with TS 3.1. The emitted declaration files would not include this so would be compatible with 3.1
Latest and greatest features of TS could be used freely anywhere in the code. As soon as this results in incompatible types being emitted in the declaration files TS throws an error saying this is incompatible.
This would allow new features to be used within a function (where it will not affect the declaration files) but if you wanted to return an incompatible type you would be stopped.
My suggestion meets these guidelines:
You can achieve this already by providing different .d.ts files for different TypeScript versions: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#version-selection-with-typesversions
You can use the downlevel-dts tool by Nathan to create .d.ts files targeting older versions: https://github.com/sandersn/downlevel-dts
The current solution as described by @MartinJohns is as far as we intend to go in this area.
Most helpful comment
You can achieve this already by providing different .d.ts files for different TypeScript versions: https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#version-selection-with-typesversions
You can use the downlevel-dts tool by Nathan to create .d.ts files targeting older versions: https://github.com/sandersn/downlevel-dts