Skip to content

Conversation

@andrewbranch
Copy link
Member

Fixes incorrect completions preferences passing and trailing commas in package.jsons

Copilot AI review requested due to automatic review settings October 20, 2025 18:17
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Oct 20, 2025
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 20, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes issues in fourslash tests related to invalid JSON syntax and incorrect completions API usage. The changes ensure that package.json files in test fixtures are valid JSON (removing trailing commas) and that completion preferences are passed correctly to the verify.completions API.

  • Removes trailing commas from package.json files to ensure valid JSON syntax
  • Fixes incorrect preferences passing in verify.completions calls where preferences were mistakenly placed as a separate argument instead of within the options object
  • Adds runtime validation to catch future instances of incorrect preferences passing

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/cases/fourslash/server/importSuggestionsCache_invalidPackageJson.ts Removes trailing comma from jsconfig.json
tests/cases/fourslash/organizeImportsReactJsxDev.ts Removes trailing comma from react package.json
tests/cases/fourslash/organizeImportsReactJsx.ts Removes trailing comma from react package.json
tests/cases/fourslash/completionsWithDeprecatedTag9.ts Fixes preferences passing and adds missing completion entries
tests/cases/fourslash/completionsThisProperties_globalType.ts Fixes preferences passing syntax
tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports48.ts Removes trailing comma from react package.json
tests/cases/fourslash/codeFixMissingTypeAnnotationOnExports47.ts Removes trailing comma from react package.json
tests/cases/compiler/jsxClassAttributeResolution.tsx Removes trailing comma from @types/react package.json
tests/baselines/reference/jsxClassAttributeResolution.js Updates baseline to match fixed package.json
tests/baselines/reference/jsxClassAttributeResolution.errors.txt Updates baseline to match fixed package.json
src/harness/fourslashInterfaceImpl.ts Adds validation to detect incorrect preferences passing pattern

Comment on lines 281 to +282
for (const options of optionsArray) {
if (options.preferences && Object.keys(options).length === 1 && optionsArray.length > 1 && optionsArray.indexOf(options) > 0) {
Copy link

Copilot AI Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using optionsArray.indexOf(options) within a loop has O(n²) complexity. Store the index from the for...of loop instead. Change for (const options of optionsArray) to for (let i = 0; i < optionsArray.length; i++) and use i > 0 in the condition.

Suggested change
for (const options of optionsArray) {
if (options.preferences && Object.keys(options).length === 1 && optionsArray.length > 1 && optionsArray.indexOf(options) > 0) {
for (let i = 0; i < optionsArray.length; i++) {
const options = optionsArray[i];
if (options.preferences && Object.keys(options).length === 1 && optionsArray.length > 1 && i > 0) {

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a completely wild review comment but not a concern here

@@ -3,7 +3,7 @@
// @Filename: /home/src/workspaces/project/jsconfig.json
////{
//// "compilerOptions": {
//// "module": "commonjs",
//// "module": "commonjs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a jsconfig so probably okay, but NBD

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I just modified readJson and went to town

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean jsconfigs are not using JSONC? Fun

@github-project-automation github-project-automation bot moved this from Not started to Needs merge in PR Backlog Oct 20, 2025
@andrewbranch
Copy link
Member Author

@typescript-bot cherry-pick to tsgo-port

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 20, 2025

Starting jobs; this comment will be updated as builds start and complete.

Command Status Results
cherry-pick to tsgo-port ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

Hey, @andrewbranch! I've created #62642 for you.

@andrewbranch
Copy link
Member Author

Lol, one of them is named "importSuggestionsCache_invalidPackageJson" so I better revert that one too

@andrewbranch
Copy link
Member Author

Oh, it’s the same one I changed the jsconfig on

@andrewbranch andrewbranch enabled auto-merge (squash) October 20, 2025 18:50
@andrewbranch
Copy link
Member Author

These timeouts are getting annoying...

@andrewbranch andrewbranch merged commit 84f4856 into microsoft:main Oct 20, 2025
56 of 60 checks passed
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Oct 20, 2025
andrewbranch added a commit that referenced this pull request Oct 20, 2025
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
Co-authored-by: Andrew Branch <andrew@wheream.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants