Skip to content

Maintaining Emitted Backwards Compatibility Across Minor ReleasesΒ #51392

Closed
@JasonGore

Description

@JasonGore

Bug Report

πŸ”Ž Search Terms

maintain emitted backwards compatibility ts minbar across minor releases

πŸ•— Version & Regression Information

  • This changed between versions TS4.4 and TS4.5

⏯ Playground Link

Playground link with relevant code showing d.ts emitted inline type imports that break consumers < TS4.5

πŸ’» Code

import { type DOMElement } from "react";

export type SomeElement = DOMElement;

πŸ™ Actual behavior

Downstream consumers using < TS4.5 break upon d.ts output containing inline type imports. downlevel-dts does not appear to support making inline type imports backwards compatible.

πŸ™‚ Expected behavior

I wanted to create this issue primarily for collaboration, but I'm creating it as a bug as I think at the very least there is a gap in downlevel-dts.

TS regularly adds new features like inline type imports that make emitted TS output incompatible for any downstream consumer using any older version of TS. TypeScript considers these features opt-in and therefore aren't listed as a breaking change. However, since devs don't easily know which minor release features break backwards compatibility, it becomes untenable to use any new feature introduced by any TS minor release for fear of breaking any downstream consumer that isn't at the latest possible version. This ends up introducing significant friction in maintaining TS update velocity, either because we don't want to upgrade as frequently or because we introduce issues using new TS features that only become known as downstream consumers use our emitted source.

While there are tools like downlevel-dts it doesn't appear to cover this specific inline type import issue, so that wouldn't fix our issue in this case.

It seems there should be some test suite in TS that determines whether the emitted output of each new minor release feature is backwards compatible. At the very least, this could feed into downlevel-dts to uncover gaps in the downlevel tooling. It would also be really helpful if this could feed into a minbar configuration that would indicate to devs whether or not the features they are using break backwards compatibility. If I could tell TS which TS version I want to maintain compatibility with and have it fail compilation if the emitted output is not compatible, that would be ideal.

To summarize, as things currently stand, our options are:

  • Allow devs to use new features and respond reactively to downstream issues as they occur. This is our current mode of operation and is untenable because it causes significant friction with our releases and our downstream consumers.
  • Stop updating to minor releases altogether. If using any new minor feature can break any of our downstream consumers using any earlier version of the same major release, our only realistic alternative may be to avoid using any new minor release features entirely.
  • Some way of understanding how using any features in a given release affect TS minbar compatibility. It'd be nice if TS could take in a minbar target configuration and fail compilation if that minbar is violated with the use of a feature, such as inline type imports.
  • Find some method to validate feature compatibility that feeds into downlevel-dts to uncover gaps such as inline type imports not being transformed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions