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

Type definition for defineComponent in capi.legacy.ts is any #992

Closed
konkarin opened this issue Nov 30, 2023 · 2 comments
Closed

Type definition for defineComponent in capi.legacy.ts is any #992

konkarin opened this issue Nov 30, 2023 · 2 comments
Labels
good first issue Good for newcomers types

Comments

@konkarin
Copy link
Contributor

konkarin commented Nov 30, 2023

Environment

  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 2.17.2
  • CLI Version: 3.10.0
  • Nitro Version: 2.7.2
  • Package Manager: [email protected]
  • Builder: webpack
  • User Config: bridge, typescript, nitro
  • Runtime Modules: -
  • Build Modules: @nuxt/[email protected]

Reproduction

https://stackblitz.com/edit/github-heoruj?file=defineComponent.ts

Describe the bug

Even with bridge.capi: true, the aliases for the legacy @nuxtjs/composition-api are still defined in .nuxt/tsconfig.json.

The return value of defineComponent in there is any, so the types for Vue components are not inferred correctly.

Additional context

export const defineComponent = (options) => {
if (!('head' in options)) { return options }
return {
...options,
...getHeadOptions(options)
}
}

It looks like this could fix the issue. What do you think?

import {defineComponent as defineComponentVue } from "vue"

export const defineComponent: typeof defineComponentVue = (options) => {
  if (!('head' in options)) { return options }

  return {
    ...options,
    ...getHeadOptions(options)
  }
}

Logs

No response

@wattanx
Copy link
Collaborator

wattanx commented Nov 30, 2023

I think the solution described in the description is a good one!

@wattanx
Copy link
Collaborator

wattanx commented Dec 1, 2023

Fixed at #994

@wattanx wattanx closed this as completed Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers types
Projects
None yet
Development

No branches or pull requests

2 participants