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

fix: useSeoMeta type #315

Merged
merged 1 commit into from
Mar 4, 2024
Merged

fix: useSeoMeta type #315

merged 1 commit into from
Mar 4, 2024

Conversation

nWacky
Copy link
Contributor

@nWacky nWacky commented Feb 8, 2024

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Currently useSeoMeta accepts UseSeoMetaInput type

UseSeoMetaInput can be both `T` and `() => T`
type UseSeoMetaInput = MaybeComputedRefEntries<MetaFlatInput> & {
  title?: ReactiveHead["title"];
  titleTemplate?: ReactiveHead["titleTemplate"];
};

type MaybeComputedRefEntries<T> =
  | MaybeComputedRef<T>
  | {
      [key in keyof T]?: MaybeComputedRefOrPromise<T[key]>;
    };

type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;

type MaybeReadonlyRef<T> = (() => T) | ComputedRef<T>;

Because of this, typescript thinks both examples below are valid:

// computed that returns MetaFlatInput
useSeoMeta(() => {
  console.log("seo meta called");

  return {
    description: "description",
  };
});



const description = computed(() => {
  console.log("seo meta called");

  return "description";
});

// MetaFlatInput with computed properties
useSeoMeta({
  description,
});

After 1.8 computed that returns MetaFlatInput no longer works

Update UseSeoMetaInput type to reflect that

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.
    current documentation is up to date

@harlan-zw harlan-zw merged commit 686800f into unjs:main Mar 4, 2024
1 of 2 checks passed
@harlan-zw
Copy link
Collaborator

Thanks :) Sorry for the delay

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