You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
import type can't be used with interface extends #36478
This is marked "closed," but I am still seeing this issue on TypeScript 3.8.3.
TypeScript Version: 3.8.3
Search Terms: import type
Code
importtype*asmonacofrom"monaco-editor";// Trying to create a subtype of IViewZone that provides// a guarantee that marginDomNode is not null.interfaceMyViewZoneextendsmonaco.editor.IViewZone{marginDomNode: HTMLElement;}
Expected behavior:
This should typecheck.
Actual behavior:
error TS1361: 'monaco' cannot be used as a value because it was imported using 'import type'.
24 interface MyViewZone extends monaco.editor.IViewZone {
~~~~~~
src/zoneManager.ts:5:13
5 import type * as monaco from "monaco-editor";
~~~~~~~~~~~
'monaco' was imported here.
Note that in the same file, I can do:
type ZoneWidget = {
afterLineNumber: number;
zone: monaco.editor.IViewZone;
};
so it is surprising that I can use monaco.editor.IViewZone in one place but not the other.
Playground Link:
Unfortunately, I cannot repro in a playground as I would expect. Perhaps this is something specific to monaco-editor? For example, doing something analogous with the http Node built-in works fine:
Activity
bolinfest commentedon Mar 6, 2020
This is marked "closed," but I am still seeing this issue on TypeScript 3.8.3.
TypeScript Version: 3.8.3
Search Terms: import type
Code
Expected behavior:
This should typecheck.
Actual behavior:
Note that in the same file, I can do:
so it is surprising that I can use
monaco.editor.IViewZonein one place but not the other.Playground Link:
Unfortunately, I cannot repro in a playground as I would expect. Perhaps this is something specific to
monaco-editor? For example, doing something analogous with thehttpNode built-in works fine:https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=5&pc=2#code/JYWwDg9gTgLgBDAnmApnAVHAhgZzgCxhjDgDMoIQ4AiQ46gbgCgngA7GFKUrAYzQCyiAMIAbYCg4AlFAEcArihwwAglADmeFAA9ObACZ46YAHRiJ0uYuVrNcAN5M4zuGAowIvCKIBccZVDs6swAvkA
Related Issues: This one!
bolinfest commentedon Mar 6, 2020
I suspect it has to do with the depth into the namespace? It appears I could do this:
but not this:
bolinfest commentedon Mar 6, 2020
Ah, though as a workaround I can do: