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

Set typescript.tsdk so VSCode's TS language features work properly #4143

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dvg-p4
Copy link
Contributor

@dvg-p4 dvg-p4 commented Oct 10, 2024

EDIT 2: Setting the typescript version in the UI actually just creates this line in the settings.json file under the hood.

EDIT 3: but it seems to keep the right version even if you subsequently revert that change to settings.json ???


EDIT: The real solution to the problem I was having was simply to configure the TypeScript version used, via VSCode UI. Hit the braces on the bottom right:

image

Then "Select Version":

image

Then "Use Workspace Version".


This prevents spurious linting warnings, and makes type detection work properly with the complex constructions used in some places.

@dvg-p4 dvg-p4 changed the title Set typescript.tsdk so vscode's TS tools work properly Set typescript.tsdk so VSCode's TS language features work properly Oct 10, 2024
@gadenbuie
Copy link
Member

This prevents spurious linting warnings, and makes type detection work properly

I think there might be something particular to your local setup that's involved here. I don't see any lint errors in VS Code currently.

@dvg-p4
Copy link
Contributor Author

dvg-p4 commented Oct 10, 2024

Do you have TypeScript > Validate enabled or disabled?

@dvg-p4
Copy link
Contributor Author

dvg-p4 commented Oct 10, 2024

Also, if you open up this line in VSCode:

} else if (hasDefinedProperty(data, "value")) {

and hover over data, does it show

image

or....never mind, I can't seem to reproduce the old behavior anymore, even after switching back to main. But it used to say data: never before I started messing with the settings.

@dvg-p4
Copy link
Contributor Author

dvg-p4 commented Oct 10, 2024

Ahhh I see. On the bottom right:

image

If I click "Select Version":

image

With "Use VS Code's Version" I get the errors:

image

But with "Use Workspace Version" everything works properly:

image

@dvg-p4 dvg-p4 closed this Oct 10, 2024
@dvg-p4
Copy link
Contributor Author

dvg-p4 commented Oct 10, 2024

Messing with the settings appears to have kicked my VS Code into the "use workspace version" state, but is not generally needed to do so, since apparently there's an actual menu 🤦‍♂️.

@dvg-p4 dvg-p4 deleted the vscode-typescript.tsdk branch October 10, 2024 16:08
@dvg-p4 dvg-p4 restored the vscode-typescript.tsdk branch October 10, 2024 16:35
@dvg-p4
Copy link
Contributor Author

dvg-p4 commented Oct 10, 2024

...actually it turns out, selecting the setting in the UI just automatically adds this line to to the project's settings.json file. So this does need to be here for it to work right (I think?)

@dvg-p4 dvg-p4 reopened this Oct 10, 2024
@dvg-p4
Copy link
Contributor Author

dvg-p4 commented Oct 10, 2024

...but if I revert the change to settings.json and reload VSCode then it keeps using the right version anyways???

@dvg-p4 dvg-p4 marked this pull request as draft October 14, 2024 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants