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

[TS] Fix importing module augmentations #13433

Closed
arkflpc opened this issue Feb 8, 2023 · 0 comments · Fixed by #13435
Closed

[TS] Fix importing module augmentations #13433

arkflpc opened this issue Feb 8, 2023 · 0 comments · Fixed by #13435
Assignees
Labels
domain:ts squad:core Issue to be handled by the Core team. type:task This issue reports a chore (non-production change) and other types of "todos".

Comments

@arkflpc
Copy link
Contributor

arkflpc commented Feb 8, 2023

We use module augmentation for adding properties to interfaces from ckeditor5-core with information provided by other packages:

  • EditorConfig - plugin-specific config is added there,
  • PluginsMap - it enables editor.plugins.get() to provide specific return type based on plugin name,
  • CommandsMap - it enables editor.commands.get() to provide specific return type based on command name and also checks the parameters of editor.execute().

Return types are correctly provided at each call-site ({config,plugins,commands}.get()) only when the file with the proper declare module '@ckeditor/ckeditor5-core' is imported.
However, it's not always imported directly, and the results are not-consistent. Visual Studio Code usually sees those augmentations and reports no error. But, when running automatic tests, the compilation fails randomly with TypeScript emitted no output error.

Let's make sure that every augmentation is directly and explicitly imported:

  1. Whenever there is plugin.get(), the type of the plugin is imported. Make sure that PluginsMap is augmented in the same file as plugin class.
  2. Whenever there is commands.get(), the type of the command is imported. Make sure that CommandsMap is augmented in the same file as command class.
  3. Whenever there is config.get(), the plugin config should be imported. Ideally, the config should be in a single file like ckeditor5-mypackage/src/mypackageconfig.ts.
@arkflpc arkflpc added squad:core Issue to be handled by the Core team. domain:ts type:task This issue reports a chore (non-production change) and other types of "todos". labels Feb 8, 2023
@arkflpc arkflpc self-assigned this Feb 8, 2023
@CKEditorBot CKEditorBot added the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Feb 8, 2023
arkflpc added a commit that referenced this issue Feb 13, 2023
Internal: Fixes imports of declare module. Closes #13433.
@CKEditorBot CKEditorBot removed the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Feb 13, 2023
@CKEditorBot CKEditorBot added this to the iteration 61 milestone Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:ts squad:core Issue to be handled by the Core team. type:task This issue reports a chore (non-production change) and other types of "todos".
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants