Skip to content

refactor: Migrate JavaScript files to TypeScript#1223

Merged
hexqi merged 7 commits intoopentiny:developfrom
gene9831:refactor/js-to-ts
Mar 20, 2025
Merged

refactor: Migrate JavaScript files to TypeScript#1223
hexqi merged 7 commits intoopentiny:developfrom
gene9831:refactor/js-to-ts

Conversation

@gene9831
Copy link
Collaborator

@gene9831 gene9831 commented Mar 18, 2025

【注意】由于改动文件太多,这个PR需要等待其他2.4版本PR先合入

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

将多个模块的js文件迁移到ts文件,vue文件添加lang="ts"。以下模块或目录除外:

  • @opentiny/tiny-engine
  • @opentiny/tiny-engine-webcomponent-core
  • @opentiny/tiny-engine-common/js

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Refactor

    • Migrated numerous modules and components to TypeScript for improved type safety and maintainability.
    • Enhanced build configurations to support dynamic filename generation and streamlined module resolution.
  • Chore

    • Updated internal references, variable declarations, and type annotations for improved robustness and clarity.

These internal improvements boost overall code stability and developer efficiency without altering any end-user functionality.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2025

Walkthrough

The pull request performs a widespread migration from JavaScript to TypeScript. It updates module path mappings (e.g., in jsconfig.json), converts many Vue components to use TypeScript via added lang="ts" attributes and refined prop/method signatures, and adds explicit type annotations in utility and composable files. Additionally, several Vite configurations across multiple packages have been updated to use TypeScript entry points and dynamic filename generation. Deprecated JS entry files have been removed or replaced with their TS counterparts, and hook management code has been restructured accordingly.

Changes

File(s) Change Summary
jsconfig.json Updated path mappings for @opentiny/tiny-engine-canvas and @opentiny/tiny-engine-utils, removing the .js extension for improved module resolution.
packages/build/vite-config/src/vite-plugins/devAliasPlugin.js Modified alias paths to reference .ts files instead of .js files.
packages/{builtinComponent, common, canvas, i18n, layout, svgs, toolbars,...}/*.vue Added lang="ts" to <script> tags and updated prop types and method signatures to enforce TypeScript type safety in Vue components.
packages/{builtinComponent, canvas, common, i18n, register, settings}/**/*.ts Enhanced code by adding explicit TypeScript type annotations for function parameters, return types, and exported entities across utilities, composables, and services.
packages/{builtinComponent, canvas, common, configurator, i18n, layout, svgs, theme, toolbars, settings}/vite.config.ts Updated Vite config files to change entry points from .js to .ts and implemented dynamic fileName functions for flexible output naming.
packages/canvas/common/index.js (removed) & corresponding HTML files Removed legacy JS entry file and updated HTML script references to load TypeScript modules.
packages/register/{hooks.js (removed), hooks.ts} and related register files Refactored hook management and registry modules with comprehensive TypeScript annotations, replacing outdated JavaScript implementations.

Suggested labels

refactor-main, ready_for_review

Suggested reviewers

  • hexqi
  • chilingling
  • rhlin

Poem

I’m a little bunny hopping in the code,
TypeScript carrots lining every road.
From JS to TS, each file is so spry,
Dynamic names and safe types make bugs say goodbye!
With a twitch of my nose, I cheer these updates high 🐇✨
Happy coding, let the clean refactors fly!

Enjoy the garden of improved code!


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gene9831 gene9831 changed the title Refactor/js to ts refactor: /js to ts Mar 18, 2025
@gene9831 gene9831 changed the title refactor: /js to ts refactor: refactor project to typescript Mar 18, 2025
@gene9831 gene9831 changed the title refactor: refactor project to typescript refactor: Migrate JavaScript files to TypeScript Mar 18, 2025
@gene9831 gene9831 marked this pull request as ready for review March 18, 2025 08:29
@gene9831 gene9831 force-pushed the refactor/js-to-ts branch from 3693d78 to fddbc58 Compare March 18, 2025 08:31
@gene9831 gene9831 added this to the v2.4.0 milestone Mar 18, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (70)
packages/i18n/src/i18n.ts (1)

24-24: Replace any with a stricter type if possible.
A well-defined type clarifies usage and reduces runtime errors.

packages/i18n/src/test/TestVueInject.vue (1)

15-15: Refine the generic type
Using any defeats part of TypeScript’s benefit. Consider providing an explicit interface or type for better type-checking.

packages/i18n/src/test/TestWebcomponent.vue (1)

15-15: Type specification
Replacing any with a typed interface would leverage TypeScript’s strengths.

packages/layout/src/DesignPlugins.vue (1)

100-102: Consider more specific typing instead of any.

Using any undermines type safety and might cause missed errors. Consider defining explicit interface(s) or using more precise types.

packages/toolbars/breadcrumb/src/composable/useBreadcrumb.ts (2)

15-15: Ref with any[].

Consider using a more specific type if possible to better describe the array’s items.


26-26: Generic any parameter.

Using any for the parameter can hide potential mistypings. A more specific type would be beneficial.

packages/common/composable/generateCode/index.ts (2)

27-27: Avoid ...args: any[] if possible.

Consider using more explicit parameters for clarity and consistency.


38-64: Leverage more specific types.

Widespread any usage in getAllNestedBlocksSchema can hide errors. Define custom interfaces to better describe pageSchema and related objects.

packages/settings/design/src/convertToSchema.ts (2)

53-53: Rename function for clarity
getWidgetCompoent could be renamed to getWidgetComponent. The parameter type any might be replaced with a more specific type if feasible.


67-67: Prefer narrower types over any
Instead of const props: any = {}, consider using an interface or a typed object if possible.

packages/canvas/common/src/utils.ts (3)

31-31: Verify the array type
(node: any[]) might be replaced with generics like <T> (node: T[]).


64-64: Narrow the parameter type
({ pkg, script }: any) is workable, but consider more precise types if known.


90-90: Parameter destructuring
({ package: pkg, script, components }: any) is correct but might benefit from a custom interface to reflect the expected structure.

packages/common/composable/defaultGlobalService.ts (9)

24-24: Avoid using any if possible
Replace null as any with a more suitable user info type if known.


42-42: App list typing
[] as any[] ensures a typed array, but define the item shape if feasible.


63-63: Parameter data: any
If the structure of data is known, define an interface.


74-74: Casting
{} as Record<string, any> is workable. Try to define a more precise shape if possible.


78-78: Any usage
const changedParams: any could be refined.


101-101: Use typed param
(params: any, replace = false) is workable, but specifying a shape for params is recommended.


180-180: Await type
(app: any) might be narrower if the shape is known.


197-197: List item type
(list: any[]) is functional, but a typed interface would help.


203-203: Narrow user info
(data: any) might be typed if the structure is known.

packages/settings/styles/src/js/parser.ts (3)

3-32: Use of “any” as a fallback type.

The type annotation (node: any) clarifies method parameters but consider using more specific types if available to improve type safety.


34-48: Consistent type usage.

Same comment applies: consider a more specialized type instead of any for at-rules nodes.


212-276: Explicit typing for stringify.

Using any for config objects is acceptable as a transitional measure. Encouraged to refine if possible.

packages/settings/styles/src/js/useStyle.ts (2)

96-108: parseClassOrIdProps typed.

Clearer, but consider narrower types than any for propValue. No immediate issues.


295-339: updateStyle parameter typed.

Using properties: any is acceptable for now; consider a stricter shape if known.

packages/common/component/MetaPopover.vue (1)

14-14: Consider using Vue’s defineComponent for improved type inference.

Switching to TypeScript in Vue is a great start. For stronger typing and better editor support, consider wrapping your default export in defineComponent().

packages/common/component/CloseIcon.vue (1)

8-8: Adopt defineComponent for better typing.

Switching to TypeScript on this component is helpful. Consider using defineComponent() to leverage full TypeScript benefits in Vue.

packages/canvas/render/src/builtin/CanvasIcon.vue (1)

1-1: Leverage defineComponent for full TS support.

Enabling TypeScript is a great step. Consistently wrapping the exported object in defineComponent() can further improve type checking across the component.

packages/canvas/render/src/builtin/CanvasSlot.vue (1)

7-7: Enhance type safety with defineComponent.

Including lang="ts" is an excellent start. Importing and using defineComponent() can further boost type safety and editor support.

packages/common/component/LinkButton.vue (1)

7-7: Consider adding explicit prop types.
With lang="ts", you can extend type safety by defining explicit interfaces for props and the component.

packages/common/component/ConfigCollapse.vue (1)

11-11: Maximize TypeScript benefits.
Think about introducing stricter typings for inputs, such as defining an interface for the “title” prop, to catch possible usage errors early.

packages/canvas/render/src/builtin/CanvasText.vue (1)

5-5: Enhance type safety for props.
Now that TypeScript is enabled, consider introducing a dedicated interface for your “text” and “className” props to ensure strict type checks.

packages/common/component/MaskModal.vue (1)

9-9: Leverage TypeScript for clarity.
Consider declaring the “visible” prop type more explicitly in composition, and annotate the computed property for better IDE support.

packages/common/component/MetaListActions.vue (1)

23-23: Use a more specific parameter type than any.
Defining a narrower type improves maintainability and reduces potential runtime errors.

packages/svgs/index.ts (1)

15-15: Refine the app parameter type further.
Using the Vue App type in place of Record<string, any> enhances maintainability and clarity.

packages/common/component/MetaChildItem.vue (1)

78-78: Refine parameter types if possible.
(property: any, data: any) may benefit from more specialized types to prevent unintended misuse.

packages/common/component/CanvasDragItem.vue (1)

21-21: Consider narrowing the event type.
(e: any) could be (e: DragEvent) or similar, providing stronger type safety.

packages/common/component/MetaModalItem.vue (1)

69-69: Consider refining the 'any' type in the save function.

Replacing any with a more specific type could improve type safety and maintainability.

packages/common/component/BlockDescription.vue (1)

25-25: Enhance the type definition for the api parameter if possible.

Defining a more precise type for item instead of any can help catch errors earlier.

packages/register/src/useMessage.ts (2)

13-13: Consider using a more specific type instead of any.

Using any masks potential type errors. A narrower type or a union type would improve type safety.


14-14: Narrow the subscriber values' type if feasible.

Record<string, any> is valid, but providing a more explicit definition for subscriber data can enhance clarity.

packages/register/src/templateHash.ts (1)

24-24: Avoid relying on any if possible.

Consider a more exact type signature for component and metaData to leverage stronger checking.

packages/builtinComponent/src/components/CanvasCol.vue (1)

46-47: Using 'any' in getFlex.
Consider adding a clearer interface for stronger type safety.

packages/common/component/MetaCodeEditor.vue (2)

145-145: Ref typed as any.
Consider providing a more precise type for stronger safety.


186-186: Error type set to any.
This is acceptable, though narrower types might increase clarity.

packages/common/component/MetaListItem.vue (1)

129-129: Use of any for reactive fields and function parameters.
Defining an interface might improve clarity and maintainability.

Also applies to: 145-145, 189-189

packages/common/component/MonacoEditor.vue (1)

85-85: Ref typed as 'any'.
Consider defining a more specific type for better code clarity, though this is acceptable for flexible usage.

packages/register/src/entryHash.ts (2)

39-39: mergeRegistry parameters typed as any.
Works for flexible merging logic, but narrower types could reduce risk of runtime errors.


78-78: defineEntry parameter typed as any.
Consider a stricter type if registry has a known interface.

packages/common/component/BlockDeployDialog.vue (1)

206-206: changeCompare param typed as any.
Flexible approach for dynamic usage; consider stricter typing if data shape is known.

packages/register/src/service.ts (1)

33-77: Check reactive<any> usage.
While the generics for defineService are solid, consider replacing reactive<any> with a more explicit type if possible, for added maintainability. Otherwise, this implementation is consistent with the new TypeScript definitions.

packages/common/component/BindI18n.vue (4)

89-91: Consider more specific types than any.
Using ref<any> and reactive<any> helps but restricts type-checking. If possible, define more detailed interfaces for selectRef or editForm data.


97-97: Declare param type with any[].
This array usage is clear, but refining the item shape could provide better readability long term.


109-114: Typed filter logic.
(value: any) and local item: any maintain broad flexibility, though narrower types can catch more errors at compile time.


140-140: Use of Record<string, any> is a decent step.
Still, narrower definitions can better reflect actual structure.

packages/common/component/MultiTypeSelector.vue (3)

55-55: Refined function signature.
(types: string[], value: any) clarifies expected arguments, though consider specifying the shape of value if known.


93-99: Strong typing on change.
(val: any[]) is broad, but an improvement from untyped usage.


101-109: Param types for handleChange.
index: string | number and val: any are a step up from leaving them untyped. Consider further specificity if possible.

packages/settings/design/src/store/index.ts (5)

17-18: genTreeData with typed parameters.
(properties: any[], keys: string[] = []) is more explicit. Consider using domain-specific object types for stronger constraints.


156-168: removeGroup typed as (group: any).
Basic coverage is fine. If feasible, specify a shape for group to improve code discoverability.


188-216: addProperty with structured param.
(group: { content: any[] }, prop: string | number, index = 0) clarifies usage, though a stronger interface for content may help.


234-236: setCurrentGroup.
(group: any) is a small improvement but consider dedicated interface for group.


