Broken Import on RTK Query Code Generation ({ createApi as })
See original GitHub issueTrying to run the example from the docs:
curl -o petstore.json https://petstore3.swagger.io/api/v3/openapi.json
npx @rtk-incubator/rtk-query-codegen-openapi --hooks petstore.json > petstore-api.generated.ts
Output:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 16088 0 16088 0 0 22982 0 --:--:-- --:--:-- --:--:-- 22950
npx: installed 101 in 11.797s
SyntaxError: Identifier expected. (1:24)
> 1 | import { createApi as } from "@reduxjs/toolkit/query/react";
| ^
2 | import { fetchBaseQuery as } from "@reduxjs/toolkit/query";
3 | export const api = createApi({
4 | baseQuery: fetchBaseQuery({ baseUrl: "/api/v3" }),
at e (/Users/charlesjonas/.npm/_npx/79935/lib/node_modules/@rtk-incubator/rtk-query-codegen-openapi/node_modules/prettier/parser-typescript.js:1:322)
at /Users/charlesjonas/.npm/_npx/79935/lib/node_modules/@rtk-incubator/rtk-query-codegen-openapi/node_modules/prettier/parser-typescript.js:22:3328487
at Object.parse (/Users/charlesjonas/.npm/_npx/79935/lib/node_modules/@rtk-incubator/rtk-query-codegen-openapi/node_modules/prettier/parser-typescript.js:22:3328520)
at Object.parse$a [as parse] (/Users/charlesjonas/.npm/_npx/79935/lib/node_modules/@rtk-incubator/rtk-query-codegen-openapi/node_modules/prettier/index.js:12513:19)
at coreFormat (/Users/charlesjonas/.npm/_npx/79935/lib/node_modules/@rtk-incubator/rtk-query-codegen-openapi/node_modules/prettier/index.js:14044:16)
at formatWithCursor$1 (/Users/charlesjonas/.npm/_npx/79935/lib/node_modules/@rtk-incubator/rtk-query-codegen-openapi/node_modules/prettier/index.js:14284:14)
at /Users/charlesjonas/.npm/_npx/79935/lib/node_modules/@rtk-incubator/rtk-query-codegen-openapi/node_modules/prettier/index.js:59304:12
at Object.format (/Users/charlesjonas/.npm/_npx/79935/lib/node_modules/@rtk-incubator/rtk-query-codegen-openapi/node_modules/prettier/index.js:59324:12)
at prettify (/Users/charlesjonas/.npm/_npx/79935/lib/node_modules/@rtk-incubator/rtk-query-codegen-openapi/lib/utils/prettier.js:53:21)
at /Users/charlesjonas/.npm/_npx/79935/lib/node_modules/@rtk-incubator/rtk-query-codegen-openapi/lib/bin/cli.js:92:52 {
loc: { start: { line: 1, column: 24 } },
codeFrame: '> 1 | import { createApi as } from "@reduxjs/toolkit/query/react";\n' +
' | ^\n' +
' 2 | import { fetchBaseQuery as } from "@reduxjs/toolkit/query";\n' +
' 3 | export const api = createApi({\n' +
' 4 | baseQuery: fetchBaseQuery({ baseUrl: "/api/v3" }),'
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Code Generation - Redux Toolkit
We provide a package for RTK Query code generation from OpenAPI schemas. It is published as @rtk-query/codegen-openapi and you can find the ...
Read more >Creating React Apps With Redux Toolkit and RTK Query - Toptal
RTK Query features tools for auto-generating API definitions using OpenAPI ... import { createApi } from '@reduxjs/toolkit/query/react'; ...
Read more >rtk query interceptor | The AI Search Engine You Control
How to make a response interceptor in RTK Query ... reduxjs/redux-toolkitBroken Import on RTK Query Code Generation ({ createApi as })#1753.
Read more >Rtk query open api - tr.fr.edu.vn 'da Ara
24 Haz 2022 · RTK Query is a powerful data fetching and caching tool. ... Broken Import on RTK Query Code Generation ({...
Read more >React Redux Toolkit Query Tutorial and RTK Query ... - YouTube
In this React Redux Toolkit Query tutorial, you will build a CRUD example app with ... RTK Query abstracts API logic from your...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Why on earth they would add a new parameter at the beginning instead of the end evades me though. Super frustrating.
Well, we’re not using ts-morph, so it would only be possible if TS itself had changed their internal AST.