Currently, if I have a project test, with a file test/src/app.js. I need this workspace setting to get it recognized as TypeSscript:
{
"files.associations": {
"/Users/octref/Code/fiddle/test/src/*.js": "typescript"
}
}
I wish I could do
{
"files.associations": {
"src/*.js": "typescript"
}
}
@octref for that I think you should set:
{
"files.associations": {
"**/src/*.js": "typescript"
}
}
Since it is totally valid to open files without having a workspace open we cannot allow workspace relative paths here.
@bpasero
But things like test/node_modules/mypackage/src/app.js would also be matched with "**/src/*.js.
That is true but just allowing workspace relative paths is causing many issues because they do not work once you have no workspace open. How would you solve that?
How about only applying global files.associations when no workspace is open?
Or if you meant adding relative path to workspace settings in general, how about allowing ${workspaceRoot}, similar to launch.json?
I am not sure I understand the suggestion. For one a user might not easily understand the difference between workspace and global association setting, it is too subtle. And then while we could support ${workspaceRoot} it would not work when no workspace is open and again I fear this is too subtle...
The only potential solution I see is to allow for workspace relative paths only when you configure workspace settings (as opposed to global settings). But this needs lots of guidance to the user to make this understandable.
I am open for suggestions and PRs if someone wants to jump in.
@bpasero Agree with your views on implementation. I just found this issue after trying to set a relative files.associations path in a workspace settings files. From my PoV, it only makes sense to support such paths within workspace settings files and not global or user settings files.
We closed this issue because we don't plan to address it in the foreseeable future. You can find more detailed information about our decision-making process here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding and happy coding!
Most helpful comment
@octref for that I think you should set:
Since it is totally valid to open files without having a workspace open we cannot allow workspace relative paths here.