Fix configuration lookups and prefer saving as js/ts#4054
Open
DanielRosenwasser wants to merge 5 commits into
Open
Fix configuration lookups and prefer saving as js/ts#4054DanielRosenwasser wants to merge 5 commits into
js/ts#4054DanielRosenwasser wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the VS Code native-preview extension to prefer the unified js/ts.experimental.useTsgo setting when reporting or updating the useTsgo enablement flag, since typescript.experimental.useTsgo is deprecated.
Changes:
- Update the development-mode warning to default to referencing
js/ts.experimental.useTsgo. - Change
updateUseTsgoSettingto prefer writingjs/ts.experimental.useTsgoin more cases and avoid updating both settings at once.
Show a summary per file
| File | Description |
|---|---|
| _extension/src/extension.ts | Adjusts the dev-mode warning fallback setting name to js/ts.experimental.useTsgo. |
| _extension/src/commands.ts | Updates logic for choosing which configuration section/target to update when toggling useTsgo. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
Comment on lines
37
to
42
| if (jsTsTarget !== undefined || tsTarget === undefined) { | ||
| await jsTsConfig.update("experimental.useTsgo", enable, jsTsTarget ?? vscode.ConfigurationTarget.Global); | ||
| } | ||
| if (tsTarget !== undefined || jsTsTarget === undefined) { | ||
| updates.push(tsConfig.update("experimental.useTsgo", enable, tsTarget ?? vscode.ConfigurationTarget.Global)); | ||
| else if (tsTarget !== undefined) { | ||
| await tsConfig.update("experimental.useTsgo", enable, tsTarget); | ||
| } |
js/ts settings when modifying useTsgo.js/ts
Comment on lines
156
to
+168
| export function getUseTsgo(): boolean | undefined { | ||
| const tsValue = getExplicitUseTsgo("typescript"); | ||
| const jsTsValue = getExplicitUseTsgo("js/ts"); | ||
| if (tsValue === true || jsTsValue === true) return true; | ||
| if (tsValue === false || jsTsValue === false) return false; | ||
|
|
||
| if (tsValue !== undefined || jsTsValue !== undefined) { | ||
| const jsTsTarget = getExplicitConfigTarget(vscode.workspace.getConfiguration("js/ts"), "experimental.useTsgo"); | ||
| const tsTarget = getExplicitConfigTarget(vscode.workspace.getConfiguration("typescript"), "experimental.useTsgo"); | ||
| const mostSpecific = Math.max(jsTsTarget ?? vscode.ConfigurationTarget.Global, tsTarget ?? vscode.ConfigurationTarget.Global); | ||
| return jsTsTarget === mostSpecific ? jsTsValue : tsValue; | ||
| } | ||
|
|
||
| return undefined; | ||
| } |
…dence and resolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When modifying the
useTsgosetting, we would previously modifytypescript.experimental.useTsgo; however, that setting is deprecated.Additionally, we would always prefer
js/ts.experimental.useTsgoovertypescript.experimental.useTsgo, even if the latter occurred in the workspace, and the former occurred in the global user settings.And finally, we had a bug in development mode where we would always start the server if
useTsgowas explicitlyfalse.This PR does a few things:
typescript.experimental.useTsgocan now win out overjs/ts.experimental.useTsgoif it was specified in the workspace, andjs/tswas specified in the user settings. If both are specified in the same location,js/tsalways wins out.js/tsconfiguration when making modifications. If the user toggles the settings via our commands, we will migrate any currently-activetypescriptconfigurations, or just drop them if they coexist in the same settings location.useTsgo === falsein development mode, instead of starting up the language server.