Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use in typescript project #785

Open
ColinFrick opened this issue Sep 21, 2022 · 3 comments
Open

Unable to use in typescript project #785

ColinFrick opened this issue Sep 21, 2022 · 3 comments

Comments

@ColinFrick
Copy link

I'm currently evaluating different wysiwyg editor projects (Slate, Quill, Tiptap) and I wanted to check mobile doc out.

Sadly I get following errors when trying to use it:

Error: node_modules/mobiledoc-kit/dist/mobiledoc.d.ts:406:9 - error TS2611: 'isBlank' is defined as a property in class '{ _tagName: string | null; tagName: string; isValidTagName(normalizedTagName: string): boolean; type: Type; isSection: boolean; isMarkerable: boolean; isNested: boolean; isListItem: boolean; ... 20 more ...; prev: any; }', but is overridden here in 'Markerable' as an accessor.

406     get isBlank(): boolean;
            ~~~~~~~


Error: node_modules/mobiledoc-kit/dist/mobiledoc.d.ts:437:9 - error TS2611: 'length' is defined as a property in class '{ _tagName: string | null; tagName: string; isValidTagName(normalizedTagName: string): boolean; type: Type; isSection: boolean; isMarkerable: boolean; isNested: boolean; isListItem: boolean; ... 20 more ...; prev: any; }', but is overridden here in 'Markerable' as an accessor.

437     get length(): number;
            ~~~~~~


Error: node_modules/mobiledoc-kit/dist/mobiledoc.d.ts:515:9 - error TS2611: 'post' is defined as a property in class 'Markerable', but is overridden here in 'ListItem' as an accessor.

515     get post(): Option<Post> | undefined;
            ~~~~


Error: node_modules/mobiledoc-kit/dist/mobiledoc.d.ts:562:9 - error TS2611: 'isBlank' is defined as a property in class '{ _tagName: string | null; tagName: string; isValidTagName(normalizedTagName: string): boolean; type: Type; isSection: boolean; isMarkerable: boolean; isNested: boolean; isListItem: boolean; ... 20 more ...; prev: any; } & Attributable', but is overridden here in 'ListSection' as an accessor.

562     get isBlank(): boolean;
            ~~~~~~~

I'm using typescript 4.8.3

@gpoitch
Copy link
Member

gpoitch commented Sep 21, 2022

You can add "skipLibCheck": true to tsconfig so you aren't type checking dependencies. We just released the type declarations so they may not be perfect yet. Will look into why these errors are occurring.

@royemosby
Copy link

Same issue and same output when trying import {DOMParser} from 'mobiledoc-kit'

@vjonesmuth
Copy link

I'm also seeing this issue in a typescript node application that is using ESM. I'm trying to do
import { DOMParser, PostNodeBuilder, Renderer } from 'mobiledoc-kit';

But I get the following error:

(node:15254) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
...
export { DOMParser, Editor, MobiledocError as Error, ImageCard$2 as ImageCard, MOBILEDOC_VERSION$2 as MOBILEDOC_VERSION, Markup, Position, PostNodeBuilder, Range, MobiledocRenderer as Renderer, ui as UI };
^^^^^^

SyntaxError: Unexpected token 'export'

I believe we need to add "type": "module" to the package.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants