-
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
Opening files in different order in IDE produces different errors #1953
Comments
This could be fixed by adding a stricter subtype rule for optional parameters versus absent parameters |
This should be fixed after the strict object literal changes |
What exactly is the reason for that? |
@DanielRosenwasser I believe because This has to do with the nondeterministic order of types for union type collapsing. is no longer relevant as subtype reduction for union types was removed as part of the strict object literal changes. We should double check that this actually no longer repros though. |
It isn't really because we eliminated subtype reduction in that change. We did in fact eliminate subtype reduction. But more importantly we eliminating the sorting of union constituents by type id. That was the source of the nondeterminism. |
0.ts:
1.ts:
2.ts:
These three files form a clique because they all reference each other. If you start with none of these files open, and then open them, you may or may not get an error depending on the order that you open the files. Specifically, if you open file 0.ts or 1.ts first, you get an error. But if you open 2.ts first, you get no error.
This has to do with the nondeterministic order of types for union type collapsing.
This also means that the order the IDE calls getSemanticDiagnostics on the files is important, as it could lead to different outcomes. For compile-on-save, we call getSemanticDiagnostics on just the file we are saving. But in order to get a consistent outcome, we would have to call getSemanicDiagnostics on all the files in a canonical order, every time a file is saved. This means many files may have to be type checked before you can emit the file you've saved.
The text was updated successfully, but these errors were encountered: