Keep track of file package scope(user project, library, compiler, etc.) - #2031
Conversation
|
Changes in this PR will be published to the following url to try(check status of TypeSpec Pull Request Try It pipeline for publish status): Website: https://cadlwebsite.z1.web.core.windows.net/prs/2031/ |
| }); | ||
| }); | ||
|
|
||
| describe("if a file is imported from main project and library, FIRST loaded wins...", () => { |
There was a problem hiding this comment.
This is the current behavior. It is not very nice to not have consistency here but at the same time this might be sign of a bad design from project structure.
Alternative would be to always promote to the project scope if it is part of it in any way
|
Overall, the notion of hooking module resolution to establish a map of sourceFile -> "project" | "compiler" | "library" feels good. Some thoughts:
|
|
"Domain"? |
|
I like domain, ish? But considering "Realms" is coming, "domains" and "realms" might be a bit much? Or we go all in and have features named "kingdoms", "fiefdoms", etc.? :-D Could also just be super descriptive - LocationContext or something like that? |
|
I tried naming it |
|
That works for me too. (Separately, my mind is wandering, thinking about a new name for the whole project where we lean into having "kingdoms" and "fiefdoms".) |
|
|
|
Timothee Guerin (@timotheeguerin) Ok but this is actually really good! I think we have our April Fools joke for next year?? Could pretty easily be supported 😈 My issue with DeclarationX is that I think we will want to pass non-declarations to this, e.g. template instantiations especially, which should have the fiefdom of where it is instantiated rather than where it is declared, probably. |
|
The template instantiation is a good point, I think it would be a different helper but resulting context object would be the same so Declaration is indeed not a good name. I guess |
|
Brian Terlson (@bterlson) Nick Guerrera (@nguerrera) could I get rereview of this PR, would like to be able to use that in the linter PR #2066 |
Co-authored-by: Nick Guerrera <nicholg@microsoft.com>
…ture/scoped-files
This is a key piece to ensure a linter can omit warnings in non project code.
The resolution goes as follow:
projectscopepackage.jsonset scope to thatlibrary. If library loads another library update the scope to be the nested library.compilerQuestions to answer: