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

[pull] master from vuejs:master #140

Merged
merged 102 commits into from
Sep 5, 2024
Merged

[pull] master from vuejs:master #140

merged 102 commits into from
Sep 5, 2024

Conversation

pull[bot]
Copy link

@pull pull bot commented Aug 27, 2024

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

Summary by CodeRabbit

  • New Features

    • Introduced a global types file to enhance type management and navigation support for template-ref.
    • Enhanced code completion for directives with better sorting and filtering capabilities.
    • Added support for typed fallthrough attributes and improved handling of template references.
    • Launched a new file for generating global types to enhance type safety and component interaction.
    • Added conditional suffix handling for template processing to improve robustness.
    • Updated versioning information in the insiders configuration for better access to the latest releases.
  • Bug Fixes

    • Corrected export issues related to globalTypes and improved default behavior for vueCompilerOptions.lib.
    • Resolved vulnerabilities and enhanced parsing capabilities to avoid type errors.
  • Tests

    • Integrated new testing strategies for TypeScript configurations to ensure comprehensive coverage.
    • Added fixture tests for custom template tags in Vue to validate grammar and parsing.
  • Chores

    • Updated various package dependencies to their latest versions for improved performance and stability.

johnsoncodehk and others added 30 commits August 25, 2024 16:00
…4784)

* refactor(language-core): wrap template virtual code into a function

* fix: drop `declare`

---------

Co-authored-by: KazariEX <[email protected]>
Copy link

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fd30217 and ece125b.

