Skip to content

feat(nuxt): add <NuxtTime> export props interface#32547

Merged
danielroe merged 2 commits into
nuxt:mainfrom
hywax:main
Jul 7, 2025
Merged

feat(nuxt): add <NuxtTime> export props interface#32547
danielroe merged 2 commits into
nuxt:mainfrom
hywax:main

Conversation

@hywax

@hywax hywax commented Jul 7, 2025

Copy link
Copy Markdown
Member

🔗 Linked issue

Resolves #32546

📚 Description

The props export has been added

@hywax hywax requested a review from danielroe as a code owner July 7, 2025 10:00
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions github-actions Bot added 4.x ✨ enhancement New feature or improvement to existing functionality labels Jul 7, 2025
@coderabbitai

coderabbitai Bot commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce a new TypeScript interface, NuxtTimeProps, to define the props for the nuxt-time.vue component. This interface is exported from nuxt-time.vue and then re-exported via index.ts in the components directory. The main index.ts file in the app directory is updated to export NuxtTimeProps alongside existing types. The defineProps call within nuxt-time.vue is updated to use the new NuxtTimeProps interface. No other logic, functionality, or exports are modified.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb52868 and 5251e83.

⛔ Files ignored due to path filters (1)
  • package.json is excluded by !package.json, !**/package.json
📒 Files selected for processing (3)
  • packages/nuxt/src/app/components/index.ts (1 hunks)
  • packages/nuxt/src/app/components/nuxt-time.vue (2 hunks)
  • packages/nuxt/src/app/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/nuxt/src/app/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/nuxt/src/app/components/index.ts
  • packages/nuxt/src/app/components/nuxt-time.vue
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: code
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/nuxt/src/app/components/nuxt-time.vue (2)

6-32: Consider inheriting from Intl.DateTimeFormatOptions to avoid manual duplication

Most fields in NuxtTimeProps mirror the built-in Intl.DateTimeFormatOptions. Extending that interface keeps you in sync with future spec/TypeScript updates and shortens this block.

-export interface NuxtTimeProps {
+export interface NuxtTimeProps extends Intl.DateTimeFormatOptions {
   locale?: string
   datetime: string | number | Date
@@
   hourCycle?: 'h11' | 'h12' | 'h23' | 'h24'
   relative?: boolean
   title?: boolean | string
 }

Only the three custom keys (datetime, relative, title) then need explicit declaration.


34-36: Minor: withDefaults call is redundant

Passing { hour12: undefined } has no effect because undefined does not override an omitted prop. Unless you plan to add other defaults, defineProps<NuxtTimeProps>() alone is sufficient.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69345c3 and bb52868.

📒 Files selected for processing (3)
  • packages/nuxt/src/app/components/index.ts (1 hunks)
  • packages/nuxt/src/app/components/nuxt-time.vue (2 hunks)
  • packages/nuxt/src/app/index.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
`**/*.{ts,tsx}`: Follow standard TypeScript conventions and best practices

**/*.{ts,tsx}: Follow standard TypeScript conventions and best practices

📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)

List of files the instruction was applied to:

  • packages/nuxt/src/app/index.ts
  • packages/nuxt/src/app/components/index.ts
`**/*.{ts,tsx,vue}`: Use clear, descriptive variable and function names Add comm...

**/*.{ts,tsx,vue}: Use clear, descriptive variable and function names
Add comments only to explain complex logic or non-obvious implementations
Keep functions focused and manageable (generally under 50 lines), and extract complex logic into separate domain-specific files
Remove code that is not used or needed
Use error handling patterns consistently

📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)

List of files the instruction was applied to:

  • packages/nuxt/src/app/index.ts
  • packages/nuxt/src/app/components/index.ts
  • packages/nuxt/src/app/components/nuxt-time.vue
`**/*.vue`: Use `<script setup lang="ts">` and the composition API when creating Vue components

**/*.vue: Use <script setup lang="ts"> and the composition API when creating Vue components

📄 Source: CodeRabbit Inference Engine (.github/copilot-instructions.md)

List of files the instruction was applied to:

  • packages/nuxt/src/app/components/nuxt-time.vue
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.vue : Use `<script setup lang="ts">` and the composition API when creating Vue components
Learnt from: Tofandel
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/runtime/client-delayed-component.ts:62-62
Timestamp: 2024-11-05T20:04:39.622Z
Learning: In Vue components, when typing the `hydrate` prop for hydration strategies like `hydrateOnInteraction`, use `type: null as PropType<Arguments<typeof hydrateOnInteraction>[0]>` to get the type directly from Vue's hydration methods. Also, remember that `HTMLElementEventMap` is not a type but an object; use `keyof HTMLElementEventMap` when defining prop types for events.
Learnt from: TheAlexLichter
PR: nuxt/nuxt#31812
File: packages/nuxt/src/components/plugins/islands-transform.ts:202-202
Timestamp: 2025-04-18T18:33:41.753Z
Learning: In Nuxt, using `rolldownVersion` (not `rollupVersion`) is intentional when detecting if rolldown-vite is being used, even though TypeScript may show an error because the property isn't in standard type definitions yet.
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx} : Follow standard TypeScript conventions and best practices
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.
packages/nuxt/src/app/index.ts (6)
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx} : Follow standard TypeScript conventions and best practices
Learnt from: huang-julien
PR: nuxt/nuxt#29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```

