ngx-editor: [Bug]: Error: node_modules/ngx-editor/lib/commands/Heading.d.ts:2:10 - error TS2305: Module '"prosemirror-commands"' has no exported member 'type'.

What happened?

On ng build, we are facing the error Module ‘“prosemirror-commands”’ has no exported member ‘type’. import { type Command } from ‘prosemirror-commands’;

Version

v12.4.1

Angular Version

v12.2.5

What browsers are you seeing the problem on?

No response

Link to reproduce

No response

Relevant log output

Error: node_modules/ngx-editor/lib/commands/Heading.d.ts:2:10 - error TS2305: Module '"prosemirror-commands"' has no exported member 'type'.

2 import { type Command } from 'prosemirror-commands';
           ~~~~


Error: node_modules/ngx-editor/lib/commands/Heading.d.ts:2:15 - error TS1005: ',' expected.

2 import { type Command } from 'prosemirror-commands';
                ~~~~~~~


Error: node_modules/ngx-editor/lib/commands/Heading.d.ts:2:15 - error TS2459: Module '"prosemirror-commands"' declares 'Command' locally, but it is not exported.

2 import { type Command } from 'prosemirror-commands';
                ~~~~~~~

  node_modules/prosemirror-commands/dist/index.d.ts:2:10
    2 import { Command } from 'prosemirror-state';
               ~~~~~~~
    'Command' is declared here.


Error: node_modules/ngx-editor/lib/commands/Image.d.ts:1:10 - error TS2305: Module '"prosemirror-state"' has no exported member 'type'.

1 import { type EditorState } from 'prosemirror-state';
           ~~~~


Error: node_modules/ngx-editor/lib/commands/Image.d.ts:1:15 - error TS1005: ',' expected.

1 import { type EditorState } from 'prosemirror-state';
                ~~~~~~~~~~~


Error: node_modules/ngx-editor/lib/commands/Image.d.ts:2:15 - error TS2459: Module '"prosemirror-commands"' declares 'Command' locally, but it is not exported.

2 import type { Command } from 'prosemirror-commands';
                ~~~~~~~

  node_modules/prosemirror-commands/dist/index.d.ts:2:10
    2 import { Command } from 'prosemirror-state';
               ~~~~~~~
    'Command' is declared here.


Error: node_modules/ngx-editor/lib/commands/Link.d.ts:2:10 - error TS2305: Module '"prosemirror-commands"' has no exported member 'type'.

2 import { type Command } from 'prosemirror-commands';
           ~~~~


Error: node_modules/ngx-editor/lib/commands/Link.d.ts:2:15 - error TS1005: ',' expected.

2 import { type Command } from 'prosemirror-commands';
                ~~~~~~~


Error: node_modules/ngx-editor/lib/commands/Link.d.ts:2:15 - error TS2459: Module '"prosemirror-commands"' declares 'Command' locally, but it is not exported.

2 import { type Command } from 'prosemirror-commands';
                ~~~~~~~

  node_modules/prosemirror-commands/dist/index.d.ts:2:10
    2 import { Command } from 'prosemirror-state';
               ~~~~~~~
    'Command' is declared here.


Error: node_modules/ngx-editor/lib/commands/TextAlign.d.ts:2:15 - error TS2459: Module '"prosemirror-commands"' declares 'Command' locally, but it is not exported.

2 import type { Command } from 'prosemirror-commands';
                ~~~~~~~

  node_modules/prosemirror-commands/dist/index.d.ts:2:10
    2 import { Command } from 'prosemirror-state';
               ~~~~~~~
    'Command' is declared here.


Error: node_modules/ngx-editor/lib/commands/types.d.ts:2:10 - error TS2459: Module '"prosemirror-commands"' declares 'Command' locally, but it is not exported.

2 import { Command } from 'prosemirror-commands';
           ~~~~~~~

  node_modules/prosemirror-commands/dist/index.d.ts:2:10
    2 import { Command } from 'prosemirror-state';
               ~~~~~~~
    'Command' is declared here.


Error: node_modules/ngx-editor/lib/defaultPlugins.d.ts:11:90 - error TS2707: Generic type 'Plugin<PluginState>' requires between 0 and 1 type arguments.

11 export declare const getKeyboardShortcuts: (schema: Schema, options: ShortcutOptions) => Plugin<any, any>[];
                                                                                            ~~~~~~~~~~~~~~~~


Error: node_modules/ngx-editor/schema/index.d.ts:2:230m - error TS2315: Type 'Schema' is not generic.

2 declare const schema: Schema<"blockquote" | "image" | "text" | "ordered_list" | "bullet_list" | "list_item" | "doc" | "paragraph" | "horizontal_rule" | "heading" | "hard_break" | "code_block", "link" | "code" | "em" | "s" | "strong" | "u" | "text_color" | "text_background_color">;
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Error: node_modules/ngx-editor/schema/nodes.d.ts:30:24 - error TS2315: Type 'Node' is not generic.