242-251: setCurrentProperty (property: any).
Use an interface to better define the property shape for clarity and maintainability.

packages/common/component/VueMonaco.vue (2)

72-72: Parameter monaco typed as any
Consider refining the monaco type for improved editor-specific safety if possible.


103-103: Event typed as any
If event details are known (e.g., monaco.editor.IModelContentChangedEvent), using a more specific type can improve readability.

packages/register/src/hooks.ts (1)

45-50: getHook utility function
This delegator pattern is straightforward. Consider handling unknown hook names with a warning or fallback.

packages/common/component/ConfigItem.vue (1)

181-181: Typed editorModalRef as ref<any>
If feasible, refine the any type for better editor modal clarity.

packages/register/src/common.ts (1)

82-101: handleVueLifeCycle typed id and value
Iterating over known Vue lifecycle hooks is correct; consider verifying unrecognized hooks.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13e7f96 and fddbc58.

📒 Files selected for processing (107)
  • jsconfig.json (2 hunks)
  • packages/build/vite-config/src/vite-plugins/devAliasPlugin.js (2 hunks)
  • packages/builtinComponent/src/components/CanvasCol.vue (4 hunks)
  • packages/builtinComponent/src/components/CanvasFlexBox.vue (1 hunks)
  • packages/builtinComponent/src/components/CanvasRow.vue (1 hunks)
  • packages/builtinComponent/src/components/CanvasRowColContainer.vue (1 hunks)
  • packages/builtinComponent/src/components/helper.ts (3 hunks)
  • packages/builtinComponent/vite.config.ts (1 hunks)
  • packages/canvas/DesignCanvas/src/api/useCanvas.ts (1 hunks)
  • packages/canvas/canvas.html (1 hunks)
  • packages/canvas/common/index.js (0 hunks)
  • packages/canvas/common/index.ts (1 hunks)
  • packages/canvas/common/src/utils.ts (5 hunks)
  • packages/canvas/container/src/keyboard.ts (2 hunks)
  • packages/canvas/index.html (1 hunks)
  • packages/canvas/render/src/builtin/CanvasCollection.vue (1 hunks)
  • packages/canvas/render/src/builtin/CanvasIcon.vue (1 hunks)
  • packages/canvas/render/src/builtin/CanvasImg.vue (1 hunks)
  • packages/canvas/render/src/builtin/CanvasPlaceholder.vue (1 hunks)
  • packages/canvas/render/src/builtin/CanvasRouterView.vue (1 hunks)
  • packages/canvas/render/src/builtin/CanvasSlot.vue (1 hunks)
  • packages/canvas/render/src/builtin/CanvasText.vue (1 hunks)
  • packages/canvas/vite.config.ts (1 hunks)
  • packages/common/component/BindI18n.vue (4 hunks)
  • packages/common/component/BlockDeployDialog.vue (6 hunks)
  • packages/common/component/BlockDescription.vue (2 hunks)
  • packages/common/component/BlockHistoryList.vue (1 hunks)
  • packages/common/component/CanvasDragItem.vue (2 hunks)
  • packages/common/component/CloseIcon.vue (1 hunks)
  • packages/common/component/ConfigCollapse.vue (1 hunks)
  • packages/common/component/ConfigItem.vue (8 hunks)
  • packages/common/component/ConfigRender.vue (3 hunks)
  • packages/common/component/EmptyTip.vue (1 hunks)
  • packages/common/component/I18nInput.vue (2 hunks)
  • packages/common/component/LinkButton.vue (1 hunks)
  • packages/common/component/MaskModal.vue (1 hunks)
  • packages/common/component/MetaChildItem.vue (2 hunks)
  • packages/common/component/MetaCodeEditor.vue (4 hunks)
  • packages/common/component/MetaDescription.vue (1 hunks)
  • packages/common/component/MetaForm.vue (1 hunks)
  • packages/common/component/MetaListActions.vue (2 hunks)
  • packages/common/component/MetaListItem.vue (4 hunks)
  • packages/common/component/MetaListItems.vue (1 hunks)
  • packages/common/component/MetaListTitle.vue (1 hunks)
  • packages/common/component/MetaModal.vue (1 hunks)
  • packages/common/component/MetaModalItem.vue (3 hunks)
  • packages/common/component/MetaPopover.vue (1 hunks)
  • packages/common/component/MonacoEditor.vue (4 hunks)
  • packages/common/component/MultiTypeSelector.vue (4 hunks)
  • packages/common/component/PluginBlockItemImg.vue (2 hunks)
  • packages/common/component/PluginPanel.vue (1 hunks)
  • packages/common/component/PluginSetting.vue (2 hunks)
  • packages/common/component/PublicIcon.vue (1 hunks)
  • packages/common/component/SearchEmpty.vue (1 hunks)
  • packages/common/component/SelectAll.vue (1 hunks)
  • packages/common/component/SvgButton.vue (2 hunks)
  • packages/common/component/ToolbarBase.vue (1 hunks)
  • packages/common/component/VideoGuide.vue (1 hunks)
  • packages/common/component/VueMonaco.vue (6 hunks)
  • packages/common/component/toolbar-built-in/ToolbarBaseButton.vue (1 hunks)
  • packages/common/component/toolbar-built-in/ToolbarBaseIcon.vue (1 hunks)
  • packages/common/composable/defaultGlobalService.ts (6 hunks)
  • packages/common/composable/generateCode/index.ts (4 hunks)
  • packages/common/vite.config.ts (1 hunks)
  • packages/configurator/vite.config.ts (1 hunks)
  • packages/i18n/index.html (1 hunks)
  • packages/i18n/src/I18nHost.vue (1 hunks)
  • packages/i18n/src/i18n.ts (1 hunks)
  • packages/i18n/src/test/TestVueInject.vue (1 hunks)
  • packages/i18n/src/test/TestWebcomponent.vue (1 hunks)
  • packages/i18n/vite.config.ts (1 hunks)
  • packages/layout/src/DesignPlugins.vue (2 hunks)
  • packages/layout/src/DesignSettings.vue (1 hunks)
  • packages/layout/src/DesignToolbars.vue (1 hunks)
  • packages/layout/src/Main.vue (2 hunks)
  • packages/layout/src/ToolbarCollapse.vue (1 hunks)
  • packages/layout/vite.config.ts (1 hunks)
  • packages/register/src/common.ts (7 hunks)
  • packages/register/src/configurators.ts (2 hunks)
  • packages/register/src/entryHash.ts (4 hunks)
  • packages/register/src/hooks.js (0 hunks)
  • packages/register/src/hooks.ts (1 hunks)
  • packages/register/src/layoutHash.ts (1 hunks)
  • packages/register/src/service.ts (3 hunks)
  • packages/register/src/templateHash.ts (1 hunks)
  • packages/register/src/useMessage.ts (2 hunks)
  • packages/register/vite.config.ts (1 hunks)
  • packages/settings/design/src/components/widgets/index.ts (1 hunks)
  • packages/settings/design/src/convertToSchema.ts (3 hunks)
  • packages/settings/design/src/store/index.ts (6 hunks)
  • packages/settings/design/vite.config.ts (1 hunks)
  • packages/settings/events/index.ts (1 hunks)
  • packages/settings/events/src/commonjs/events.ts (1 hunks)
  • packages/settings/events/src/components/AddEventsDialog.vue (1 hunks)
  • packages/settings/events/vite.config.ts (1 hunks)
  • packages/settings/panel/vite.config.ts (1 hunks)
  • packages/settings/props/vite.config.ts (1 hunks)
  • packages/settings/styles/src/js/parser.ts (6 hunks)
  • packages/settings/styles/src/js/useStyle.ts (7 hunks)
  • packages/settings/styles/vite.config.ts (1 hunks)
  • packages/svgs/index.ts (1 hunks)
  • packages/svgs/src/Main.vue (1 hunks)
  • packages/svgs/vite.config.ts (1 hunks)
  • packages/theme/base/vite.config.ts (1 hunks)
  • packages/toolbars/breadcrumb/src/Main.vue (1 hunks)
  • packages/toolbars/breadcrumb/src/composable/useBreadcrumb.ts (1 hunks)
  • packages/toolbars/breadcrumb/vite.config.ts (1 hunks)
⛔ Files not processed due to max files limit (48)
  • packages/toolbars/clean/src/Main.vue
  • packages/toolbars/clean/vite.config.ts
  • packages/toolbars/collaboration/vite.config.ts
  • packages/toolbars/fullscreen/src/Main.vue
  • packages/toolbars/fullscreen/vite.config.ts
  • packages/toolbars/generate-code/src/FileSelector.vue
  • packages/toolbars/generate-code/src/Main.vue
  • packages/toolbars/generate-code/src/composable/useSaveLocal.ts
  • packages/toolbars/generate-code/src/http.ts
  • packages/toolbars/generate-code/vite.config.ts
  • packages/toolbars/lang/src/Main.vue
  • packages/toolbars/lang/vite.config.ts
  • packages/toolbars/layout/src/Main.vue
  • packages/toolbars/layout/vite.config.ts
  • packages/toolbars/lock/src/Main.vue
  • packages/toolbars/lock/src/http.ts
  • packages/toolbars/lock/vite.config.ts
  • packages/toolbars/logo/src/AppList.vue
  • packages/toolbars/logo/src/Main.vue
  • packages/toolbars/logo/vite.config.ts
  • packages/toolbars/logout/src/Main.vue
  • packages/toolbars/logout/vite.config.ts
  • packages/toolbars/media/index.ts
  • packages/toolbars/media/src/Main.vue
  • packages/toolbars/media/vite.config.ts
  • packages/toolbars/preview/src/Main.vue
  • packages/toolbars/preview/vite.config.ts
  • packages/toolbars/redoundo/src/Main.vue
  • packages/toolbars/redoundo/src/composable/useHistory.ts
  • packages/toolbars/redoundo/vite.config.ts
  • packages/toolbars/refresh/src/Main.vue
  • packages/toolbars/refresh/vite.config.ts
  • packages/toolbars/save/src/Main.vue
  • packages/toolbars/save/src/js/index.ts
  • packages/toolbars/save/vite.config.ts
  • packages/toolbars/setting/src/Main.vue
  • packages/toolbars/setting/vite.config.ts
  • packages/toolbars/themeSwitch/src/Main.vue
  • packages/toolbars/themeSwitch/src/composable/index.ts
  • packages/toolbars/themeSwitch/vite.config.ts
  • packages/toolbars/view-setting/src/Main.vue
  • packages/toolbars/view-setting/vite.config.ts
  • packages/utils/src/fs/fszip.ts
  • packages/utils/src/fs/index.ts
  • packages/utils/src/utils/index.ts
  • packages/utils/vite.config.ts
  • tsconfig.app.json
  • tsconfig.node.json
💤 Files with no reviewable changes (2)
  • packages/canvas/common/index.js
  • packages/register/src/hooks.js
🧰 Additional context used
🧠 Learnings (1)
packages/canvas/render/src/builtin/CanvasRouterView.vue (1)
Learnt from: rhlin
PR: opentiny/tiny-engine#1011
File: packages/canvas/render/src/builtin/CanvasRouterView.vue:4-19
Timestamp: 2025-03-13T02:41:34.105Z
Learning: In the tiny-engine project, component implementations should maintain consistency with other components at the same level, even if modernization improvements (like TypeScript and Composition API) are possible.
🧬 Code Definitions (6)
packages/canvas/container/src/keyboard.ts (1)
packages/canvas/container/src/container.ts (1) (1)
  • getCurrent (67:73)
packages/canvas/common/src/utils.ts (1)
packages/canvas/container/src/container.ts (2) (2)
  • addScript (861:861)
  • addStyle (859:859)
packages/register/src/service.ts (1)
packages/register/src/index.ts (1) (1)
  • defineService (21:21)
packages/register/src/entryHash.ts (1)
packages/register/src/index.ts (3) (3)
  • mergeRegistry (15:15)
  • getMergeRegistry (15:15)
  • defineEntry (15:15)
packages/settings/styles/src/js/useStyle.ts (1)
packages/utils/src/utils/index.ts (1) (1)
  • generateRandomLetters (172:180)
packages/register/src/common.ts (1)
packages/register/src/index.ts (3) (3)
  • getMetaApi (13:13)
  • getOptions (13:13)
  • getMergeMeta (13:13)
🔇 Additional comments (182)
packages/i18n/src/I18nHost.vue (1)

5-5: Good job enabling TypeScript.
This transition helps with better type inference and error detection.

packages/i18n/index.html (1)

11-11: Looks good.
Referring to main.ts aligns with the ongoing TypeScript migration.

packages/layout/src/ToolbarCollapse.vue (1)

32-32: Great migration to TypeScript!
No issues spotted.

packages/layout/src/DesignSettings.vue (1)

17-17: TypeScript transition confirmed.
Looks consistent with the PR objectives.

packages/layout/src/DesignToolbars.vue (1)

49-49: Script tag updated to TypeScript.
All good here.

packages/i18n/vite.config.ts (1)

31-31:

Details

✅ Verification successful

Update entry path to a TypeScript file.
Ensure that the new file is present and recognized in the build.


🏁 Script executed:

#!/bin/bash
# Check for the presence of the new entry file
fd lib.ts --exec ls -l {}

Length of output: 190


Entry path update verified.
The file ./packages/i18n/src/lib.ts exists as expected, so the TypeScript migration is correctly applied.

packages/i18n/src/test/TestVueInject.vue (1)

7-7: Transition to TypeScript
Adding lang="ts" is in line with the PR’s goal of migrating to TypeScript.

packages/canvas/container/src/keyboard.ts (2)

61-62: Decomposed destructuring
Splitting schema and parent could improve readability or type-related checks.


71-71: Const usage
Defining obj as const clarifies its immutability.

packages/layout/src/Main.vue (2)

28-28: Using TypeScript
Switching the script to TypeScript aligns with the codebase refactor.


49-50: Default prop
Providing a default empty object prevents runtime issues when no registry is passed.

packages/i18n/src/test/TestWebcomponent.vue (1)

7-7: Move to TypeScript
Good job adding lang="ts".

packages/layout/src/DesignPlugins.vue (1)

74-74: Adoption of TypeScript.

The addition of lang="ts" aligns with the PR objective to migrate to TypeScript.

packages/builtinComponent/src/components/helper.ts (3)

13-13: Good type annotation for numeric and string values.

Specifying string | number helps ensure correct usage and improves readability.


25-25: Appropriate usage of Record<string, string>.

This clarifies the shape of the map, enhancing type safety.


34-34: Consistent object shape definition.

Using Record<string, string> for justAlignMap improves clarity.

packages/toolbars/breadcrumb/src/composable/useBreadcrumb.ts (1)

21-21: String parameter.

Defining a string type for the parameter improves clarity and ensures correct usage.

packages/common/composable/generateCode/index.ts (2)

1-6: Type import for IAppSchema.

The import statement with type IAppSchema is a clean approach to keep type information separate and well-defined.


20-20: Strongly typed appSchema parameter.

Specifying IAppSchema ensures the function receives the correct structure.

packages/settings/design/src/convertToSchema.ts (2)

44-44: Consider refined types if possible
Using Record<string, string> is good. Ensure that the mapped values truly match the expected widget component strings to avoid runtime type mismatches.


70-70: Confirm index type usage
(item: any, index: string | number) is functional but might be simplified to (item: string | number, index: number) if you expect only numeric iteration.

packages/canvas/common/src/utils.ts (4)

1-1: Check optional doc param usage
The doc = document default is useful. Ensure calls from iframes or special DOM contexts pass the correct doc object.


13-13: Validate non-null assertion
Ensure doc.querySelector('head') is guaranteed to return a node in all usage contexts.


17-17: Similar approach for addStyle
Same comment about doc = document and usage in iframes.


27-27: Validate non-null assertion
Confirm 'head' is always present.

packages/common/composable/defaultGlobalService.ts (10)

49-49: Error handling
.catch((error: { message: any }) => ...) is fine, but consider explicit error type if known.


55-55: Stricter type usage
(appId: string) is a good improvement. Confirm that appId is always a string.


58-58: Ensure string
(platformId: string) is correct if truly always a string.


70-70: Function definition
(params: Record<string, any>) is more precise than plain any, good improvement.


98-98: Param doc
Documenting replace as boolean is helpful.

🧰 Tools
🪛 Biome (1.9.4)

[error] 97-98: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


138-138: Update param
(pageId: string) is good. Confirm callers pass valid strings.


142-142: Update param
(blockId: string) is correct.


146-146: Optional boolean
(previewId: string, replace = false) is consistent with the doc.


172-172: Event callback
(appId: string) is good for typed event handling.


190-190: Similar typed callback
(platformId: string) is consistent.

packages/build/vite-config/src/vite-plugins/devAliasPlugin.js (1)

14-14: TypeScript alias updates
All references to .js => .ts. This ensures the devAlias points to TypeScript sources, consistent with the broader migration. Confirm that these TypeScript files exist and are compilable.

Also applies to: 18-18, 32-55, 57-58, 60-64

jsconfig.json (2)

9-9: Consistent TypeScript path updates.

Removing the “.js” extension enhances flexibility for TS/JS resolution. No issues found.


64-64: Ensuring path alignment for utils.

Similarly removing the “.js” extension is good for TS compatibility. Looks correct.

packages/settings/styles/src/js/parser.ts (3)

50-60: Refined comment node shape.

Defining the parameter type clarifies usage, improving readability.


73-142: CSS parameter typed as string.

Specifying css: string helps avoid accidental non-string inputs. No further concerns.


149-174: Returning string array.

Defining getSelectorArr return type as string[] is a helpful improvement. Looks good.

packages/settings/styles/src/js/useStyle.ts (8)

61-63: Random class names typed.

Adding componentName: any is consistent with the codebase’s transitional typing strategy. Looks fine.


65-94: getPropsFromExpression typed.

The explicit { value: string } structure is a step forward. Great improvement.


101-101: Array initialization.

Renaming to a typed array is consistent with TS migration. Good.


110-131: getClassNameAndIdList typed.

Specifying the shape of schema.props clarifies intent. Approved.


260-265: Enforcing string for styleStr.

This ensures the function is used correctly, no issues found.


267-292: Revising newSelector as string.

Aligns with TS usage. Looks good.


355-366: Improving numeric extraction.

(value: string) clarifies usage. Approved.


402-405: Fine-grained property access.

Adding styleName: string fosters clarity. Approved.

packages/common/component/MetaDescription.vue (1)

23-23: Switching to TypeScript.

Enabling TypeScript in the component is aligned with the broader migration. No issues.

packages/common/component/EmptyTip.vue (1)

17-17: Convert to TypeScript
This addition of lang="ts" aligns with your migration goal and introduces no issues.

packages/common/component/toolbar-built-in/ToolbarBaseIcon.vue (1)

19-19: No issues with TypeScript addition
Using lang="ts" is consistent with the current refactoring effort.

packages/builtinComponent/src/components/CanvasFlexBox.vue (1)

7-7: Refactor to TypeScript using <script setup>
This migration neatly transitions the component script to TypeScript without altering functionality.

packages/canvas/index.html (1)

11-11: Redirect script to TypeScript file
Switching from main.js to main.ts is on point with the TypeScript transition.

packages/common/component/VideoGuide.vue (1)

22-22: Use of TypeScript script block is consistent with the migration goal.
No issues identified.

packages/canvas/common/index.ts (1)

1-2: Centralized re-exports look good.
This file cleanly consolidates exports from constants and utils.

packages/common/component/PluginPanel.vue (1)

19-19: TypeScript migration approved.
No functional changes; this fosters consistency and type safety.

packages/canvas/render/src/builtin/CanvasPlaceholder.vue (1)

11-11: Transition to TS is in line with the refactoring objective.
No concerns; implementation remains the same.

packages/canvas/render/src/builtin/CanvasImg.vue (1)

5-5: TypeScript migration confirmed.
This update to <script lang="ts"> is consistent with the refactor objectives and introduces no issues.

packages/settings/events/src/components/AddEventsDialog.vue (1)

45-45: Confirm import path resolution.
Please verify that removing the file extension doesn't break references in certain bundlers or older TS configurations.

packages/common/component/SearchEmpty.vue (1)

7-7: Transition to TypeScript supported.
The addition of lang="ts" is aligned with the project's refactoring goals.

packages/common/component/PublicIcon.vue (1)

8-8: Refactor to TypeScript acknowledged.
Adopting <script lang="ts"> here maintains consistency across the codebase and appears valid.

packages/common/component/MetaListTitle.vue (1)

5-5: Smooth transition to TypeScript.

No issues found. Good job on adding lang="ts".

packages/svgs/src/Main.vue (1)

7-7: TypeScript migration looks good.

No concerns identified. Everything else appears unchanged.

packages/common/component/BlockHistoryList.vue (1)

25-25: Setup script now in TypeScript.

Looks clean. Great step in ensuring stronger type safety.

packages/common/component/MetaForm.vue (1)

17-17: Successfully enabled TypeScript.

Implementation remains consistent, and no issues are detected.

packages/canvas/render/src/builtin/CanvasRouterView.vue (1)

4-4: Script tag successfully migrated to TypeScript.

No issues found. This aligns with the project's TS migration guidelines.

packages/common/component/MetaModal.vue (1)

10-10: Script tag successfully migrated to TypeScript.

No logic changes. Looks good for the TS migration effort.

packages/builtinComponent/src/components/CanvasRow.vue (1)

7-7: Script setup migrated to TypeScript.

No functional modifications are introduced; this matches the migration goals.

packages/common/component/ToolbarBase.vue (1)

13-13: Script tag successfully migrated to TypeScript.

Implementation remains unchanged, only the language attribute is updated.

packages/common/component/SelectAll.vue (1)

7-7: TypeScript Integration in Script Setup
Adding lang="ts" to the <script setup> tag ensures that this component now benefits from TypeScript’s type checking and improved tooling. This change is consistent with the overall migration effort.

packages/builtinComponent/src/components/CanvasRowColContainer.vue (1)

7-7: TypeScript Integration for Enhanced Type Safety
Updating the <script setup> tag to <script setup lang="ts"> establishes a clear intent to use TypeScript. This aligns well with the project’s migration goals and provides additional type-checking benefits without affecting runtime behavior.

packages/settings/events/index.ts (1)

15-15: Updated Import Path for TypeScript Compatibility
Modifying the import from

import { commonEvents } from './src/commonjs/events.js'

to

import { commonEvents } from './src/commonjs/events.ts'

ensures that the module is resolved correctly in a TypeScript environment. This change is a necessary step for the migration and improves the overall consistency of module resolution.

packages/canvas/DesignCanvas/src/api/useCanvas.ts (1)

75-76: Immutable Declaration for columns
Changing the declaration from a mutable (let) to an immutable (const) variable for columns reinforces that the reference should not be reassigned. This update improves both code safety and readability.
Consider adding explicit type annotations in future revisions for even stricter type validation.

packages/common/component/MetaListItems.vue (1)

64-64: TypeScript Language Specification Added
Changing the plain <script> tag to <script lang="ts"> enables TypeScript processing within this component. This update enhances type safety and aligns the file with the overall refactor strategy without altering functionality.

packages/common/component/toolbar-built-in/ToolbarBaseButton.vue (1)

11-11: Migration to TypeScript confirmed.
This change aligns with the TypeScript migration.

packages/common/component/MetaListActions.vue (1)

9-9: Script language changed to TypeScript.
This is consistent with the PR's TypeScript migration goal.

packages/toolbars/breadcrumb/src/Main.vue (1)

36-36: Migration to TypeScript confirmed.
This update is consistent with the PR's objectives and introduces no new issues.

packages/common/component/SvgButton.vue (2)

10-10: Migration to TypeScript
Nice work adding lang="ts" for enhanced type safety.


40-41: Type-annotated event and optional chaining
The explicit MouseEvent type annotation and use of optional chaining prevent runtime errors and improve clarity.

packages/register/src/layoutHash.ts (1)

15-15: Enhanced type safety for metaData
Good job enforcing the presence of the id property.

packages/common/component/PluginSetting.vue (2)

33-33: Migration to TypeScript
Adding lang="ts" improves maintainability and catches type errors early.


111-111: Parameter type enforcement
Defining isFullScreen: boolean clarifies usage and enhances type safety.

packages/register/vite.config.ts (1)

23-25: Switched entry to TypeScript & enabled dynamic filename
Great work aligning this config with TypeScript and providing a flexible file naming approach.

packages/common/component/MetaChildItem.vue (1)

19-19: Good transition to TypeScript.
No functional concerns; using <script lang="ts"> aligns with the PR's refactoring strategy.

packages/settings/events/src/commonjs/events.ts (1)

184-193: Ensure valid event length before indexing.
The signature change to (event: string) is good. However, confirm that e[2] is safe if the event string is unexpectedly short.

packages/common/component/CanvasDragItem.vue (1)

7-7: TypeScript adoption confirmed.
Switching <script> to <script lang="ts"> is aligned with the TS migration objective.

packages/canvas/canvas.html (1)

210-210: Verify that TypeScript modules are handled.
Browsers typically don’t support raw .ts modules. Confirm that a bundler or transpile step processes “canvas.ts.”

packages/settings/events/vite.config.ts (1)

26-28: Well-done on switching to a TypeScript entry and dynamic output filename.

Your configuration aligns with best practices for TypeScript-based libraries.

packages/common/component/MetaModalItem.vue (2)

28-28: Good job adding TypeScript support.

Enabling lang="ts" fosters better type checking and development tooling.


46-46: Additional emits are properly declared.

Adding 'close' and 'update:modelValue' expands the component’s event interface, ensuring clarity for consumers.

packages/configurator/vite.config.ts (1)

24-25: Switch to TypeScript entry and dynamic filenames approved.

This update aligns with the overall TypeScript migration and offers better clarity on output bundles.

packages/common/component/BlockDescription.vue (1)

12-12: Nice TypeScript adoption in script block.

This ensures improved type inference and IntelliSense support.

packages/settings/panel/vite.config.ts (1)

26-27: Ensure the new entry file is valid.

Switching the entry to index.ts is consistent with the TypeScript migration. Verify that index.ts exists and is properly exported.

packages/common/component/I18nInput.vue (3)

37-37: Good move enabling TypeScript.

lang="ts" helps ensure stronger type checks for this component.


73-73: Typed event parameter for clarity.

Defining event.target.value type improves readability and reduces errors.


77-77: Parameter typing.

Typing the data parameter ensures clarity on what data is emitted.

packages/layout/vite.config.ts (1)

