-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
files.associations "javascript" not forwarded to TypeScript Service #15460
Comments
Oh, sorry @dbaeumer I was thinking this code was closer to the TS Service code you have written. |
@waderyan I wrote that code and the reason for this is as follows: the script kind can only be set for a single open file. We can't tell the tsserver to treat all file with es6 extension as JS. As a result something like this will not work
We would treat it as JS and you would get code assist for stuff, ... however the import to a would be errored and you would not get any code complete for anything from a.es6. The reason is that the tsserver would only look for a a.js, a.ts or a.d.ts file and NOT for a.es6. Since this would even be more confusing I don't sent the scriptKind for all file. The reason why I do it for file without extension is the |
@dbaeumer The main focus here is viewing and editing files in VS Code. I fix the bufferSyncSupport.ts for me so that it always sends the scriptType and all these errors disappear. So the question is: Do I want confusion errors or just be able to use the editor? The code completion does not work in both cases, so it's an other problem that should be solved. |
Agree that the require will not give a red underline for the JS case. However there will still be no smartness here. So what we could do is to send the script kind for JS, but we should definitely not do it for TS since it will make things definitely worse. @mjbvz can you look into this. Change should be easy. |
I believe this was handled by #20351 |
Steps to Reproduce:
e.q. "javascript.es6" with content "var fs = require('fs');"
Use UI "Select Language Mode" for that or set "files.associations": {"*.es6":"javascript"}
This is because TypeScript Service associate this file as TypeScript (getScriptKindFromFileName default) if it does not get the scriptKindName from VS Code.
And VS Code only sets the scriptKindName for files without file extensions:
extensions/typescript/src/features/bufferSyncSupport.ts
I think TypeScript Service should always use the scriptKind selected in VS Code, especially for file extionsions not known by the TypeScript Service.
The text was updated successfully, but these errors were encountered: