-
Notifications
You must be signed in to change notification settings - Fork 78
refactor: enhance type safety and structure in AST handling #2214
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request enhances type safety in the @shopware/cms-base-layer package by adding comprehensive TypeScript types to the html-to-vue helper functions. The refactor removes @ts-nocheck directives and introduces strongly-typed interfaces for AST parsing, traversal, and rendering logic.
Key changes:
- Added TypeScript type definitions (ASTNode, VisitCallback, ExtraComponentConfig, RendererConfig, etc.) across ast.ts and renderer.ts
- Refactored renderer logic with new
flattenChildrenutility for child node normalization - Updated type guards and function signatures for safer AST manipulation with explicit typing
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/cms-base-layer/app/helpers/html-to-vue/renderer.ts | Added comprehensive TypeScript types, introduced flattenChildren function, refactored renderer with explicit typing |
| packages/cms-base-layer/app/helpers/html-to-vue/ast.ts | Added type definitions for AST operations, improved type guards in isNode, enhanced _visitAST with proper typing |
| packages/cms-base-layer/app/helpers/html-to-vue/renderToHtml.ts | Updated to use new RendererConfig and RectifyConfig types from refactored modules |
| packages/cms-base-layer/app/helpers/html-to-vue/getOptionsFromNode.ts | Exported Options type for cross-module type consistency |
| packages/cms-base-layer/app/components/public/cms/element/CmsElementText.vue | Fixed boolean conversion in conditions function to align with TypeScript typing |
| .changeset/light-dragons-lie.md | Added changeset entry documenting the TypeScript typing additions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces full TypeScript to the
html-to-vuehelper functions in the@shopware/cms-base-layerpackage. The main focus is on improving type safety and code clarity across the AST parsing, traversal, and rendering logic. The changes include adding and refining TypeScript types, updating function signatures, and refactoring internal logic to leverage these types.TypeScript Typing and Type Safety Improvements:
ASTNode,VisitCallback,ExtraComponentConfig, etc.) toast.tsandrenderer.ts, replacing//@ts-nocheckand ensuring all functions and parameters are strongly typed. [1] [2]isNode,generateAST, andrectifyASTfunctions to use explicit types and improved type guards for safer AST manipulation. [1] [2]Optionstype fromgetOptionsFromNode.tsfor consistent usage across modules.Renderer Refactoring and Type Integration:
rendererfunction and its internal logic to use the new types, addedflattenChildrenfor child normalization, and improved handling of extra component renderers and children arrays. [1] [2] [3]Documentation and Minor Improvements:
(References: [1] [2] [3] [4] [5] [6] [7]
closes #1088