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

@tanstack/vue-query can't unwrapRef in template #505

Open
5 tasks done
lizyChy0329 opened this issue May 31, 2024 · 0 comments
Open
5 tasks done

@tanstack/vue-query can't unwrapRef in template #505

lizyChy0329 opened this issue May 31, 2024 · 0 comments

Comments

@lizyChy0329
Copy link

lizyChy0329 commented May 31, 2024

Describe the bug

I tried to use codesendbox or stackblitz, but they both have problems with the type system and I could only take screenshots

When the auto-imports.d.ts exists, @tanstack/vue-query export data can't auto UnwrapRef in template

When the auto-imports.d.ts exists:

image

When the auto-imports.d.ts not exists:

image

Query setting

ImVueRef types is “const ImVueRef: globalThis.Ref<string>”
useQueryData types is "const useQueryData: Ref<any> | Ref<undefined>"

/**
 * light data
 */
const ImVueRef = ref('start');
const {data: useQueryData, isPending} = useQuery({
    queryKey: ['testing_light_data'],
    queryFn: () =>
        axios
            .get('/api/lightcontent/index/getData')
            .then(r => r.data)
            .then(res => {
                return res.data;
            })
});

AutoImports Options

plugins: [
    AutoImport({
        include: [
            /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
            /\.vue$/,
            /\.vue\?vue/, // .vue
            /\.md$/ // .md
        ],
        imports: [
            // presets
            'vue',
            'vue-router',
            '@vueuse/core',
            {
                axios: [['default', 'axios']],
                dayjs: [['default', 'dayjs']],
                ['@tanstack/vue-query']: ['useQuery']
            },
            VantImports(),
        ],
        resolvers: [VantResolver()],
        vueTemplate: true,
        dirs: [
            './src/js',
            './src/js/common',
            './src/js/v-component'
        ],
        dts: './auto-imports.d.ts'
    }),
    Components({
        resolvers: [VantResolver()]
    })
],

Reproduction

no

System Info

"vue": "3.4.25",
"eslint": "^8.56.0",
"typescript": "^5.3.3",
"@vant/auto-import-resolver": "^1.2.1",
"unplugin-auto-import": "^0.17.6",
"unplugin-vue-components": "^0.27.0"

windows: 10
vscode: 1.87.2
pnpm: 8.15.6
node: 20.11.0

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@lizyChy0329 lizyChy0329 changed the title @tanstack/vue-query can't unRef in template @tanstack/vue-query can't unwrapRef in template May 31, 2024
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

No branches or pull requests

1 participant