Skip to content

refactor(tyescript): simplify ref usage in Vue components and composables #1293

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

Merged
merged 1 commit into from
Apr 27, 2025

Conversation

ThornWalli
Copy link
Contributor

This pull request simplifies the use of Vue's ref and computed by removing unnecessary explicit type annotations (Ref and ComputedRef) and streamlining imports. These changes improve code readability and maintainability without altering functionality.

Simplification of ref and computed usage:

  • Removed explicit Ref type annotations from ref declarations across multiple files, simplifying the syntax. For example, const items: Ref<Item[]> = ref([...]) was updated to const items = ref<Item[]>([...]) in Horizontal.vue and Vertical.vue. [1] [2]
  • Updated computed declarations by removing ComputedRef type annotations, e.g., const classNames: ComputedRef<ClassNames> = computed(...) was updated to const classNames = computed<ClassNames>(...) in BoosterPicture/Base.vue.
  • Simplified ref and computed usage in various runtime components, such as BoosterImage/Base.vue, BoosterVimeo/Base.vue, BoosterYoutube/Base.vue, and composables like useBoosterComponentObserver.ts and useBoosterCritical.ts. [1] [2] [3] [4] [5]

Streamlined imports:

  • Removed unused type imports for Ref and ComputedRef where they were no longer necessary after the refactoring. For instance, in BoosterImage/Base.vue and useBoosterHead.ts. [1] [2]
  • Consolidated and cleaned up import statements for better readability across multiple files. [1] [2]

These updates reduce boilerplate code and align with Vue's best practices, making the codebase cleaner and easier to maintain.

Copy link

pkg-pr-new bot commented Apr 24, 2025

Open in StackBlitz

npm i https://pkg.pr.new/basics/nuxt-booster@1293

commit: a357596

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
12.1% Duplication on New Code (required ≤ 5%)

See analysis details on SonarQube Cloud

@ThornWalli ThornWalli merged commit 9d413dd into main Apr 27, 2025
8 of 9 checks passed
@ThornWalli ThornWalli deleted the feature/ts-optimize branch April 27, 2025 23:28
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