instead of wrapping the import in a computed property or importing the component unconditionally.
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.vue : Use `<script setup lang="ts">` and the composition API when creating Vue components
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx,vue} : Remove code that is not used or needed
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx,vue} : Keep functions focused and manageable (generally under 50 lines), and extract complex logic into separate domain-specific files
packages/nuxt/src/app/components/index.ts (2)
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.vue : Use `<script setup lang="ts">` and the composition API when creating Vue components
packages/nuxt/src/app/components/nuxt-time.vue (8)
Learnt from: huang-julien
PR: nuxt/nuxt#29366
File: packages/nuxt/src/app/components/nuxt-root.vue:16-19
Timestamp: 2024-12-12T12:36:34.871Z
Learning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:

```js
const IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null
```

instead of wrapping the import in a computed property or importing the component unconditionally.
Learnt from: GalacticHypernova
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/plugins/loader.ts:24-24
Timestamp: 2024-11-05T15:22:54.759Z
Learning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.vue : Use `<script setup lang="ts">` and the composition API when creating Vue components
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx} : Follow standard TypeScript conventions and best practices
Learnt from: Tofandel
PR: nuxt/nuxt#26468
File: packages/nuxt/src/components/runtime/client-delayed-component.ts:62-62
Timestamp: 2024-11-05T20:04:39.622Z
Learning: In Vue components, when typing the `hydrate` prop for hydration strategies like `hydrateOnInteraction`, use `type: null as PropType<Arguments<typeof hydrateOnInteraction>[0]>` to get the type directly from Vue's hydration methods. Also, remember that `HTMLElementEventMap` is not a type but an object; use `keyof HTMLElementEventMap` when defining prop types for events.
Learnt from: TheAlexLichter
PR: nuxt/nuxt#31812
File: packages/nuxt/src/components/plugins/islands-transform.ts:202-202
Timestamp: 2025-04-18T18:33:41.753Z
Learning: In Nuxt, using `rolldownVersion` (not `rollupVersion`) is intentional when detecting if rolldown-vite is being used, even though TypeScript may show an error because the property isn't in standard type definitions yet.
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx,vue} : Use clear, descriptive variable and function names
Learnt from: CR
PR: nuxt/nuxt#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-06-30T13:48:28.134Z
Learning: Applies to **/*.{ts,tsx,vue} : Remove code that is not used or needed
🔇 Additional comments (2)
packages/nuxt/src/app/components/index.ts (1)

4-5: Type re-export looks correct

The new re-export cleanly surfaces NuxtTimeProps without altering runtime behaviour. ✅

packages/nuxt/src/app/index.ts (1)

10-10: Export addition is consistent

NuxtTimeProps is now available at the root app entry – matches the component index change. Looks good.

@hywax

hywax commented Jul 7, 2025

Copy link
Copy Markdown
Member Author

@danielroe there is currently an issue (which caused the CI to fail): it’s not possible to import types from .vue files into .ts files.

I can refactor the component to use a render function, which would avoid this problem. However, I think it would be better to configure the project to allow importing from .vue files, as this might be needed for other components in the future.

@danielroe

Copy link
Copy Markdown
Member

Yes, let's configure it to support importing from vue files, if you're happy to tackle that. It might require running vue-tsc instead of tsc as a type-checking step.

@pkg-pr-new

pkg-pr-new Bot commented Jul 7, 2025

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@32547

nuxt

npm i https://pkg.pr.new/nuxt@32547

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@32547

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@32547

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@32547

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@32547

commit: 5251e83

@codspeed-hq

codspeed-hq Bot commented Jul 7, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #32547 will not alter performance

Comparing hywax:main (5251e83) with main (a1eaf33)

Summary

✅ 10 untouched benchmarks

@hywax

hywax commented Jul 7, 2025

Copy link
Copy Markdown
Member Author

@danielroe done, migrated to vue-tsc

@danielroe danielroe merged commit 78bfb41 into nuxt:main Jul 7, 2025
83 of 84 checks passed
@danielroe

Copy link
Copy Markdown
Member

thank you!

@github-actions github-actions Bot mentioned this pull request Jul 7, 2025
danielroe pushed a commit that referenced this pull request Jul 21, 2025
@github-actions github-actions Bot mentioned this pull request Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.x ✨ enhancement New feature or improvement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose <NuxtTime> props

2 participants