Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/harness/fourslashInterfaceImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ export class Verify extends VerifyNegatable {
return this.state.verifyCompletions(optionsArray[0]);
}
for (const options of optionsArray) {
if (options.preferences && Object.keys(options).length === 1 && optionsArray.length > 1 && optionsArray.indexOf(options) > 0) {
Comment on lines 281 to +282
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

throw new Error("Did you mean to put 'preferences' in the previous 'verify.completions' object argument instead of their own object?");
}
this.state.verifyCompletions(options);
}
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ file.tsx(2,19): error TS2741: Property 'ref' is missing in type '{}' but require
"name": "@types/react",
"version": "0.0.1",
"main": "",
"types": "index.d.ts",
"types": "index.d.ts"
}
==== node_modules/@types/react/index.d.ts (0 errors) ====
interface IntrinsicClassAttributesAlias<T> {
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/jsxClassAttributeResolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const a = <App></App>;
"name": "@types/react",
"version": "0.0.1",
"main": "",
"types": "index.d.ts",
"types": "index.d.ts"
}
//// [index.d.ts]
interface IntrinsicClassAttributesAlias<T> {
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/compiler/jsxClassAttributeResolution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const a = <App></App>;
"name": "@types/react",
"version": "0.0.1",
"main": "",
"types": "index.d.ts",
"types": "index.d.ts"
}
// @filename: node_modules/@types/react/index.d.ts
interface IntrinsicClassAttributesAlias<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// @filename: node_modules/react/package.json
////{
//// "name": "react",
//// "types": "index.d.ts",
//// "types": "index.d.ts"
////}

// @filename: node_modules/react/index.d.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// @filename: node_modules/react/package.json
////{
//// "name": "react",
//// "types": "index.d.ts",
//// "types": "index.d.ts"
////}

// @filename: node_modules/react/index.d.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ test.markerNames().forEach(marker => {
kind: "var",
kindModifiers: "declare",
sortText: completion.SortText.GlobalsOrKeywords
}]
}, {
}],
preferences: {
includeInsertTextCompletions: true
}
Expand Down
11 changes: 8 additions & 3 deletions tests/cases/fourslash/completionsWithDeprecatedTag9.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,24 @@
////class Foo {
//// foo: number;
//// m() {
//// foo/**/
//// [|foo|]/**/
//// }
////}

verify.completions({
marker: "",
includes: [{
name: "foo",
insertText: "this.foo",
kind: "property",
source: completion.CompletionSource.ThisProperty,
sortText: completion.SortText.SuggestedClassMembers,
}, {
name: "foo",
kind: "var",
kindModifiers: "deprecated,declare",
sortText: completion.SortText.Deprecated(completion.SortText.GlobalsOrKeywords),
}]
}, {
}],
preferences: {
includeInsertTextCompletions: true
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/fourslash/organizeImportsReactJsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// @filename: node_modules/react/package.json
////{
//// "name": "react",
//// "types": "index.d.ts",
//// "types": "index.d.ts"
////}

// @filename: node_modules/react/index.d.ts
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/fourslash/organizeImportsReactJsxDev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// @filename: node_modules/react/package.json
////{
//// "name": "react",
//// "types": "index.d.ts",
//// "types": "index.d.ts"
////}

// @filename: node_modules/react/index.d.ts
Expand Down