-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Moving to TS 2.0 causes grief due to d.ts file incompatibility #10412
Comments
This would be at the expense of accuracy for other 2.0 users. We don't guarantee downlevel .d.ts emit and never have. Someone can write a downleveler tool if it's truly needed - it'd be quite simple. |
please see my comment in #6702 (comment) and in #7573. This is an unfortunate side effect of the type system getting more accurate. this also applies to |
I think |
I think in particular, TypeScript 2.0 would be a significant flag to people that there are likely to be breaking changes. |
@kitsonk but this has a very bad ripple. If I write an npm module and now upgrade to TS 2.0 I am almost forced to do a major version number change of my npm module since I force all users of my npm module that use TS to upgrade as well. And they might not be able to. So I need to give them a choice. From my experience having backwards compatibility in a language is very critical for adopting new versions. |
So major version of languages aren't allowed to introduce breaking changes? That seems like a severe limitation. |
They are for new features. However if I use my code unchanged it would be cool if they can generate code that is compatible. Java for example did this for the generated byte code. |
Notably, Java is often hamstrung by that decision (e.g. erased generics). |
As said I am not arguing against new features (like generics, undefined, never type, ....). I am only saying that if my code successfully compiles with 1.8.10 I should be able to generate the same output with 2.0. |
+1 |
I've started a simple regex-based tool that downlevels the .d.ts files generated for https://github.com/angular-ui/ui-router/ . It only downlevels the stuff that my own project is emitting, so feel free to submit PR. https://github.com/christopherthielen/dts-downlevel |
TypeScript Version: 1.8.x and 2.0
Code
A d.ts file for this ts file looks with 2.0 like this:
This d.ts file can't be consumed by clients still using 1.8.10 compiler. To ease transition to 2.0 the compiler should allow to generate 1.8 compliant d.ts file if possible, which is not possible for example with using undefined as a type.
The text was updated successfully, but these errors were encountered: