Automatically refactor JavaScript or TypeScript functions to use object parameters instead of multiple positional parameters, improving readability and maintainability.
Features
Automatic Refactoring: Converts function signature and all call sites across your workspace
Smart Detection: Identifies confirmed safe conversions and asks about uncertain cases
Preview Mode: Optional preview dialogs to review each change before applying
Workspace-Wide: Scans and updates all matching files in your project
Type-Safe: Preserves TypeScript types, optional parameters, and function return types
Preview walkthrough is optional.
Usage
Place your cursor inside a function definition.
Right-click and select "Objectify Params" or use the Command Palette. You can assign your own hot-key.
Review any uncertain conversions in interactive dialogs. In every dialog the cancel button will remove all changes.
The extension updates both the function signature and all call sites.
Before
function createUser(name: string, age = 22) {
return { name, age };
}
createUser("Alice", 30);
createUser("Bob");
After
function createUser($: { name: string; age?: number }) {
let { name, age = 22 } = $;
return { name, age };
}
createUser({ name:"Alice", age:30 });
createUser({ name:"Bob" });
Configuration
Access settings via File > Preferences > Settings and search for "Objectify Params":
objectifyParams.1.showPreviews
Type: boolean
Default: true
Show preview dialog for every call conversion (including confirmed safe calls)
objectifyParams.2.highlightDelay
Type: number
Default: 1000
Range: 0-5000ms
Duration in ms to show preview highlights. Set to 0 to show only the dialog without delay
objectifyParams.3.objectVariable
Type: string
Default: $par$
Provide a variable name for a single object parameter in the signature. The extension inserts let { ... } = $par$; as the first statement inside the function body. If this field is blank then the object is destructured inline in the parameter list.
objectifyParams.4.preserveTypes
Type: boolean
Default: true
When disabled, any extracted TypeScript types are replaced with any, dropping type information for both the incoming object and the destructured properties.
objectifyParams.5.exclude
Type: string
Default: "**/node_modules/**"
Space-separated glob patterns to exclude
Priority over includes
objectifyParams.6.include
Type: string
Default: "**/*.ts **/*.js"
Space-separated glob patterns of files to scan
How It Works
Scanning: Searches your workspace for all references to the function
Classification: Categorizes calls as:
Confirmed: Safe to convert automatically
Fuzzy: Requires user review (name collisions, argument mismatches, etc.)