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

[BUG] Paystack Typescript import not constructable #4

Open
orimdominic opened this issue Oct 25, 2022 · 23 comments
Open

[BUG] Paystack Typescript import not constructable #4

orimdominic opened this issue Oct 25, 2022 · 23 comments
Assignees
Labels
bug Something isn't working

Comments

@orimdominic
Copy link

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

@orimdominic orimdominic added the bug Something isn't working label Oct 25, 2022
@damilola-paystack
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

@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
Copy link

waptik commented Nov 1, 2022

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

@damilola-paystack
Copy link
Contributor

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

@waptik
Copy link

waptik commented Nov 23, 2022

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
Copy link
Contributor

Can you share what your tsconfig looks like?

@dubems
Copy link

dubems commented Mar 15, 2023

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
Copy link
Contributor

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
Copy link

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

@orimdominic
Copy link
Author

orimdominic commented Nov 19, 2023

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
Copy link

Please when is this issue going to be fixed?😓

Screenshot 2024-01-28 153937

@ogheneovo12
Copy link

almost two years and still not fixed

@damilola-paystack damilola-paystack self-assigned this Jun 3, 2024
@damilola-paystack
Copy link
Contributor

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
Copy link
Contributor

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/[email protected]

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
Copy link
Author

Hello @damilola-paystack, I have tested this with @paystack/[email protected] 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
Copy link
Contributor

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
Copy link

steve-jr commented Aug 8, 2024

@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
Copy link
Contributor

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
Copy link

@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
Copy link
Contributor

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?

@gray-adeyi
Copy link

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

@gray-adeyi
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants