-
Notifications
You must be signed in to change notification settings - Fork 34.5k
Description
- VSCode Version: 1.52.0-insiders (5e350b1)
- OS Version: Windows 10 1809 (OS Build 17763.1518)
Steps to Reproduce:
- Create an extension (any sample will do) and use a TypeScript version below 3.9
- Somewhere in the extension, use
import * as vscode from "vscode"
- Try to load the extension. It will fail with the "Proposed API is only available..." error
Does this issue occur when all extensions are disabled?: Yes
Note that this only happens on insiders.
Recent changes (c219b06) cause problems for extensions built with old versions of TypeScript (< 3.9). With these old versions
import * as vscode from "vscode"
gets emitted as:
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; // Problem
result["default"] = mod;
return result;
};
const vscode = __importStar(require("vscode"));
The line with my added "problem" comment will trigger some getters which include checkProposedApiEnabled()
and cause the extension to fail to load with the "Proposed API is only available..." error even though it may never access the relevant properties. Later versions of TypeScript use a getter to defer property access and this isn't a problem.
Technically, I'd call this a TypeScript/tslib bug and not a VSCode bug. It's fixed in later versions of TypeScript (or worked around by changing the imports to import vscode from "vscode"
), but I figured you'd like to be made aware since this could cause problems for a number of existing extensions.