30         toDOM?: (node: ProseMirrorNode<any>) => DOMOutputSpec;
                          ~~~~~~~~~~~~~~~~~~~~


Error: node_modules/ngx-editor/schema/nodes.d.ts:32:32 - error TS2315: Type 'Node' is not generic.

32         toDebugString?: (node: ProseMirrorNode<any>) => string;
                                  ~~~~~~~~~~~~~~~~~~~~


Error: node_modules/ngx-editor/schema/nodes.d.ts:51:24 - error TS2315: Type 'Node' is not generic.

51         toDOM?: (node: ProseMirrorNode<any>) => DOMOutputSpec;
                          ~~~~~~~~~~~~~~~~~~~~


Error: node_modules/ngx-editor/schema/nodes.d.ts:53:32 - error TS2315: Type 'Node' is not generic.

53         toDebugString?: (node: ProseMirrorNode<any>) => string;
                                  ~~~~~~~~~~~~~~~~~~~~


Error: node_modules/ngx-editor/schema/nodes.d.ts:72:24 - error TS2315: Type 'Node' is not generic.

72         toDOM?: (node: ProseMirrorNode<any>) => DOMOutputSpec;
                          ~~~~~~~~~~~~~~~~~~~~


Error: node_modules/ngx-editor/schema/nodes.d.ts:74:32 - error TS2315: Type 'Node' is not generic.

74         toDebugString?: (node: ProseMirrorNode<any>) => string;
                                  ~~~~~~~~~~~~~~~~~~~~


Error: node_modules/prosemirror-model/dist/index.d.ts:1:8 - error TS1259: Module '"C:/Workspace/Temp/12.2.5/test/node_modules/@types/orderedmap/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag

1 import OrderedMap from 'orderedmap';
         ~~~~~~~~~~

  node_modules/@types/orderedmap/index.d.ts:7:1
    7 export = OrderedMap;
      ~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.

Willing to submit a PR?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 44 (17 by maintainers)

Most upvoted comments

Thanks. prose-mirror seems to now have types of their own as they ported to typescript and hence definitely typed packages are not considered. and Command seems to be exported from prosemirror-state now. They should have released in a major. Let me fix this or pin the versions to an older version where it still works.

Yes. issue is with typescript : 4.4.4. Upgrading sorts the issue

Published v13.0.0. It had to be a major version due to the nature of dependency updates. But there are no breaking changes. And pinned all packages to the current version, so these bugs won’t happen again.

Let me know if that works.

And for older version of packages. I am afraid it is not possible to fix them, due to the nature of the change. Please avoid updating the package or deleting the lockfile (which will update transitive dependencies to latest)

We update rxjs version to “~7.5.2”, typeScript to “~4.5.5”. “ngx-editor”: “~13.0.0”, and most of the error dissipated, now we face only this issue:

`Error: node_modules/prosemirror-model/dist/index.d.ts:1:8 - error TS1259: Module '"C:/FL/asset-trax/asset-trax-web/web/node_modules/orderedmap/dist/index-cjs"' can only be default-imported using the 'allowSyntheticDefaultImports' flag

1 import OrderedMap from 'orderedmap';
         ~~~~~~~~~~

  node_modules/orderedmap/dist/index-cjs.d.ts:31:1
    31 export = OrderedMap
       ~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.`

Any ideas?

this happens if the package is updated. Since the newer version and old version of prosemirror have same semver range of orderedmap. It doesn’t gets updated. try re-installing the package or delete lockfile and node_modules and reinstall.

In addition we add in tsconfig.json: “allowSyntheticDefaultImports”: true, “esModuleInterop”: true, Now is working thanks @sibiraj-s:

If you guys using ngx-editor@8.1.1 then you can directly use this zip on local directory & update tsconfig.json,

it will work’s, Working for me now after moving it from node_module to local directory. ngx-editor-8.1.1.zip

We update rxjs version to “~7.5.2”, typeScript to “~4.5.5”. “ngx-editor”: “~13.0.0”, and most of the error dissipated, now we face only this issue:

`Error: node_modules/prosemirror-model/dist/index.d.ts:1:8 - error TS1259: Module '"C:/FL/asset-trax/asset-trax-web/web/node_modules/orderedmap/dist/index-cjs"' can only be default-imported using the 'allowSyntheticDefaultImports' flag

1 import OrderedMap from 'orderedmap';
         ~~~~~~~~~~

  node_modules/orderedmap/dist/index-cjs.d.ts:31:1
    31 export = OrderedMap
       ~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.`

Any ideas?

💋 Updated the rxjs and its building now. thanks for the support bro.

@prajyot-tote what version of rxjs you are using? I have “rxjs”: “~7.5.0”. It works.

