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

feat(template): add type constraint to exported metadata in layout.tsx #1908

Closed
pwuersch opened this issue Jun 2, 2024 · 1 comment · Fixed by #1934
Closed

feat(template): add type constraint to exported metadata in layout.tsx #1908

pwuersch opened this issue Jun 2, 2024 · 1 comment · Fixed by #1934
Labels
🌟 enhancement New feature or request

Comments

@pwuersch
Copy link

pwuersch commented Jun 2, 2024

Is your feature request related to a problem? Please describe.

In newly generated projects by ct3a the exported metadata object in the layout.tsx has no type constraint. This makes it harder to find the appropriate configuration keys in the Next.js documentation. Although this is trivial to find and solve, I think this should be included in the templates nevertheless.

Describe the solution you'd like to see

Constraining the exported object to the Metadata type from the next solves this issue. This change would need to be added in the following places:

  • cli/template/extras/src/app/layout/base.tsx
  • cli/template/extras/src/app/layout/with-trpc-tw.tsx
  • cli/template/extras/src/app/layout/with-trpc.tsx
  • cli/template/extras/src/app/layout/with-tw.tsx

Describe alternate solutions

Just letting the users add the type on their own and not implementing this change could be an alternative, but I don't see any reason why this shouldn't be included in the first place.

Additional information

I'd be happy to implement this change and submit a PR 🙌🏻

@pwuersch pwuersch added the 🌟 enhancement New feature or request label Jun 2, 2024
@pwuersch
Copy link
Author

pwuersch commented Jun 2, 2024

Quick follow-up:

Apparently this type automatically added to the metadata object in i.e. an IDE when using the TypeScript Plugin provided by Next.js. Nevertheless, I still think the explicit way is better because it works even when not switching to the included language server and can help new users to find the origin of the type much easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant