Skip to content
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

jsconfig.json generates incorrectly and disallows correction #5520

Closed
djeune opened this issue Mar 26, 2024 · 5 comments · Fixed by forcedotcom/lightning-language-server#597

Comments

@djeune
Copy link

djeune commented Mar 26, 2024

Summary

When the Salesforce Extensions for VSCode activate, they generate a jsconfig.json file within the lwc directory to support intellisense in Lightning Web Components.

When the file is generated, it includes a key "paths" as a top level property of the configuration object. This is the incorrect place for the key, as it belongs within the compilerOptions object.

See documentation here for more information. Specifically, the "jsConfig options" header describes the correct configuration.

To make the issue worse, this improper configuration is re-applied after removal any time the Salesforce Extensions reload.

Steps To Reproduce:

  1. Generate a new project with the Salesforce CLI command sf project generate
  2. Observe the generated jsconfig.json file within the lwc directory and its improper structure.
  3. Move the key to the compilerOptions object and save the file.
  4. Reload the window from the command palette to force the Salesforce Extensions to reload.
  5. Observe that the erroneous key has been re-added to the configuration.

Expected result

The jsconfig.json file should generate with a valid configuration file. Failing that, it should respect the user's attempts to fix it.

Actual result

The jsconfig.json file generates with an invalid "paths" key and re-adds this key when it is removed.

Additional information

Salesforce Extension Version in VS Code: 60.5.1

SFDX CLI Version: 2.33.3

OS and version: MacOS Sonoma 14.3.1

VS Code version: 1.87.2

Additional note on preferred fix: I would prefer to be able to modify files after generation without worrying about the extensions overriding my changes. I have also run into this problem with .forceignore, which doesn't allow me to the remove .eslint.json entry even though I am using the flat config eslint.config.js file located at the root of the project.

@CristiCanizales
Copy link
Contributor

CristiCanizales commented Mar 30, 2024

Hi @djeune, sorry for the delay. Thank you for bringing this to out attention! I was able to replicate this bug and we'll be adding it to our backlog.

@CristiCanizales
Copy link
Contributor

Link to Bug W-15374337

@nwcm
Copy link

nwcm commented May 27, 2024

likewise baseUrl is required in complierOptions when using * path mappings

@diyer diyer added the area:lwc label Jul 2, 2024
@diyer
Copy link
Collaborator

diyer commented Jul 2, 2024

@djeune can you please describe the user impact on development due to this behavior?

@djeune
Copy link
Author

djeune commented Jul 2, 2024

The configuration file is necessary for type acquisition when attempting to use VSCode's built-in javascript/typescript features.

When I discovered the problem, I was attempting to get type information working from one LWC component to another. For example, if I had an LWC component that imported shared code from a different component, I wanted vscode to support type information from that shared code. Code sharing process described here.

I reported the erroneous file generation because is generating invalid configuration files. However, the best case would be if the standard configuration supported the use case linked above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants