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

Improve typings #5192

Merged
merged 3 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ cmp.addType(...);
* `component:drag:start` - Component drag started. Passed an object, to the callback, containing the `target` (component to drag), `parent` (parent of the component) and `index` (component index in the parent)
* `component:drag` - During component drag. Passed the same object as in `component:drag:start` event, but in this case, `parent` and `index` are updated by the current pointer
* `component:drag:end` - Component drag ended. Passed the same object as in `component:drag:start` event, but in this case, `parent` and `index` are updated by the final pointer
* `component:resize` - During component resize.

## Methods

Expand Down
3 changes: 2 additions & 1 deletion src/dom_components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ export type ComponentEvent =
| 'component:type:update'
| 'component:drag:start'
| 'component:drag'
| 'component:drag:end';
| 'component:drag:end'
| 'component:resize';

export interface ComponentModelDefinition extends IComponent {
defaults?: ComponentDefinitionDefined;
Expand Down
6 changes: 3 additions & 3 deletions src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import ComponentManager, { ComponentEvent } from '../dom_components';
import Component from '../dom_components/model/Component';
import Components from '../dom_components/model/Components';
import ComponentWrapper from '../dom_components/model/ComponentWrapper';
import { DragMode } from '../dom_components/model/types';
import { ComponentDefinition, DragMode } from '../dom_components/model/types';
import I18nModule from '../i18n';
import KeymapsModule, { KeymapEvent } from '../keymaps';
import ModalModule, { ModalEvent } from '../modal_dialog';
Expand Down Expand Up @@ -320,7 +320,7 @@ export default class Editor implements IBaseModule<EditorConfig> {
* content: 'New component'
* });
*/
setComponents(components: any, opt: any = {}) {
setComponents(components: string | ComponentDefinition, opt: any = {}) {
this.em.setComponents(components, opt);
return this;
}
Expand All @@ -342,7 +342,7 @@ export default class Editor implements IBaseModule<EditorConfig> {
* content: 'New component'
* });
*/
addComponents(components: any, opts?: any): Component[] {
addComponents(components: string | ComponentDefinition, opts?: any): Component[] {
return this.getWrapper()!.append(components, opts);
}

Expand Down
2 changes: 1 addition & 1 deletion src/storage_manager/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface StorageManagerConfig {
* Available by default: 'local' | 'remote'
* @default 'local'
*/
type?: string;
type?: 'local' | 'remote';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll replace this with LiteralUnion<'local' | 'remote', string> as the type could be a custom name


/**
* Enable/disable autosaving.
Expand Down
2 changes: 1 addition & 1 deletion src/storage_manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class StorageManager extends Module<
constructor(em: EditorModel) {
super(em, 'StorageManager', defaults);
const { config } = this;
if (config._disable) config.type = '';
if (config._disable) config.type = undefined;
this.storages = {};
this.add(STORAGE_LOCAL, new LocalStorage());
this.add(STORAGE_REMOTE, new RemoteStorage());
Expand Down