Skip to main content
The Completions API provides IntelliSense features like auto-complete suggestions, parameter hints, and import completions. This powers the dropdown suggestion list in editors.

Overview

Completions are retrieved in two steps:
  1. Get completion list with getCompletionsAtPosition() - Fast, returns basic info
  2. Get entry details with getCompletionEntryDetails() - Slower, called when user selects an item
This two-phase approach optimizes performance by deferring expensive operations until needed.

getCompletionsAtPosition

Returns completion suggestions at a specific position in a file.

Signature

Parameters

fileName
string
required
The path to the source file.
position
number
required
Zero-based character offset in the file where completions are requested.
options
GetCompletionsAtPositionOptions
Options controlling what completions to return:
formattingSettings
FormatCodeSettings
Formatting options for generated code in completions.

Return Value

CompletionEntry

Example: Basic Completions

Basic Usage

Example: Auto-Import Completions

Auto-Import

Example: Member Completions

Member Completions

getCompletionEntryDetails

Retrieve detailed information about a specific completion entry.

Signature

Parameters

fileName
string
required
The path to the source file.
position
number
required
Position where the completion was requested.
entryName
string
required
The name field from the CompletionEntry.
formatOptions
FormatCodeSettings
Formatting settings for code generation.
source
string
The source field from the CompletionEntry (for auto-imports).
preferences
UserPreferences
User preferences for code generation.
data
CompletionEntryData
The data field from the CompletionEntry.

Return Value

Example: Completion Details

Completion Details

Completion Triggers

Completions can be triggered by specific characters:
Trigger Examples

Sort Text and Ordering

The sortText field controls display order:
Lower sort text appears first in completion lists.

Example: Filtering Completions

Filter by Kind

Commit Characters

Characters that accept/commit a completion:
Usage

Performance Optimization

The completions API is optimized for responsiveness:

Incomplete Completions

When options.allowIncompleteCompletions is true, the Language Service may return partial results:

Module Specifier Resolution

Auto-import completions are limited to prevent performance issues in large projects.

Real-World Integration

Complete Example

See Also

Language Service API

Main Language Service reference

Diagnostics

Error reporting and diagnostics

Navigation

Go to definition and find references

Language Service Overview

Language Service architecture