最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Quill 2 - Use typescript imports or Quill.import()? - Stack Overflow

programmeradmin1浏览0评论

I am in the process of upgrading my project from Quill v1 to v2.

Quill now has typescript type definitions and I don't know if I should keep using the static Quill.import() method or if I should import the types instead, which also provides strong typing.

The documentation examples still use Quill.import() in some cases, for example parchment blot extensions but I don't know if this has just not been updated.

Also, the documentation for the import methods has got the following footnote, which is what initially made me unsure about the type imports as it mentions side effects:

Note
Don't confuse this with the import keyword for ECMAScript modules. 
Quill.import() doesn't load scripts over the network,
it just returns the corresponding module from the Quill library without
causing any side-effects.

Quill docs

I currently have:

const Tooltip = Quill.import('ui/tooltip');

const quillTooltip = new Tooltip(this.quill) as any;

but now I could do:

import Tooltip from 'quill/ui/tooltip';
...
const quillTooltip = new Tooltip(this.quill);

Is there an officially preferred way out of the two? Are there any pitfalls using the import keyword?

Thank you.

发布评论

评论列表(0)

  1. 暂无评论