Skip to content

Deprioritize native Function methods in IntelliSense#63147

Open
apoorvdarshan wants to merge 1 commit intomicrosoft:mainfrom
apoorvdarshan:deprioritize-native-function-members
Open

Deprioritize native Function methods in IntelliSense#63147
apoorvdarshan wants to merge 1 commit intomicrosoft:mainfrom
apoorvdarshan:deprioritize-native-function-members

Conversation

@apoorvdarshan
Copy link

Summary

  • When autocompleting on a function value with custom properties (e.g. Bun.inspect.), native Function prototype methods (apply, bind, call, etc.) now sort below custom properties instead of above them
  • Adds an isNativeFunctionMember helper that identifies symbols from the global Function, CallableFunction, and NewableFunction interfaces, and assigns them SortText.SortBelow(LocationPriority) so custom properties appear first
  • Applies deprioritization in both checked (TypeScript) and unchecked (JavaScript) file code paths

Fixes #61426

Test plan

  • New fourslash test completionsFunctionCustomProperties.ts verifying custom properties sort above native Function methods
  • New test also verifies static class members continue to appear above Function methods (no regression)
  • All 6811 existing fourslash tests pass
  • Updated baselines and tests that check explicit sort text for native Function members

When autocompleting on a function value with custom properties,
native Function prototype methods (apply, bind, call, etc.) now
sort below custom properties. This is achieved by assigning
SortText.SortBelow(LocationPriority) to members of the global
Function, CallableFunction, and NewableFunction interfaces.

Fixes microsoft#61426
Copilot AI review requested due to automatic review settings February 16, 2026 10:34
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Feb 16, 2026
@typescript-bot typescript-bot added the For Milestone Bug PRs that fix a bug with a specific milestone label Feb 16, 2026
@apoorvdarshan
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Contributor

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 improves the IntelliSense experience for function values with custom properties by deprioritizing native Function prototype methods (like apply, bind, call, toString, length, arguments, caller, and prototype) so they appear below custom properties in autocomplete suggestions. This addresses issue #61426, which was raised in the context of Bun's APIs where functions like Bun.inspect have custom properties (e.g., Bun.inspect.table and Bun.inspect.custom) that are more useful than the native Function methods.

Changes:

  • Added an isNativeFunctionMember helper function that identifies symbols from the global Function, CallableFunction, and NewableFunction interfaces
  • Applied deprioritization using SortText.SortBelow(LocationPriority) in both checked (TypeScript) and unchecked (JavaScript) completion code paths
  • Added comprehensive fourslash test completionsFunctionCustomProperties.ts verifying the new behavior
  • Updated test infrastructure and baselines to reflect the new sort order

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/services/completions.ts Added isNativeFunctionMember helper and applied deprioritization logic in both checked and unchecked file completion paths
src/harness/fourslashInterfaceImpl.ts Updated test infrastructure to reflect deprioritized sort text for function members and prototype
tests/cases/fourslash/completionsFunctionCustomProperties.ts New test verifying custom properties sort above native Function methods while static class members maintain their priority
tests/cases/fourslash/server/completions02.ts Updated to reflect new sort order with prototype and custom properties appearing before deprioritized Function methods
tests/cases/fourslash/javaScriptPrototype1.ts Updated expected sortText for native Function members
tests/cases/fourslash/completionListStaticProtectedMembers2.ts Simplified test using functionMembersPlus helper instead of listing individual Function members
tests/cases/fourslash/completionListOnAliases2.ts Updated expected sortText for call method
tests/baselines/reference/tsserver/fourslashServer/completions02.js Baseline showing correct sort order: custom properties and prototype first (sortText "11"), then Function methods (sortText "111")
tests/baselines/reference/completionsCommitCharactersAfterDot.baseline Updated baselines reflecting deprioritized Function members with sortText "111"
tests/baselines/reference/completionsCommentsClassMembers.baseline Updated baselines showing prototype appearing before Function methods in completion lists

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

Labels

For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

Intellisense: deprioritise native function methods

2 participants