PaystackOSS / paystack-node

Paystack API Node Client Library
MIT License
9 stars 2 forks source link

[BUG] Paystack Typescript import not constructable #4

Open orimdominic opened 1 year ago

orimdominic commented 1 year ago

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

damilola-paystack commented 1 year ago

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

damilola-paystack commented 1 year ago

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

damilola-paystack commented 1 year ago

@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.

waptik commented 1 year ago

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

damilola-paystack commented 1 year ago

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

waptik commented 1 year ago

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

damilola-paystack commented 1 year ago

Can you share what your tsconfig looks like?

dubems commented 1 year ago

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

damilola-paystack commented 1 year ago

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.

daudujohn commented 11 months ago

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

orimdominic commented 9 months ago

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"]
}
R4heem-Orekoya commented 7 months ago

Please when is this issue going to be fixed?😓

Screenshot 2024-01-28 153937

ogheneovo12 commented 3 months ago

almost two years and still not fixed

damilola-paystack commented 2 months ago

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.

damilola-paystack commented 2 months ago

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.

orimdominic commented 2 months ago

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`
damilola-paystack commented 2 months ago

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.

steve-jr commented 3 weeks ago

@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 commented 2 weeks ago

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

steve-jr commented 2 weeks ago

@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.

damilola-paystack commented 2 weeks ago

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?