readmeio / api

🚀 Automatic SDK generation from an OpenAPI definition
https://api.readme.dev
MIT License
587 stars 26 forks source link

Request to support TypeScript #521

Closed jeremyjs closed 2 years ago

jeremyjs commented 2 years ago

Using typescript, I get the following error:

jeremy@aegon practical (main) $ npx ts-node ./src/indexer
/Users/jeremy/Development/_work/interviews/tessera-senior-backend-coding-challenge/solution/practical/node_modules/.pnpm/ts-node@10.9.1_bidgzm5cq2du6gnjtweqqjrrn4/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/indexer/index.ts:5:21 - error TS7016: Could not find a declaration file for module 'api'. '/Users/jeremy/Development/_work/interviews/tessera-senior-backend-coding-challenge/solution/practical/node_modules/.pnpm/api@4.5.2_openapi-types@12.0.2/node_modules/api/src/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/api` if it exists or add a new declaration (.d.ts) file containing `declare module 'api';`

5 import OpenApi from "api";
                      ~~~~~

    at createTSError (/Users/jeremy/Development/_work/interviews/tessera-senior-backend-coding-challenge/solution/practical/node_modules/.pnpm/ts-node@10.9.1_bidgzm5cq2du6gnjtweqqjrrn4/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/jeremy/Development/_work/interviews/tessera-senior-backend-coding-challenge/solution/practical/node_modules/.pnpm/ts-node@10.9.1_bidgzm5cq2du6gnjtweqqjrrn4/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/jeremy/Development/_work/interviews/tessera-senior-backend-coding-challenge/solution/practical/node_modules/.pnpm/ts-node@10.9.1_bidgzm5cq2du6gnjtweqqjrrn4/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/jeremy/Development/_work/interviews/tessera-senior-backend-coding-challenge/solution/practical/node_modules/.pnpm/ts-node@10.9.1_bidgzm5cq2du6gnjtweqqjrrn4/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/jeremy/Development/_work/interviews/tessera-senior-backend-coding-challenge/solution/practical/node_modules/.pnpm/ts-node@10.9.1_bidgzm5cq2du6gnjtweqqjrrn4/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/jeremy/Development/_work/interviews/tessera-senior-backend-coding-challenge/solution/practical/node_modules/.pnpm/ts-node@10.9.1_bidgzm5cq2du6gnjtweqqjrrn4/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {
  diagnosticCodes: [ 7016 ]
}

There is currently no @types/api package.

It would be great to support typescript typings as TypeScript is very popular these days.

erunion commented 2 years ago

I actually rewrote api into TypeScript with our v5 release that's currently in the beta channel on NPM!

If you're upgrading from v4 there shouldn't be any breaking changes for you.