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

[ts]: Typing Template Refs #341

Open
WuChenDi opened this issue Sep 23, 2024 · 4 comments
Open

[ts]: Typing Template Refs #341

WuChenDi opened this issue Sep 23, 2024 · 4 comments
Labels
needs reproduction question Further information is requested

Comments

@WuChenDi
Copy link

📚 What are you trying to do?

Hello everyone, my apologies for the interruption.

How can one determine the type of the NuxtTurnstile component in practical development?

import { NuxtTurnstile } from '#components'

// const turnstile = ref<InstanceType<typeof NuxtTurnstile> | null>()

const turnstile = useTemplateRef<typeof NuxtTurnstile>(null)

image

image

image

🔍 What have you tried?

No response

ℹ️ Additional context

No response

@maige-app maige-app bot added the question Further information is requested label Sep 23, 2024
@Yizack
Copy link
Contributor

Yizack commented Sep 23, 2024

It works for me 🤔

import { NuxtTurnstile } from "#components";
const turnstile = ref<InstanceType<typeof NuxtTurnstile> | null>(null);

image

image

@WuChenDi
Copy link
Author

@Yizack Thank you for your response.

As mentioned in my initial reply, I attempted to write the code in this manner; however, the result was any, which is of no use to me.

    devDependencies:
      '@nuxtjs/turnstile':
        specifier: ^0.9.7
        

image

@Yizack
Copy link
Contributor

Yizack commented Sep 23, 2024

I see, have you tried re-generating the types again using npx nuxi prepare and restarting TS server I believe sometimes when reopening the project it gives any, probably not the best to do but you could always use as workaround if you need it

const turnstile = ref<{ reset: () => void }>();

@WuChenDi
Copy link
Author

No, I have attempted to execute npx nuxi prepare, but regrettably, the outcome remains any.

Currently, this is how I have approached the issue.

ref<{ reset: () => void }>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs reproduction question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants