Skip to content
New issue

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

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

Already on GitHub? # to your account

command/CommandHandler.ts import bug #864

Closed
huang-long opened this issue Mar 7, 2024 · 10 comments · Fixed by #927
Closed

command/CommandHandler.ts import bug #864

huang-long opened this issue Mar 7, 2024 · 10 comments · Fixed by #927
Labels
bug Something isn't working pr welcome We rely on a community contribution to improve this. spring cleaning Could be cleaned up one day

Comments

@huang-long
Copy link

huang-long commented Mar 7, 2024

Describe the Bug

TypeScript compiler reports an error if I compile bpmn-js with verbatimModuleSyntax:

[PRJ]/diagram-js/lib/features/outline/OutlineProvider.spec.ts:
    6:10  error   'Element' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled. ​typescript(1484)
    8:8   error   'OutlineProvider' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled. ​typescript(1484)
    8:27  error   'Outline' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled. ​typescript(1484)

Steps to Reproduce

  • Configure verbatimModuleSyntax in tsconfig.json.
  • npm run check-types

Expected Behavior

  • Building works with that setting, too.
@huang-long huang-long added the bug Something isn't working label Mar 7, 2024
@nikku
Copy link
Member

nikku commented Mar 11, 2024

@huang-long What exactly is your feature request?

@nikku nikku added the needs more information Requires additional information to be actionable. label Mar 11, 2024
@huang-long
Copy link
Author

@huang-long What exactly is your feature request?
When I use "diagram-js" in my project, and run "npm run build:prod", typescript checks error in the file "command/CommandHandler.ts", error message: [This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'].
error

@nikku
Copy link
Member

nikku commented Mar 11, 2024

@huang-long I tried to reproduce locally but found that you're using an old (ancient?) TypeScript version (<= 5.0).

Can you reproduce the issue with TypeScript@5?

@huang-long
Copy link
Author

I tried using TypeScript@5.0.4, but got the same error.I read the content of file “/diagram-js/lib/command/CommandHandler.ts”,the module “ElementLike、CommandContext” should be type.
So I modified the file “/diagram-js/lib/command/CommandHandler.ts” as first commented, build success.

import type { ElementLike } from "../core/Types"; import type { CommandContext } from "./CommandStack";

@nikku
Copy link
Member

nikku commented Mar 12, 2024

I believe you have verbatimModuleSyntax enabled, right? Enabling it in diagram-js leads to similar issues during type checking:

[PRJ]/diagram-js/lib/features/outline/OutlineProvider.spec.ts:
    6:10  error   'Element' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled. ​typescript(1484)
    8:8   error   'OutlineProvider' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled. ​typescript(1484)
    8:27  error   'Outline' is a type and must be imported using a type-only import when 'verbatimModuleSyntax' is enabled. ​typescript(1484)

@huang-long
Copy link
Author

No,I did not use this “verbatimModuleSyntax” in the tsconfig.This is my project ruoyi-web-vue3-ts

@nikku
Copy link
Member

nikku commented Mar 13, 2024

You use TypeScript@5 with deprecation warnings disabled, and importNotUsedAsValues. Later versions of @vue/tsconfig enable verbatimModuleSyntax.

We don't support that setting to date, but may investigate how to support it in the future.

@nikku nikku added backlog Queued in backlog spring cleaning Could be cleaned up one day and removed needs more information Requires additional information to be actionable. labels Mar 13, 2024
@huang-long
Copy link
Author

Thanks for answering.

@LoaderB0T
Copy link
Contributor

LoaderB0T commented Aug 19, 2024

We have the same issue after enabling "verbatimModuleSyntax" in our project.
diagram-js seems to be the only dependency that produces these errors in our project and it would be great if the type imports are marked as such in the code.
Would you accept a PR enabling the verbatimModuleSyntax flag in diagram-js's tsconfig file with the fixed imports/exports?

It would be 100% backwards compatible afaik.

@nikku
Copy link
Member

nikku commented Aug 19, 2024

@LoaderB0T Happy to inspect a PR with such a change.

@nikku nikku added the pr welcome We rely on a community contribution to improve this. label Aug 19, 2024
@bpmn-io-tasks bpmn-io-tasks bot removed the backlog Queued in backlog label Aug 19, 2024
@nikku nikku added the needs review Review pending label Aug 19, 2024 — with bpmn-io-tasks
@nikku nikku closed this as completed in e6559b2 Aug 20, 2024
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Aug 20, 2024
ElRaptorus added a commit to 5minds/diagram-js that referenced this issue Feb 4, 2025
# Changes 

Siehe Changelog:
https://github.com/bpmn-io/diagram-js/blob/develop/CHANGELOG.md

## 15.2.4

* `FIX`: canvas `autoFocus` must explicitly be enabled
([bpmn-io#956](bpmn-io#956))
* `FIX`: properly integrate `zoomscroll` with canvas focus
([bpmn-io#956](bpmn-io#956))
* `FIX`: properly integrate `movecanvas` with canvas focus
([bpmn-io#956](bpmn-io#956))

## 15.2.3

* `FIX`: adjust search to prioritize start of word and exact matches
([bpmn-io#953](bpmn-io#953))
* `FIX`: ignore whitespace when searching
([bpmn-io#954](bpmn-io#954))

## 15.2.2

* `FIX`: correct `Keyboard#bind` and config types
([bpmn-io#948](bpmn-io#948))

## 15.2.1

* `FIX`: limit overly permissive regex
([bpmn-io#949](bpmn-io#949))

## 15.2.0

* `FIX`: clear selection when opening search pad
([bpmn-io#947](bpmn-io#947))
* `FIX`: correct dangling selection after search pad interaction
([bpmn-io#947](bpmn-io#947))
* `CHORE`: simplify search pad pre-selection behavior
([bpmn-io#947](bpmn-io#947))

## 15.1.0

* `FEAT`: integrate `popup-menu` with `search`
([bpmn-io#932](bpmn-io#932))
* `FEAT`: recognize modern `search` tokens in `search-pad`
([bpmn-io#932](bpmn-io#932))
* `FEAT`: improve `search` types
([bpmn-io#932](bpmn-io#932))
* `FIX`: correctly handle duplicate entries and whitespace in `search`
([bpmn-io#932](bpmn-io#932))
* `FIX`: find `search` terms across all keys
([bpmn-io#932](bpmn-io#932))
* `FIX`: `search` always returns tokens for matched items
([bpmn-io#932](bpmn-io#932))

## 15.0.0

* `FEAT`: make canvas browser selectable
([bpmn-io#659](bpmn-io#659))
* `FEAT`: make keyboard binding implicit
([bpmn-io#661](bpmn-io#661))
* `FEAT`: make multi-selection outline an outline concern
([bpmn-io#944](bpmn-io#944))

### Breaking Changes

* `Keyboard` binding target can no longer be chosen. Configure keyboard
binding via the `keyboard.bind` configuration and rely on keybindings to
work if the canvas has browser focus.
([bpmn-io#661](bpmn-io#661))
* The `Canvas` is now a focusable component, that is recognized
accordingly by the browser, with all benefits for UX and interaction.
Components that pull focus from the `Canvas` during modeling must ensure
to restore the focus (if intended), via `Canvas#restoreFocus`.
([bpmn-io#661](bpmn-io#661))
* The `selection` feature does not provide visual outline by default
anymore. Use the `outline` feature to re-enable it.
([bpmn-io#944](bpmn-io#944))

## 14.11.3

* `CHORE`: simplify viewbox cloning
([bpmn-io#935](bpmn-io#935))

## 14.11.2

* `FIX`: restore search result highlight
([bpmn-io#931](bpmn-io#931))
* `FIX`: correct search result highlight not being removed
([bpmn-io#931](bpmn-io#931))
* `FIX`: do not change zoom when search openes
([bpmn-io#931](bpmn-io#931))

## 14.11.1

_Partially reverts v14.11.0._

* `FIX`: revert `search` integration into popup menu

## 14.11.0

* `FEAT`: add `search` utility
* `FEAT`: sort popup entry search results semantically
([bpmn-io#916](bpmn-io#916))

## 14.10.0

* `FEAT`: align search styling with other popups
([bpmn-io#913](bpmn-io#913))
* `CHORE`: use existing outline in search
([bpmn-io#913](bpmn-io#913))
* `FIX`: only commit search viewport changes on `ENTER`
([bpmn-io#913](bpmn-io#913))

## 14.9.0

* `CHORE`: export types compatible with `verbatimModuleSyntax`
([bpmn-io#927](bpmn-io#927),
[bpmn-io#864](bpmn-io#864))
* `CHORE`: re-compute context pad position next frame
([bpmn-io#920](bpmn-io#920))
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working pr welcome We rely on a community contribution to improve this. spring cleaning Could be cleaned up one day
Projects
None yet
3 participants