26-28: Consistent TypeScript migration.

Using index.ts and dynamic filename generation aligns well with the rest of the PR.

packages/common/component/PluginBlockItemImg.vue (2)

20-20: Script setup now in TypeScript.

This ensures the component reaps the benefits of TS checking and improved maintainability.


49-49: Typed parameter for handleCheck.

Declaring (v: any) clarifies expected usage for the event callback.

packages/register/src/useMessage.ts (1)

103-103: No issues found.

Defining const callbacks with a fallback array is fine and ensures callbacks is always defined.

packages/register/src/templateHash.ts (1)

16-16: Good addition of a string type.

Explicitly typing template improves readability and reduces type ambiguity.

packages/canvas/vite.config.ts (2)

29-29: Migration to TypeScript path is correct.

Switching from .js to .ts aligns with the overall PR objective.


37-37: Properly updated library entry to TypeScript.

This improves type safety and consistency with the rest of the codebase.

packages/settings/props/vite.config.ts (2)

26-26: Migration to .ts for the entry offers better type checks.

This change follows the TypeScript-first approach throughout the PR.


28-28: Dynamic filename generation looks good.

Generating ${entryName}.js keeps entries consistent across builds.

packages/builtinComponent/vite.config.ts (2)

24-24: Good migration to TypeScript.
No issues spotted; referencing index.ts here aligns well with the broader TS refactor.


26-26: Dynamic filename generation looks good.
This flexible approach is consistent with modern build configurations.

packages/canvas/render/src/builtin/CanvasCollection.vue (2)

9-9: Transition to TypeScript is on point.
No conflicts identified; this improves type safety.


13-13: Correct file extension usage.
Ensure CanvasCollection.ts is committed and properly referenced throughout.

packages/settings/design/vite.config.ts (1)

25-27: Smooth transition to TypeScript and dynamic filenames.
All changes appear correct; verify that lib.ts is present in src directory.

packages/register/src/configurators.ts (2)

3-3: Well-defined parameter type.
This improves clarity on what objects are expected in the array.


12-12: String type annotation for "name".
Straightforward addition that boosts type safety.

packages/svgs/vite.config.ts (1)

26-28: Good transition to TypeScript and dynamic naming.
Everything looks consistent with the TS migration and enhances maintainability.

packages/toolbars/breadcrumb/vite.config.ts (1)

26-28: Consistent TS migration and dynamic filename usage.
Neat improvement for type safety and flexible build outputs.

packages/theme/base/vite.config.ts (1)

21-23: Well-aligned TypeScript entry and dynamic filename.
Looks good and matches the project's TS refactor plan.

packages/settings/styles/vite.config.ts (1)

26-28: Migration to TypeScript entry and flexible file naming.
This is on par with similar refactor changes. No concerns here.

packages/common/vite.config.ts (2)

44-44: Entry point update looks good.
This aligns with TypeScript migration and appears correct.


48-48: Parameter rename to avoid unused variable warning.
No concerns; it's a clean way to acknowledge an unused parameter.

packages/builtinComponent/src/components/CanvasCol.vue (3)

7-7: TypeScript script migration.
Looks fine. No issues flagged.


25-25: Prop type changed from [String, Number] to String.
Confirm whether numeric values are still needed. If not, this is fine.

Also applies to: 29-29


56-65: Enhanced computed style handling.
Implementation looks consistent and readable.

packages/common/component/MetaCodeEditor.vue (3)

77-77: Switched to TypeScript in script.
Good migration step.


135-135: Added 'close' event in emits.
Nice addition for better event control.


192-192: Typed editorDidMount parameter.
Looks consistent with TS usage.

packages/common/component/MetaListItem.vue (1)

75-75: TypeScript migration in script.
No concerns with the script lang attribute change.

packages/common/component/MonacoEditor.vue (4)

51-51: TypeScript script tag added.
No issues found; this aligns the component with the codebase’s TypeScript migration.


66-69: Prop default value set for "value".
Good handling of default string initialization.


71-72: Prop default factory set for "options".
Using a function to provide an empty object by default is a sound approach.


133-133: Parameter typed as boolean.
Typing the switchFullScreen parameter adds clarity and reduces potential misuse.

packages/register/src/entryHash.ts (2)

22-22: Arrays typed explicitly with any[].
This clarifies that both parameters are arrays; consider refining types if the array elements have a known shape.


63-63: getMergeRegistry parameters typed as string.
Appropriate to ensure consistent usage of type and id.

packages/common/component/ConfigRender.vue (5)

38-38: TypeScript script tag added.
This is consistent with the global TypeScript migration.


61-61: Additional emits added.
Emitting 'select-prop' and 'select-group' adds clarity for consumer usage.


65-65: Typed parameters in getPropsObj.
This improves type safety; using Record<string, any> and arrays is flexible.

Also applies to: 70-72, 74-74


90-91: onPropClick/onGroupClick typed.
Acceptable usage of any for the data param.


93-94: filterActiveGroup typed.
Properly typed arrow function usage.

packages/common/component/BlockDeployDialog.vue (6)

73-73: Added TypeScript support.
This aligns with the broader migration effort.


145-145: getNextVersion param typed as any.
This is fine for code referencing an object with varied structure.


150-150: Typed param for backupList iteration.
This clarifies the structure of objects used in the loop.


173-173: setVisible typed as boolean.
Ensures correct usage of visibility toggling.


183-183: deployBlock validate callback typed.
No concerns; usage aligns with typical form validation.


220-220: changeCode param typed as string.
Clear distinction ensures the editor value is handled consistently.

packages/register/src/service.ts (4)

4-4: Confirm the usage of DeepReadonly.
Looks appropriate for ensuring the read-only nature of nested refs.


6-9: Context interface is well-defined.
Your interface neatly captures component state and options. Good job adding strongly typed generics.


11-18: Clearer structure with ServiceOptions.
This interface elegantly defines a typed contract for service creation.


20-24: Typed utility definitions look good.
These type aliases (GetState, SetState, Service) improve clarity and ensure consistency.

packages/common/component/BindI18n.vue (2)

57-57: TypeScript migration initiated.
Switching to <script lang="ts"> is aligned with the refactoring goal.


117-117: Solid param type on selectI18n.
Giving key a string type is a valuable improvement for type safety.

packages/common/component/MultiTypeSelector.vue (3)

29-29: TypeScript enabled.
Nice step toward consistent TS usage in Vue single-file components.


74-74: Explicit string type in map callback.
Specifying type: string in map increases type clarity. Good improvement.


85-85: TYPE_MAP typed as Record<string, string>.
This upgrade eliminates guesswork around key-value types.

packages/settings/design/src/store/index.ts (2)

170-186: addGroup signature updated.
Using (index: number) fosters clarity. This is an excellent change.


