Skip to content

New Proposed API checking causes extensions to fail to load when using "import * as vscode" with TypeScript < 3.9 #111913

@mwpenny

Description

@mwpenny
  • VSCode Version: 1.52.0-insiders (5e350b1)
  • OS Version: Windows 10 1809 (OS Build 17763.1518)

Steps to Reproduce:

  1. Create an extension (any sample will do) and use a TypeScript version below 3.9
  2. Somewhere in the extension, use import * as vscode from "vscode"
  3. 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.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugcandidateIssue identified as probable candidate for fixing in the next releaseverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions