Cannot use namespace 'TuiEditor' as a type

1.1k Views Asked by At

I have searched the generic error I am getting ('Cannot use namespace x as a type.') and I can't seem to match my error up with others' examples.

I have an Ionic3/Angular6 application where I have the ngx-tui-editor npm package installed so I can have a markdown editor in my app.

Everything was working fine all morning. I was able to see the editor come up just fine, I could interact with it, get/set markdown content, etc. Then, after a random refresh as I was setting this all up into a form, I started getting the above error.

The thing is, the error is referencing this code block (middle line):

options: object;
editor: TuiEditor;
constructor(editorService: TuiService);

in the /node_modules/ngx-tui-editor/tui-editor.component.d.ts file.

What do I need to do here to satisfy this error? I have npm ied, npm updated, rebuilt, hard refreshed, restarted everything, and it just keeps coming up now.

Edit Yes, the import statement for this is import * as TuiEditor from 'tui-editor'; just grabbing everything. The index.d.ts file under tui-editor does have declare namespace tuiEditor with the brunt of the code it appears. The interesting thing at the top of that file are two comments:

// Type definitions for TOAST UI Editor v1.3.1

// TypeScript Version: 3.2.2

I believe we are on TypeScript 3.9.2, but I dont know if that is where the issue lies.

1

There are 1 best solutions below

0
On

For anyone else getting this issue, we were able to eliminate this error by declaring editor: TuiEditor.default as type. I submitted a PR to package creator.