react ts(2742) 不能在没有引用的情况下命名

问题描述 投票:0回答:1

我收到此错误 ts(2742) 无法在没有所有 rtk 查询操作的引用的情况下命名,我该如何修复它?

import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'

export const postsApi = createApi({
  reducerPath: "api",
  baseQuery: fetchBaseQuery({ baseUrl: "url" }),
  endpoints: (builder) => ({
    getChaptersList: builder.query({
      query: () => "/chapters-list/",
    }),
    getChapter: builder.query({
      query: (chapter:string) => `/chapters-list/${chapter}/`,
    }),
  }),
});


export const { 
    useGetChaptersListQuery,
    useGetChapterQuery 
} = postsApi;


The inferred type of 'useGetChapterQuery' cannot be named without a reference to '../../../node_modules/@reduxjs/toolkit/dist/query/react/buildHooks'. This is likely not portable. A type annotation is necessary.ts(2742)

enter image description here

reactjs typescript rtk-query
1个回答
0
投票

我使用的是 vite 最新版本,我设置了一个旧的 vite 版本,现在我没有这个 ts 错误:]

© www.soinside.com 2019 - 2024. All rights reserved.