Files ignored due to path filters (1)
  • packages/tsc/tests/__snapshots__/dts.spec.ts.snap is excluded by !**/*.snap
Files selected for processing (5)
  • packages/language-core/lib/codegen/script/component.ts (3 hunks)
  • packages/language-core/lib/codegen/script/index.ts (4 hunks)
  • packages/language-core/lib/codegen/script/scriptSetup.ts (11 hunks)
  • packages/language-core/lib/codegen/script/template.ts (5 hunks)
  • packages/language-core/lib/codegen/template/index.ts (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/language-core/lib/codegen/script/index.ts
Additional comments not posted (23)
packages/language-core/lib/codegen/template/index.ts (6)

8-8: LGTM!

The code changes are approved.


20-24: LGTM!

The code changes are approved. The addition of templateRefNames and inheritAttrs properties to the TemplateCodegenOptions interface enhances the flexibility of the template code generation process, as mentioned in the PR summary.


28-28: LGTM!

The code change is approved. Passing the entire options object to createTemplateCodegenContext instead of just options.scriptSetupBindingNames reflects a change in how context is managed during the generation process, as mentioned in the PR summary.


52-72: LGTM! But address the previous review comment.

The code changes are approved. The introduction of the generateRefs function enhances the handling of template references, as mentioned in the PR summary.

However, the previous review comment is still valid and applicable:

Implement error handling in generateRefs.

The function generateRefs correctly iterates over templateRefNames to generate references. However, as previously suggested, adding error handling for empty or invalid entries would enhance robustness. This is especially important given the dynamic nature of template references in Vue applications.

Consider adding the following error handling:

if (!options.templateRefNames || options.templateRefNames.size === 0) {
    throw new Error('No template references provided.');
}

Please address this comment by implementing the suggested error handling in generateRefs.


105-110: LGTM! But address the previous review comment.

The code changes are approved. The introduction of the generateInheritedAttrs function enhances the management of inherited attributes, as mentioned in the PR summary.

However, the previous review comment is still valid and applicable:

Implement error handling in generateInheritedAttrs.

The function generateInheritedAttrs constructs the variable __VLS_inheritedAttrs and iterates over inheritedAttrVars. Similar to generateRefs, adding error handling for empty or invalid entries in inheritedAttrVars would prevent runtime errors and ensure that the function behaves as expected under all conditions.

Consider adding the following error handling:

if (!ctx.inheritedAttrVars || ctx.inheritedAttrVars.size === 0) {
    throw new Error('No inherited attributes provided.');
}

Please address this comment by implementing the suggested error handling in generateInheritedAttrs.


Line range hint 114-136: LGTM!

The code changes are approved. The modifications to the generatePreResolveComponents function correctly generate code for resolving local and global components by iterating over the template AST and identifying component nodes.

packages/language-core/lib/codegen/script/component.ts (2)

39-41: LGTM!

The code changes are approved.


43-45: LGTM!

The code changes are approved.

packages/language-core/lib/codegen/script/template.ts (7)

7-7: LGTM!

The code changes are approved.


11-44: Approve the renaming and parameter changes in generateTemplateCtx.

The changes to the function name and parameters reflect a clearer focus and potentially simplify the interface. The generated context variable is now more structured, incorporating various types based on the component type and the presence of styles.


91-118: Review the integration of functions in generateTemplate.

The function generateTemplate effectively integrates new and modified functions, orchestrating the template generation process seamlessly. Comprehensive integration testing is recommended to ensure that all components work together without issues, especially given the significant changes in function responsibilities and data flow.

Consider setting up comprehensive integration tests to validate the entire template generation process.


Line range hint 120-173: Approve the changes in generateTemplateBody.

The renaming of the function to generateTemplateBody indicates a clearer separation of concerns in the template generation workflow. The function now yields a structured template result object, improving the overall output format and usability within Vue components. The introduction of the generateStyleScopedClasses function call signifies a new mechanism for handling style-scoped classes, indicating a more sophisticated approach to CSS class generation based on the styles defined in the component.


Line range hint 175-203: LGTM!

The code changes are approved.


Line range hint 205-238: LGTM!

The code changes are approved.


46-88: Approve the introduction of generateTemplateComponents.

This new function enhances modularity by isolating component-related logic, which should improve maintainability and clarity. It is recommended to add unit tests for this function to ensure it handles various scenarios correctly.

Would you like assistance in creating unit tests for this function?

packages/language-core/lib/codegen/script/scriptSetup.ts (8)

2-2: LGTM!

The code change to import the TextRange type is approved.


7-7: LGTM!

The code change to import the generateInternalComponent function is approved.


8-8: LGTM!

The code change to import the generateCssClassProperty and generateTemplate functions is approved.


56-56: LGTM!

The code change to use ctx.localTypes.PrettifyLocal instead of __VLS_Prettify is approved. The comment indicates that this change is made to generate less dts code.


61-67: LGTM!

The code changes to the logic for handling emitted types are approved. The changes reflect a change in how emitted types are constructed based on the presence of defined properties. The change from unshifting to pushing to the emitTypes array is a minor refactor that does not introduce any issues.


71-75: LGTM!

The code changes to the returned object are approved. The changes reflect a shift towards a more type-safe and structured approach to generating script setups. The use of ctx.localTypes.PrettifyLocal and __VLS_TemplateResult['slots'] enhances type safety and clarity. The changes to the slots and emit properties align with modern TypeScript practices and do not introduce any issues.


Line range hint 95-109: LGTM!

The code changes to handle defineProp properties are approved. The introduction of the getPropAndLocalName function centralizes the logic for retrieving property names and local names, streamlining the code and reducing redundancy. This change enhances maintainability and readability. The generation of linked code mappings for properties with a local name is a new feature that does not introduce any issues.


Line range hint 218-550: LGTM!

The code changes introduce several new features and refactor existing code to enhance maintainability, readability, and type safety. The introduction of new functions such as generateStyleModules, generateInternalComponent, getPropAndLocalName, and getRangeName centralizes logic and reduces redundancy. The use of ctx.localTypes instead of __VLS_ prefixed types aligns with modern TypeScript practices and enhances type safety. The new logic for handling CSS modules, template refs, and model emits expands the capabilities of the script setup generation. The changes do not introduce any issues.

@pull pull bot merged commit 1dafe62 into so1ve:master Sep 5, 2024
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.

10 participants