Skip to content

[BUG] Paystack Typescript import not constructable #4

Closed

Description

@orimdominic

Describe the bug
Cannot construct object from Paystack import after following documentation

To Reproduce
Steps to reproduce the behavior:

  1. In a Node.js Typescript project, install @paystack/paystack-sdk
  2. Import the library following the documentation
import Paystack from '@paystack/paystack-sdk';
const paystack = new Paystack('secret);

Expected behavior
There should be no errors and the returned object from the Paystack constructor should have autocomplete suggestions

Screenshots
Screenshot from 2022-10-25 08-44-29

Additional context
Editor: VSCode
Node.js version: v16.17.1
Typescript version: ^4.7.4

Activity

  1. damilola-paystack commented on Oct 25, 2022

    @damilola-paystack
    Member

    Hi @orimdominic, thanks for providing context on this bug. I'll try to replicate it on my end and get back to you

  2. damilola-paystack commented on Oct 28, 2022

    @damilola-paystack
    Member

    Hi @orimdominic I've been able to replicate the bug. We'll work on a fix and push it out as soon as possible.

  3. damilola-paystack commented on Nov 1, 2022

    @damilola-paystack
    Member

    @orimdominic we've just published the fix to this issue in PR #6. Kindly upgrade to v1.0.1 and try again. You might get an error about the resource (e.g transaction) not being a type of paystack, but that's just a typing error that can be ignored for now. I'll work on the types in another PR.

  4. waptik commented on Nov 1, 2022

    @waptik

    I'm still getting a type error when importing even after upgrading to v1.0.1
    image

  5. damilola-paystack commented on Nov 23, 2022

    @damilola-paystack
    Member

    Hey @waptik I somehow missed this. Are you still getting this error? Should the issue be reopened?

  6. waptik commented on Nov 23, 2022

    @waptik

    Hey @waptik I somehow missed this. Are you still getting this error? Should the issue be reopened?

    Yes ooo, i am still getting that error. I think it should be reopened since it occurs at the import level

  7. damilola-paystack commented on Nov 23, 2022

    @damilola-paystack
    Member

    Can you share what your tsconfig looks like?

  8. dubems commented on Mar 15, 2023

    @dubems

    Bumping this up again....

    I still have this issue despite using the v1.0.1

    This is what my tsconfig looks like

    {
      "compilerOptions": {
        "module": "commonjs",
        "declaration": true,
        "removeComments": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "allowSyntheticDefaultImports": true,
        "target": "es2017",
        "sourceMap": true,
        "outDir": "./dist",
        "baseUrl": "./",
        "incremental": true,
        "skipLibCheck": true,
        "strictNullChecks": false,
        "noImplicitAny": false,
        "strictBindCallApply": false,
        "forceConsistentCasingInFileNames": false,
        "noFallthroughCasesInSwitch": false,
      }
    }
    
    

    cc: @damilola-paystack

  9. damilola-paystack commented on Mar 30, 2023

    @damilola-paystack
    Member

    Sincere apologies for the delay here. Q1 planning and setting up for the year pushed this further down the backlog. However, it's been prioritised now and we'll push a permanent fix in early Q2.

  10. daudujohn commented on Sep 14, 2023

    @daudujohn

    Hi, are there still any plans to fix this issue?

  11. orimdominic commented on Nov 19, 2023

    @orimdominic
    Author

    Hello @damilola-paystack Is there any resolution on this?
    I am having the same issue that @waptik and @dubems are having
    For context, here is information you may need and if you need more, you can make a request.

    Editor: VSCode 1.82.1
    Node.js version: v20.9.0
    Typescript version: ^4.9.5

    {
      "compilerOptions": {
        "ignoreDeprecations": "5.0",
        "target": "ES6",
        "module": "commonjs" ,
        "strict": true,
        "sourceMap": true,
        "outDir": "./build",
        "rootDir": "./src",
        "lib": ["ESNext"],
        "forceConsistentCasingInFileNames": true,
        "removeComments": true,
        "resolveJsonModule": true,
        "esModuleInterop": true,
        "strictNullChecks": true,
        "isolatedModules": true,
        "noImplicitAny": true,
        "noImplicitThis": true,
        "skipLibCheck": true,
        "importsNotUsedAsValues": "error"
      },
      "include": ["src/**/*"],
      "exclude": ["node_modules", "build"]
    }
    
  12. R4heem-Orekoya commented on Jan 28, 2024

    @R4heem-Orekoya

    Please when is this issue going to be fixed?😓

    Screenshot 2024-01-28 153937

  13. 1 remaining item

  14. damilola-paystack commented on Jun 3, 2024

    @damilola-paystack
    Member

    Hey folks, apologizing right now is literally rubbing salt on injury. For some reason, the notifications from this thread wasn't getting to our internal tool. I've assigned the issue to myself and will pick up work on it.

  15. damilola-paystack commented on Jun 25, 2024

    @damilola-paystack
    Member

    Hi @ogheneovo12 @orimdominic @R4heem-Orekoya @daudujohn thanks for the patience so far. A beta release has been published, which can be gotten by running:
    npm i @paystack/paystack-sdk@1.2.1-beta.1

    Kindly help test and share your feedback.

    PS: We've now switched to named export which means you'd now need to use curly braces to access the Paystack class i.e.

    import { Paystack } from '@paystack/paystack-sdk' for ESM or

    const { Paystack } = require('@paystack/paystack-sdk') for CJS

    Looking forward to your feedback.

  16. orimdominic commented on Jun 26, 2024

    @orimdominic
    Author

    Hello @damilola-paystack, I have tested this with @paystack/paystack-sdk@1.2.1-beta.1 and can confirm that the error does not come up with Typescript 5.5.2 🚀 💪🏽 🙌🏽
    However, I do not get suggestions for methods and fields from the paystack object when created

    import { Paystack } from '@paystack/paystack-sdk'
    const p = new Paystack("you-cant-see-me")
    p. // no suggestions for methods like `charge` and `customer`
  17. damilola-paystack commented on Jun 26, 2024

    @damilola-paystack
    Member

    Thanks for the feedback @orimdominic. Yeah, I noticed the types aren't built after compilation. This is being looked into but we want to ensure the SDK is stable and usable first.

  18. steve-jr commented on Aug 8, 2024

    @steve-jr

    @damilola-paystack I tested with @paystack/paystack-sdk": "^1.2.1-beta.1 version using CommonJS where I get this error
    { status: undefined, message: "'sk_test_XXXXXX' not a valid key=value pair (missing equal-sign) in Authorization header: 'Bearer sk_test_XXXXXX'.", data: undefined }

    when initializing the paystack object.

    Here is a code snippet

    const { Paystack } = require('@paystack/paystack-sdk')
    const paystack = new Paystack("sk_test_XXXXXX")
    
  19. damilola-paystack commented on Aug 12, 2024

    @damilola-paystack
    Member

    Hey @steve-jr it seems you didn't complete typing out your feedback. Can you try update so we understand what the issue is?

  20. steve-jr commented on Aug 13, 2024

    @steve-jr

    @damilola-paystack I tested with @paystack/paystack-sdk": "^1.2.1-beta.1 version using CommonJS where I get this error { status: undefined, message: "'sk_test_XXXXXX' not a valid key=value pair (missing equal-sign) in Authorization header: 'Bearer sk_test_XXXXXX'.", data: undefined }

    when initializing the paystack object.

    Here is a code snippet

    const { Paystack } = require('@paystack/paystack-sdk')
    const paystack = new Paystack("sk_test_XXXXXX")
    

    @damilola-paystack It is updated now.

  21. damilola-paystack commented on Aug 15, 2024

    @damilola-paystack
    Member

    This is strange @steve-jr. I tried replicating to no avail. Can you try making a direct API call in the same project without using the library?

  22. gray-adeyi commented on Sep 19, 2024

    @gray-adeyi

    Hi! try out this package. It's not yet a major release but it supports typescript and other JavaScript runtime like bun and Deno https://www.npmjs.com/package/@gray-adeyi/paystack-sdk

  23. gray-adeyi commented on Dec 14, 2024

    @gray-adeyi

    @gray-adeyi/paystack-sdk 0.2.4 release is now available with even better type support 🔥 https://www.npmjs.com/package/@gray-adeyi/paystack-sdk

  24. joshysmart commented on Jun 29, 2025

    @joshysmart

    This is still an issue

  25. gloriadasilva commented on Aug 11, 2026

    @gloriadasilva

    Hi @damilola-paystack , I ran into the same Paystack is not a constructor error. I was only able to fix it after stumbling on this thread and installing @npm i @paystack/paystack-sdk@1.2.1-beta.1.

    The problem is that the fix currently only lives in a pre-release, so the documented npm install @paystack/paystack-sdk still pulls the older broken build. Anyone who doesn't find this issue hits the error with no obvious way out.

    Would it be possible to promote this to a stable release so new users get the fix from the default install?

  26. damilola-paystack commented on Aug 24, 2026

    @damilola-paystack
    Member

    Thanks for bubbling this up again @gloriadasilva. We've bumped up the beta release to the main one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions