{"id":17132180,"url":"https://github.com/bitsofinfo/ts-debug","last_synced_at":"2025-03-24T05:18:43.126Z","repository":{"id":146759384,"uuid":"298005077","full_name":"bitsofinfo/ts-debug","owner":"bitsofinfo","description":null,"archived":false,"fork":false,"pushed_at":"2020-09-23T17:55:02.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-29T11:12:57.767Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitsofinfo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-23T14:57:18.000Z","updated_at":"2020-09-23T17:55:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"d859c904-0916-4ae4-aa62-aae97cfa8b33","html_url":"https://github.com/bitsofinfo/ts-debug","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fts-debug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fts-debug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fts-debug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitsofinfo%2Fts-debug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitsofinfo","download_url":"https://codeload.github.com/bitsofinfo/ts-debug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245212311,"owners_count":20578443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T19:26:18.464Z","updated_at":"2025-03-24T05:18:43.108Z","avatar_url":"https://github.com/bitsofinfo.png","language":"TypeScript","readme":"# swagger-client typescript issue 1\n\nhttps://github.com/swagger-api/swagger-js/issues/1730\n\n```\nnode -v\nv12.18.4\n\nnpm -v\n6.14.8\n```\n\nClone this project, change into `ts-debug`, install dependencies and generate js from ts:\n```\nnpm install\nnpx tsc\n```\n\nRun it:\n```\nnode dist/swaggerclient.js\n\n/Users/bof/ts-debug/dist/swaggerclient.js:14\nnew swagger_client_1.default({\n^\n\nTypeError: swagger_client_1.default is not a constructor\n    at Object.\u003canonymous\u003e (/Users/bof/ts-debug/dist/swaggerclient.js:14:1)\n    at Module._compile (internal/modules/cjs/loader.js:1137:30)\n    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)\n    at Module.load (internal/modules/cjs/loader.js:985:32)\n    at Function.Module._load (internal/modules/cjs/loader.js:878:14)\n    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)\n    at internal/main/run_main_module.js:17:47\n```\n\nManually modify the js:\n\nFrom:\n```\n...\nnew swagger_client_1.default({\n...\n```\n\nTo:\n```\nnew swagger_client_1({\n```\n\nRun again... it now works\n```\n...\n...\nexecuting response interceptor\n{\n  ok: true,\n  url: 'https://petstore.swagger.io/v2/store/inventory',\n  status: 200,\n  statusText: 'OK',\n  headers: {\n    'access-control-allow-headers': [ 'Content-Type', 'api_key', 'Authorization' ],\n    'access-control-allow-methods': [ 'GET', 'POST', 'DELETE', 'PUT' ],\n    'access-control-allow-origin': '*',\n    connection: 'close',\n    'content-type': 'application/json',\n    date: [ 'Wed', '23 Sep 2020 15:03:36 GMT' ],\n    server: 'Jetty(9.2.9.v20150224)',\n    'transfer-encoding': 'chunked'\n  },\n  text: '{\"sold\":9,\"swimming\":1,\"availablee\":1,\"string\":42,\"Nonavailable\":1,\"pending\":8,\"available\":425,\"HtTpS://2604595554411105325.owasp.org\":1,\"free\":1,\"Gone\":1,\"notAvailable\":1}',\n  data: '{\"sold\":9,\"swimming\":1,\"availablee\":1,\"string\":42,\"Nonavailable\":1,\"pending\":8,\"available\":425,\"HtTpS://2604595554411105325.owasp.org\":1,\"free\":1,\"Gone\":1,\"notAvailable\":1}',\n  body: {\n    sold: 9,\n    swimming: 1,\n    availablee: 1,\n    string: 42,\n    Nonavailable: 1,\n    pending: 8,\n    available: 425,\n    'HtTpS://2604595554411105325.owasp.org': 1,\n    free: 1,\n    Gone: 1,\n    notAvailable: 1\n  },\n  obj: {\n    sold: 9,\n    swimming: 1,\n    availablee: 1,\n    string: 42,\n    Nonavailable: 1,\n    pending: 8,\n    available: 425,\n    'HtTpS://2604595554411105325.owasp.org': 1,\n    free: 1,\n    Gone: 1,\n    notAvailable: 1\n  }\n}\n```\n\n\n# The solution:\n\nhttps://discord.com/channels/508357248330760243/746390817228456068/758348828331212860\n\nAdd to `tsconfig.json`:\n```\n...\n\"typeRoots\": [ \"./types\", \"./node_modules/@types\"]\n...\n```\n\nDeclare a module for `swagger-client`\n```\nmkdir types/swagger-client\necho \"declare module 'swagger-client';\" \u003e types/swagger-client/index.d.ts\n```\n\nRun tsc w/ `--esModuleInterop`:\n```\nnpx tsc --esModuleInterop\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitsofinfo%2Fts-debug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitsofinfo%2Fts-debug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitsofinfo%2Fts-debug/lists"}