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
allow listing source files in a strict order #26331
Comments
configuringas far as configuring, the existing the order of files in the
should be evaluated as listed:
it's up to the user to arrange/group files in this list based on whatever reasoning displaying in code editorsupon evaluating the order of the files in the configuration the code editor should make an attempt to display files grouped by subfolders for continuous sequences of files coming from the same subfolder:
should be displayed as:
|
semanticsthe only one adjustment needs to be made to the logic of the compiler before evaluating the code in unrestricted manner:
|
order of diagnosticsdiagnostics messages should come in the following order:
|
autoimportsautoimport needs to be aware of the files order and warn or prevent the users from importing from files listed after the edited file |
This, sadly, is by design and needs to be supported by TypeScript as it is a runtime reality. (see: #21780). The difference between F# and TypeScript is that F# has control of the execution order of code, TypeScript does not. When dealing with modules and imports, the execution order is defined in the standard. Unclear situations of execution order make it impossible to implement some syntax ahead of the standard being confirmed (see: #25988). So if you are dealing with modular code, the resolution and execution order are already defined. When you are dealing with the global or ambient context, I don't see how having an explicit ordering would actually help anything, especially because in a lot of cases, not the full context is listed in There is something to be said about co-dependent diagnostics though, and how when there are ambient/global conflicts the compiler isn't overly helpful at the moment, it just sort of 🤷♂️ s. |
all i am suggesting is a special compilation mode that has nothing to do with standards or runtime:
i am well aware that most developers tsconfig.json looks like this the proposed idea is not going to mess with the standard or solve inherent problems of javascript, all it does is: feeds files to typescript checker in a certain order, and confirms that imports don't violate this order, that's about it |
Not really seeing a need for this in the largely module-based world we now live in |
this is what F# does, each file has its place within the list of files, the place tells the compiler what it should look at first and defines the relationship between dependencies and dependent files
use cases:
having a strict hierarchy of files eliminates a chance of mutual dependencies between modules (good for overall design)
ease of localizing places that broke, by looking at the list you can see the ones at the top that cause problems for those in the bottom and start fixing from the top (rather than looking at the list of 500+ errors and not knowing where to start)
The text was updated successfully, but these errors were encountered: