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

Type of Editor.ui not resolvable with Yarn (strict) PnP mode #17213

Open
jnoordsij opened this issue Oct 3, 2024 · 2 comments
Open

Type of Editor.ui not resolvable with Yarn (strict) PnP mode #17213

jnoordsij opened this issue Oct 3, 2024 · 2 comments
Assignees
Labels
type:bug This issue reports a buggy (incorrect) behavior.

Comments

@jnoordsij
Copy link

jnoordsij commented Oct 3, 2024

📝 Provide detailed reproduction steps (if any)

  1. Setup a project with TypeScript + Yarn PnP (default strict mode)
  2. Create a plugin file along the lines of
import {Plugin} from 'ckeditor5';

export default class FooUI extends Plugin {
  init() {
    this.editor.ui.componentFactory.add('addFoo', (locale) => {
      ...
  }
}
  1. Run tsc to check types

✔️ Expected result

The type of this.editor.ui to be resolved correctly, so that consequently the type of locale in the componentFactory.add call can be inferred.

❌ Actual result

The type of this.editor.ui.componentFactory is marked as any yielding an error Parameter 'locale' implicitly has an 'any' type.ts(7006).

❓ Possible solution

This issue only appears with Yarn PnP mode, as the import import type { EditorUI } from '@ckeditor/ckeditor5-ui'; within the ckeditor5-core cannot be resolved, since the package is not listed as dependency in ckeditor5-core. To make this resolvable, the @ckeditor/ckeditor5-ui should be listed as dependency, peerDependency or optional peerDependency in the ckeditor5-core, with the last one probably being the best option.

Manual workarounds:

  • import the type EditorUI and manually cast with (this.editor.ui as EditorUI)
  • use pnpMode: loose or non-pnp mode with Yarn

📃 Other details

  • Browser: N/A
  • OS: N/A
  • First affected CKEditor version: 42.0.0 (possibly earlier); edit: still observed on 43.2.0
  • Installed CKEditor plugins: N/A

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@jnoordsij jnoordsij added the type:bug This issue reports a buggy (incorrect) behavior. label Oct 3, 2024
@Witoso
Copy link
Member

Witoso commented Oct 3, 2024

Resolved in v42.0.2, please verify :)

@Witoso Witoso added the pending:feedback This issue is blocked by necessary feedback. label Oct 3, 2024
@jnoordsij
Copy link
Author

I'm currently running into this issue on the latest version (43.2.0).

@filipsobol filipsobol self-assigned this Oct 3, 2024
@CKEditorBot CKEditorBot removed the pending:feedback This issue is blocked by necessary feedback. label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

4 participants