./node_modules/ngx-editor/fesm2015/ngx-editor.mjs:1129:36-45 - Error: export ‘takeUntil’ (imported as ‘takeUntil’) was not found in ‘rxjs’ (possible exports: ArgumentOutOfRangeError, AsyncSubject, BehaviorSubject, ConnectableObservable, EMPTY, EmptyError, GroupedObservable, NEVER, Notification, NotificationKind, ObjectUnsubscribedError, Observable, ReplaySubject, Scheduler, Subject, Subscriber, Subscription, TimeoutError, UnsubscriptionError, VirtualAction, VirtualTimeScheduler, animationFrame, animationFrameScheduler, asap, asapScheduler, async, asyncScheduler, bindCallback, bindNodeCallback, combineLatest, concat, config, defer, empty, forkJoin, from, fromEvent, fromEventPattern, generate, identity, iif, interval, isObservable, merge, never, noop, observable, of, onErrorResumeNext, pairs, partition, pipe, queue, queueScheduler, race, range, scheduled, throwError, timer, using, zip)

still getting error with v13.0.0

./node_modules/ngx-editor/fesm2015/ngx-editor.mjs:1129:36-45 - Error: export 'takeUntil' (imported as 'takeUntil') was not found in 'rxjs' (possible exports: ArgumentOutOfRangeError, AsyncSubject, BehaviorSubject, ConnectableObservable, EMPTY, EmptyError, GroupedObservable, NEVER, Notification, NotificationKind, ObjectUnsubscribedError, Observable, ReplaySubject, Scheduler, Subject, Subscriber, Subscription, TimeoutError, UnsubscriptionError, VirtualAction, VirtualTimeScheduler, animationFrame, animationFrameScheduler, asap, asapScheduler, async, asyncScheduler, bindCallback, bindNodeCallback, combineLatest, concat, config, defer, empty, forkJoin, from, fromEvent, fromEventPattern, generate, identity, iif, interval, isObservable, merge, never, noop, observable, of, onErrorResumeNext, pairs, partition, pipe, queue, queueScheduler, race, range, scheduled, throwError, timer, using, zip)

Error: node_modules/ngx-editor/lib/commands/Image.d.ts:1:10 - error TS2300: Duplicate identifier 'type'.

1 import { type EditorState, type Command } from 'prosemirror-state';
           ~~~~


Error: node_modules/ngx-editor/lib/commands/Image.d.ts:1:10 - error TS2305: Module '"prosemirror-state"' has no exported member 'type'.

1 import { type EditorState, type Command } from 'prosemirror-state';
           ~~~~


Error: node_modules/ngx-editor/lib/commands/Image.d.ts:1:15 - error TS1005: ',' expected.

1 import { type EditorState, type Command } from 'prosemirror-state';
                ~~~~~~~~~~~


Error: node_modules/ngx-editor/lib/commands/Image.d.ts:1:28 - error TS2300: Duplicate identifier 'type'.

1 import { type EditorState, type Command } from 'prosemirror-state';
                             ~~~~


Error: node_modules/ngx-editor/lib/commands/Image.d.ts:1:28 - error TS2305: Module '"prosemirror-state"' has no exported member 'type'.

1 import { type EditorState, type Command } from 'prosemirror-state';
                             ~~~~


Error: node_modules/ngx-editor/lib/commands/Image.d.ts:1:33 - error TS1005: ',' expected.

1 import { type EditorState, type Command } from 'prosemirror-state';
                                  ~~~~~~~


Error: node_modules/prosemirror-model/dist/index.d.ts:1:24 - error TS2307: Cannot find module 'orderedmap' or its corresponding type declarations.

1 import OrderedMap from 'orderedmap';

@sibiraj-s ,

Yes, it’s not due to ngx-editor issue, Due to changes of prosemirror-commands library, they removed export of Command, so we got error from ngx-editor, I investigate this issue on my local machine,

Here come to know, there is 2 error’s due to prosemirror-commands library.

1> Command export removed from prosemirror-commands

2> Type 'Schema' is not generic. => Schema export removed from prosemirror-model

If those two error’s got fixed, build will work’s.

Or simply we can change the dependency of prosemirror in ngx-editor will also resolve the error’s

below are needed dependency for resolving those error’s.

"@types/prosemirror-commands": "^1.0.4",
 "@types/prosemirror-history": "^1.0.2",
 "@types/prosemirror-inputrules": "^1.0.4",
 "@types/prosemirror-keymap": "^1.0.4",
 "@types/prosemirror-model": "^1.13.0",
 "@types/prosemirror-schema-list": "^1.0.3",
 "@types/prosemirror-state": "^1.2.6",
 "@types/prosemirror-view": "^1.17.1",
"prosemirror-commands": "^1.1.7",
 "prosemirror-history": "^1.1.3",
 "prosemirror-inputrules": "^1.1.3",
 "prosemirror-keymap": "^1.1.4",
 "prosemirror-model": "^1.13.3",
 "prosemirror-schema-list": "^1.1.4",
 "prosemirror-state": "^1.3.4",
 "prosemirror-view": "^1.18.2",