Skip to content

import type cannot be used on classes? #36040

Closed
@Tyriar

Description

@Tyriar

I was excited when I heard about import type as I've been using dynamic imports on a component to save start up time in vscode for some time, however it's very fragile as I only want to import types and not implementation.

When I try to put the import type guard in place I get the following error though:

image

What's happening here is I'm wanting to import an export class definition and only reference it as a type by getting its constructor with typeof. However I'm getting an error that it's being used as a value inside a : type definition?

Terminal definition: https://github.com/xtermjs/xterm.js/blob/1c06e576aea6b1a63dc71d180ae92cc1c6d68c7c/typings/xterm.d.ts#L385
Above usage: https://github.com/microsoft/vscode/blob/81fb34c445098d43d0f25b4e1868ca421022d4de/src/vs/workbench/contrib/terminal/browser/terminalInstanceService.ts#L8-L16

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions