-
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
Reordering variable declarations of Promise<any> and Promise<unknown> changes behavior #52100
Comments
Iβm thinking TS probably considers |
@fatcerberus That is my conclusion as well. |
Given the conclusion on ordering issues in the 6th Jan Design Meeting...
This implies that any direct user of the checker API needs to ensure that the order of source files fed to TypeScript is deterministic and, crucially, matches the order used by The file load order is a significant piece of knowledge that anyone embedding the TypeScript checker in a build tool needs to know and replicate. Otherwise the types and checking errors reported may differ between the IDE/LSP and the build tool. Ideal SolutionIdeally, the TypeScript language would make type declaration ordering irrelevant. That is easiest for users to understand and, as a bonus, permits the most flexibility and performance. But it sounds like that is not on the table right now. A second-best solution could be to make it possible to ban or lint-away any usage of the language that incurs ordering dependencies, so that projects could opt-into the subset of the language where ordering doesn't matter. Fallback SolutionToday, we embed the TypeScript checker in a custom toolchain that is used locally and during a remote project publishing step. But we don't have a custom LSP - we reuse the default VS Code LSP and configure it via a generated Is this canonical load order specified anywhere? Is there a way to reuse TypeScript's existing logic here? It would be great to reuse that code so that if TypeScript ever changes the order, our toolchain continues to match. |
I'll give a rough sketch. The order is:
This order is not final; it's then stably sorted by the dependency graph implied by |
@RyanCavanaugh This issue now appears to not happen anymore, and inference has stabilized on Was this intentional? Is this going to remain so going forward? |
AFAIK, we haven't done anything which we believed to be a fix. |
Bug Report
π Search Terms
Promise<any>
Promise<unknown>
instantiation orderπ Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Reordering the unrelated variables
u
anda
will cause the type ofunion
to change betweenPromise<unknown>
andPromise<any>
(both in declarations and in the type ofv
, although tooltips still showunion
asPromise<any>
)π Expected behavior
The type of
union
should not be impactedThe text was updated successfully, but these errors were encountered: