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

Unable to get it to work with TMDb's API #1

Closed
timharek opened this issue Jul 24, 2024 · 3 comments · Fixed by #2
Closed

Unable to get it to work with TMDb's API #1

timharek opened this issue Jul 24, 2024 · 3 comments · Fixed by #2

Comments

@timharek
Copy link

timharek commented Jul 24, 2024

I'm unable to get this to work with TMDb's API.

deno run -A jsr:@denosaurs/typefetch https://developer.themoviedb.org/openapi/64542913e1f86100738e227f

It returns a lot of errors, and I can't see if it's because TMDb has broken the OpenAPI spec or something else.

@eliassjogreen
Copy link
Member

Fun to see someone try to use typefetch, and very interesting error:

typefetch.d.ts:898:1 - error TS1128: Declaration or statement expected.

898 }
    ~

Error replacing tree: The children of the old and new trees were expected to have the same count (3:98).

-- Details --
Path: /Users/elias/Code/denosaurs/typefetch/typefetch.d.ts
Text: "...tus_message:string}>; text(): Promise<JSONString<{status_code:number;status_message:string}>>; }))>;\n\n    /**\n     * Get an up to date list of the officially supported movie certifications on TMDB.\n     * @summary Movie Certifications\n     */\n    function fetch(input: `https://api.themoviedb.org/3/certification/movie/list` | `/3/certification/movie/list`, \ninit?: Omit<RequestInit, \"method\" | \"body\" | \"headers\"> & {\n    method: \"GET\";\n}): Promise<Omit<Response, \"ok\" | \"status\" | \"arrayBuffer\" | \"blob\" | \"formData\" | \"json\" | \"text\"> & (({ ok: true; status: 200; json(): Promise<{certifications:{AU:{certification:string;meaning:string;order:number}[];BG:{certification:string;meaning:string;order:number}[];BR:{certification:string;meaning:string;order:number}[];CA:{certification:string;meaning:string;order:number}[];CA-QC:{certification:string;meaning:string;order:number}[];DE:{certification:string;meaning:string;order:number}[];DK:{certification:string;meaning:string;order:number}[];ES:{certification:string;meaning:string;order:number}[];FI:{certification:string;meaning:string;order:number}[];FR:{certification:string;meaning:string;order:number}[];GB:{certification:string;meaning:string;order:number}[];HU:{certification:string;meaning:string;order:number}[];IN:{certification:string;meaning:string;order:number}[];IT:{certification:string;meaning:string;order:number}[];LT:{certification:string;meaning:string;order:number}[];MY:{certification:string;meaning:string;order:number}[];NL:{certification:string;meaning:string;order:number}[];NO:{certification:string;meaning:string;order:number}[];NZ:{certification:string;meaning:string;order:number}[];PH:{certification:string;meaning:string;order:number}[];PT:{certification:string;meaning:string;order:number}[];RU:{certification:string;meaning:string;order:number}[];SE:{certification:string;meaning:string;order:number}[];US:{certification:string;meaning:string;order:number}[];KR:{certification:string;meaning:string;order:number}[];SK:{certification:string;meaning:string;order:number}[];TH:{certification:string;meaning:string;order:number}[];MX:{certification:string;meaning:string;order:number}[];ID:{certification:string;meaning:string;order:number}[];TR:{certification:string;meaning:string;order:number}[];AR:{certification:string;meaning:string;order:number}[];GR:{certification:string;meaning:string;order:number}[];TW:{certification:string;meaning:string;order:number}[];ZA:{certification:string;meaning:string;order:number}[];SG:{certification:string;meaning:string;order:number}[];IE:{certification:string;meaning:string;order:number}[];PR:{certification:string;meaning:string;order:number}[];JP:{certification:string;meaning:string;order:number}[];VI:{certification:string;meaning:string;order:number}[];CH:{certification:string;meaning:string;order:number}[];IL:{certification:string;meaning:string;order:number}[];HK:{certification:string;meaning:string;order:number}[];MO:{certification:string;meaning:string;order:number}[];LV:{certification:string;meaning:string;order:number}[];LU:{certification:string;meaning:string;order:number}[]}}>; text(): Promise<JSONString<{certifications:{AU:{certification:string;meaning:string;order:number}[];BG:{certification:string;meaning:string;order:number}[];BR:{certification:string;meaning:string;order:number}[];CA:{certification:string;meaning:string;order:number}[];CA-QC:{certification:string;meaning:string;order:number}[];DE:{certification:string;meaning:string;order:number}[];DK:{certification:string;meaning:string;order:number}[];ES:{certification:string;meaning:string;order:number}[];FI:{certification:string;meaning:string;order:number}[];FR:{certification:string;meaning:string;order:number}[];GB:{certification:string;meaning:string;order:number}[];HU:{certification:string;meaning:string;order:number}[];IN:{certification:string;meaning:string;order:number}[];IT:{certification:string;meaning:string;order:number}[];LT:{certification:string;meaning:string;order:number}[];MY:{certification:string;meaning:string;order:number}[];NL:{certification:string;meaning:string;order:number}[];NO:{certification:string;meaning:string;order:number}[];NZ:{certification:string;meaning:string;order:number}[];PH:{certification:string;meaning:string;order:number}[];PT:{certification:string;meaning:string;order:number}[];RU:{certification:string;meaning:string;order:number}[];SE:{certification:string;meaning:string;order:number}[];US:{certification:string;meaning:string;order:number}[];KR:{certification:string;meaning:string;order:number}[];SK:{certification:string;meaning:string;order:number}[];TH:{certification:string;meaning:string;order:number}[];MX:{certification:string;meaning:string;order:number}[];ID:{certification:string;meaning:string;order:number}[];TR:{certification:string;meaning:string;order:number}[];AR:{certification:string;meaning:string;order:number}[];GR:{certification:string;meaning:string;order:number}[];TW:{certification:string;meaning:string;order:number}[];ZA:{certification:string;meaning:string;order:number}[];SG:{certification:string;meaning:string;order:number}[];IE:{certification:string;meaning:string;order:number}[];PR:{certification:string;meaning:string;order:number}[];JP:{certification:string;meaning:string;order:number}[];VI:{certification:string;meaning:string;order:number}[];CH:{certification:string;meaning:string;order:number}[];IL:{certification:string;meaning:string;order:number}[];HK:{certification:string;meaning:string;order:number}[];MO:{certification:string;meaning:string;order:number}[];LV:{certification:string;meaning:string;order:number}[];LU:{certification:string;meaning:string;order:number}[]}}>>; }))>;\n}\n"
Stack: Error: Error replacing tree: The children of the old and new trees were expected to have the same count (3:98).
    at ParentFinderReplacementNodeHandler.#handleChildren (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:1467:19)
    at ParentFinderReplacementNodeHandler.handleNode (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:1461:33)
    at ParentFinderReplacementNodeHandler.handleNode (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:1618:19)
    at NodeHandlerHelper.handleForValues (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:1402:21)
    at ParentFinderReplacementNodeHandler.#handleChildren (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:1471:25)
    at ParentFinderReplacementNodeHandler.handleNode (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:1461:33)
    at ParentFinderReplacementNodeHandler.handleNode (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:1618:19)
    at doManipulation (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:2359:21)
    at insertIntoBracesOrSourceFile (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:2562:5)
    at insertIntoBracesOrSourceFileWithGetChildren (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:2593:5)
    at throwError (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:2375:19)
    at doManipulation (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:2369:13)
    at insertIntoBracesOrSourceFile (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:2562:5)
    at insertIntoBracesOrSourceFileWithGetChildren (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:2593:5)
    at ModuleDeclaration._insertChildren (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:11675:20)
    at ModuleDeclaration.insertFunctions (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:11449:25)
    at ModuleDeclaration.addFunctions (file:///Users/elias/Library/Caches/deno/npm/registry.npmjs.org/ts-morph/22.0.0/dist/ts-morph.js:11443:25)
    at addOperationObject (https://jsr.io/@denosaurs/typefetch/0.0.3/mod.ts:419:10)
    at addPathItemObject (https://jsr.io/@denosaurs/typefetch/0.0.3/mod.ts:233:7)
    at addPathsObject (https://jsr.io/@denosaurs/typefetch/0.0.3/mod.ts:192:5)

To me this looks like some kind of issue with the types, I think it may have to do with improperly escaping record type keys. Looking into it.

@timharek
Copy link
Author

Wow! Thank you for the quick reply and quick fix!

@eliassjogreen
Copy link
Member

Haha you caught me at the right time ;)

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

Successfully merging a pull request may close this issue.

2 participants