Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript should allow declarations to be compatible with older versions. #37478

Closed
5 tasks done
justinfagnani opened this issue Mar 19, 2020 · 4 comments
Closed
5 tasks done
Labels
Duplicate An existing issue was already created

Comments

@justinfagnani
Copy link

Search Terms

semver

Suggestion

We would like to use TypeScript 3.8 and emit declaration files compatible with TypeScript 3.4

Use Cases

Many of our users can't upgrade their TypeScript version because they are using a version mandated by another tool, especially Angular. We want to be able to use the newest TypeScript on out source to gain additional features, but that should be isolated from the outputs of our project that other projects consume.

The particular motivation for this request is that my project upgraded to TypeScript 3.8, which emits property accessors in declaration files. We have multiple reports from users that this broke their builds with TypeScript 3.4 with the message "An accessor cannot be declared in an ambient context.".

Examples

{
  "compilerOptions": {
    "declaration": true,
    "declarationVersion": "3.4",
}

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
@AnyhowStep
Copy link
Contributor

AnyhowStep commented Mar 19, 2020

I haven't personally tried it but, https://github.com/sandersn/downlevel-dts

Yeah, it's an additional step in your build process and it would be great if TS supported it by default.

I'm personally still on 3.5.1 because I know upgrading will break a lot of things at work for me

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Mar 19, 2020
@RyanCavanaugh
Copy link
Member

See #35016

@justinfagnani
Copy link
Author

The downlevel-dts tool appears to be written by a TypeScript team member... so it's at least somewhat a recognized problem. Why is it out of scope then?

Combined with TypeScript not following semver and breaking .d.ts changes in minor versions, the current situation leads to some very nasty surprises when we publish what should be a non-breaking change of our project, but it is for TypeScript consumers.

Without this semi-external tool, the only way for a project to be safe is to only upgrade TypeScript minor versions when our project has a new major version. That's not at all a constraint I planned for.

@RyanCavanaugh
Copy link
Member

We can't solve every problem in the entire TS ecosystem with code written inside this repository. That's what we mean by "out of scope" - we had hoped someone would write downlevel-dts (since it's fairly straightforward), but we stepped in when that didn't happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants