Skip to content

Deprioritize native Function methods in IntelliSense#63147

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

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

Conversation

@apoorvdarshan
Copy link
Copy Markdown

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
Copy Markdown
Author

@microsoft-github-policy-service agree

Copy link
Copy Markdown
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

@typescript-bot
Copy link
Copy Markdown
Collaborator

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

@github-project-automation github-project-automation bot moved this from Not started to Done in PR Backlog Mar 24, 2026
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: Done

Development

Successfully merging this pull request may close these issues.

Intellisense: deprioritise native function methods

3 participants