Diagnostics & Quick Fixes

Real-time, type-aware error checking for SFCC scripts, plus SFCC-specific warnings, quick fixes, and refactorings

The language server checks your scripts as you type and reports problems in the editor and the Problems panel - with the same depth as a TypeScript project, plus checks that only make sense for SFCC.

Real-Time Script Diagnostics

For sfcc-javascript, sfcc-typescript, and digitalscript (.ds) files, the engine surfaces TypeScript's full diagnostic set, mapped to SFCC types:

  • Semantic errors - calling a method that does not exist, accessing an unknown property, passing the wrong argument type.
  • Syntactic errors - malformed code the parser cannot accept.
  • Suggestions - lower-priority hints (shown as faint underlines).
var ProductMgr = require('dw/catalog/ProductMgr');
var product = ProductMgr.getProduct('p1');
product.notARealMethod();
//      ~~~~~~~~~~~~~~~ Property 'notARealMethod' does not exist on type 'Product'.

Severity follows TypeScript's classification - error, warning, information, or hint - and feeds VS Code's squiggles, the Problems panel, and the editor gutter.

Diagnostics are debounced (about ¾ of a second) so they recompute when you pause typing, not on every keystroke - keeping the editor responsive on large files.

Cross-file awareness

The checker understands dependencies between files. Edit a module's exports and the files that require() or importScript() it are re-checked, so a breaking change shows up at the call sites - not just where you made it.

SFCC-Specific Diagnostics

Beyond standard type checking, the server adds warnings that target real SFCC pitfalls:

Quick Fixes & Refactorings

Where a diagnostic has a fix, the lightbulb (Cmd/Ctrl+.) offers it. The server exposes the TypeScript engine's code actions for SFCC scripts:

  • Quick fixes - add a missing require/import, remove an unused variable, fix a misspelled identifier, add a missing property, and other diagnostic-driven repairs.
  • Refactorings - extract a selection to a function or constant, inline a variable, convert function forms, and move statements.
// Before - lightbulb offers "Extract to function"
var subtotal = lineItem.quantity * lineItem.price;
var tax = subtotal * 0.2;

// After applying the refactor
var subtotal = computeSubtotal(lineItem);

What About XML, JSON, and Properties?

The language server also watches json, xml, yaml, and properties files - primarily to keep its indexes and generated types fresh. Dedicated SFCC metadata XML validation (pipelines, jobs, system/custom objects, site preferences) is covered on its own page.

See XML Validation for validating B2C Commerce metadata before upload.

On this page