253-265: getSchemaByComponetName.
Making name a string is a straightforward improvement. Nicely done.

packages/common/component/VueMonaco.vue (5)

4-4: Use of <script lang="ts">
Transitioning this component to TypeScript is aligned with the PR’s objective.


12-12: Optional theme parameter with union type
Good use of TS union type for 'vs' | 'vs-dark'. This ensures type-safe theme values.


33-34: Default object for options prop
Providing an empty object by default prevents undefined property access.


46-46: Typing the vueMonaco structure
Defining explicit types for editor and monaco increases clarity.


131-131: Typed editor parameter in run method
Specifying getValue/setValue clarifies usage. Adjust or broaden type details if more editor API usage is expected.

packages/register/src/hooks.ts (4)

1-21: Enumeration of hook names
The HOOK_NAME object is a clear, centralized registry for recognized hooks.


23-43: Initializing hooksState
Defaulting each hook to an empty object ensures no undefined references.


52-71: Exported use* hook wrappers
Neat wrappers for retrieving each hook state. The consistent naming scheme helps readability.


72-87: initHook with optional merging
The approach to either overwrite or merge hook content is flexible. Good error-checking for invalid hook names.

packages/common/component/ConfigItem.vue (10)

103-103: Introduction of <script lang="ts">
Adding TypeScript usage is consistent with the overall migration.


123-123: hasRule function signature updated
Specifying rules as string | any[] clarifies usage.


266-266: updateValue parameter type definition
Providing a shape for value prevents mistakes when referencing props or componentName.


316-316: setVerifyFailed typed result and message
Helpful for ensuring consistent properties.


321-321: isEmptyInputValue typed param
Allows for straightforward checking of string | null.


327-327: verifyRequired with string param
Restricting to string clarifies caller responsibility.


331-331: verifyValue signature
Explicit array type for rules fosters clarity in validation logic.


386-386: executeRelationAction typed value param
Indicating string | undefined highlights possible states.


412-412: onModelUpdate typed with data: any
This maintains flexibility for complex model updates.


471-471: isRelatedComponents typed param
Clarifies the component’s name argument.

packages/register/src/common.ts (9)

32-52: Typed object maps
Declaring these as Record<string, any> is an improvement, though narrower value types can further enhance safety if known.


54-64: getMetaApi function signature
Typing id and key as strings clarifies usage.


66-68: getOptions with typed id
Enables consistent usage of optionsMap.


70-80: handleMethods typed id and methods
Generically typed as any but well-structured for assigning methods into entryHashMap.


103-109: handleLifeCycles typed id and lifeCycles
Similar approach; merges lifecycle definitions into entryHashMap.


111-143: handleRegistryProp typed id and value
Clear breakdown for layout, methods, apis, etc. Merging overwrites as needed.


145-160: preprocessRegistry typed registry
Detects array-based metaApp usage, ensuring consistency.


162-177: generateRegistry typed registry
Recursively processes meta objects, storing them in shared maps. Straightforward approach.


179-181: getMergeMeta typed id
Provides a typed retrieval from metaHashMap.

hexqi
hexqi previously approved these changes Mar 19, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/toolbars/save/src/js/index.ts (3)

39-39: Consider using a more specific type for pageSchema

While adding a TypeScript type for pageSchema is good, the current type { fileName: any } only captures one property used in the function. Based on line 46 (block.content = pageSchema), this parameter appears to have more properties that could be typed to improve type safety.

Consider creating a more comprehensive interface:

interface BlockSchema {
  fileName: string;
  // Add other properties based on the schema structure
}

const saveBlock = async (pageSchema: BlockSchema) => {

54-54: Avoid using 'any' type when possible

Using any type negates TypeScript's benefits of type safety and documentation. The parameter appears to represent a page schema object with specific properties.

Consider defining a more specific interface:

interface PageSchema {
  // Define properties based on expected schema structure
}

const savePage = async (pageSchema: PageSchema) => {

192-192: Consider using a more specific type than 'any'

Using any type reduces TypeScript's type safety benefits. Looking at how status is used (being passed to JSON.stringify()), a more specific type would be appropriate.

Since this appears to be storing auto-save status, consider:

export const setAutoSaveStatus = (status: boolean) => {

If other types are valid, consider using union types or a more specific type based on the expected values.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fddbc58 and cf63d30.

📒 Files selected for processing (2)
  • packages/canvas/container/src/keyboard.ts (2 hunks)
  • packages/toolbars/save/src/js/index.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/canvas/container/src/keyboard.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: push-check
🔇 Additional comments (2)
packages/toolbars/save/src/js/index.ts (2)

69-69: Good use of type annotation

Appropriate use of the string type for the value parameter, as it's clearly used with JSON.parse() which expects a string input.


185-185: Good use of nullish coalescing operator

The addition of the nullish coalescing operator (??) provides a default empty string when localStorage.getItem(AUTO_SAVED) returns null, preventing potential issues with JSON.parse() in the next line.

@hexqi hexqi merged commit d0f264f into opentiny:develop Mar 20, 2025
2 checks passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/layout/src/DesignPlugins.vue (1)

128-130: Consider using more specific type definitions.

The use of the any type for these variables effectively turns off TypeScript's type checking. While this is a valid first step in migration, consider defining proper interfaces in a future iteration to fully leverage TypeScript's benefits.

-const components: any = {}
-const iconComponents: any = {}
-const pluginRef = ref<any>(null)
+interface PluginComponent {
+  [key: string]: Component
+}
+const components: PluginComponent = {}
+const iconComponents: PluginComponent = {}
+const pluginRef = ref<Component | null>(null)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf63d30 and 1c62afd.

📒 Files selected for processing (7)
  • packages/common/component/PluginPanel.vue (1 hunks)
  • packages/common/component/PluginSetting.vue (2 hunks)
  • packages/layout/src/DesignPlugins.vue (2 hunks)
  • packages/layout/src/DesignSettings.vue (1 hunks)
  • packages/layout/src/Main.vue (2 hunks)
  • packages/register/src/common.ts (7 hunks)
  • packages/settings/events/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/layout/src/DesignSettings.vue
  • packages/settings/events/index.ts
  • packages/common/component/PluginPanel.vue
  • packages/common/component/PluginSetting.vue
  • packages/layout/src/Main.vue
  • packages/register/src/common.ts
🔇 Additional comments (1)
packages/layout/src/DesignPlugins.vue (1)

98-98: TypeScript migration successfully implemented.

The script tag now includes the lang="ts" attribute, enabling TypeScript compilation for this Vue component. This is consistent with the PR's objective of migrating JavaScript files to TypeScript.

@gene9831 gene9831 deleted the refactor/js-to-ts branch March 20, 2025 03:00
gene9831 added a commit to gene9831/tiny-engine that referenced this pull request Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants