How to test my extension's compatibility with different VS code versions?

Viewed 269

I'm building my first VS Code extension based on the helloWorld tutorial.

When you first run yo code it detects latest vs code version and populates package.json:

{
  "engines": {
    "vscode": "^1.47.0"
  }
}

According to the official documentation that is effectively enforcing version check.

However I find it very questionable that the simplest example with no complex api at all would require the latest vs code version.

I'm looking for a source (or tool) to check the actual version requirements of the api methods I'm using in my extension, therefore being able to define the actual engine required.

To illustrate, these are some methods I use. Ideally I'd find out version requirements for each of them.

vscode.commands.executeCommand('editor.action.revealDefinition') // 1.8.0
vscode.commands.executeCommand('workbench.action.acceptSelectedQuickOpenItem') // 1.43.0
vscode.window.showInformationMessage() // 1.18.0

// therefore I need ^1.43.0

PS: Am I overthinking this and could just assume everyone regularly updates vs code?

1 Answers

The usual approach is to develop your extension with the vscode version you have currently. This is then also the minimum version for the extension. That way it is guaranteed your extension is not used with an older version (even if that would work in some situations).

This will then be compatible with any future version of vscode (unless an API is removed or changed in an incompatible way). It's pretty tricky to roll back to an earlier vscode version to test your extension with it, so all you can do is to make it work properly with the current one.

As soon as you use a new feature of a newer vscode version you would then increase the min version for your extension.

Related