React-quill: types.d.ts exports ReactQuill incorrectly

Created on 4 Apr 2018  路  6Comments  路  Source: zenoamaro/react-quill

React-Quill version

  • [x] 1.2.7

Hi there,

I haven't used ReactQuill before so I can't speak to whether this was working previously or not but I just pulled it down and in typescript am getting the following error:

TS1192: Module '"projectroot/node_modules/react-quill/types"' has no default export.

I am importing it like so

import ReactQuill from 'react-quill';

I am noticing @clinyong made the change the other day from

export default class Component extends React.Component<ComponentProps> {
    focus(): void;
    blur(): void;
    getEditor(): Quill.Quill;
}

to

declare class ReactQuill extends React.Component<ReactQuill.ComponentProps> {
    focus(): void;
    blur(): void;
    getEditor(): Quill.Quill;
}

export = ReactQuill;

When you do export = ReactQuilll, ts doesn't treat it as default. You can fix this by saying

export default ReactQuill

on line 94 - https://github.com/zenoamaro/react-quill/blame/master/types.d.ts#L94

I can make a pr if you guys want but one of the contributors can probably do it faster than me pulling everything down. Let me know.

Cheers,

Igor

Most helpful comment

I can import ReactQuill, but I can't import UnprivilegedEditor, so I can' t add types to my event handlers. Only Quill shows up as a non-default export.

All 6 comments

Just as an update, I tried a couple of different approaches and the way the d.ts file is now _will_ work if you import it like so:

import * as ReactQuill from 'react-quill';

which is perfectly reasonable as long as your README is consistent with that, which it's not - https://github.com/zenoamaro/react-quill#import-the-component

Igor

In TS, you should not import ReactQuill as default, you can import in two ways

import * as ReactQuill from 'react-quill';
import ReactQuill = require('react-quill');

You can see the TS doc here.

And also maybe we can update README for TS...

Right - that's what I meant by my second comment.

I can import ReactQuill, but I can't import UnprivilegedEditor, so I can' t add types to my event handlers. Only Quill shows up as a non-default export.

@patrick-jones applying this patch should fix your typing issue: https://github.com/zenoamaro/react-quill/pull/433

@alexkrolick can you take a look?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexkrolick picture alexkrolick  路  4Comments

Nazanin1369 picture Nazanin1369  路  4Comments

prosenjitchy picture prosenjitchy  路  3Comments

andylacko picture andylacko  路  5Comments

mtando picture mtando  路  5Comments