Open izakfilmalter opened 4 years ago
You are a god. Will try out and report back.
I'd love to see this merged!
I've tried this but I get an error I don't fully understand. I guess the types are exporting two things named Client
, a namespace and a constructor?
I have import { Client as NumbersClient } from "@bandwidth/numbers"
above this:
@statico You need to make a bandwidthNumbers.d.ts
file and paste in the types into it.
It should just work then when you import. Don't need to do casting.
If it doesn't work, you will have to fiddle with your typeRoots
field within tsconfig.json
Thanks for helping. It's definitely finding the types, yet that error still occurs. I'm not sure why the types declare both a namespace and export a function with the same name. We're on TypeScript 4.4.2 BTW.
I'll take a look when I get home. Maybe we can set up some time to pair.
On Wed, Oct 27, 2021 at 7:46 PM Ian Langworth ☠ @.***> wrote:
Thanks for helping. It's definitely finding the types, yet that error still occurs. I'm not sure why the types declare both a namespace and export a function with the same name. We're on TypeScript 4.4.2 BTW.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Bandwidth/node-numbers/issues/14#issuecomment-953389243, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABM2FGRYKZATAOD34NHBZUDUJCFMFANCNFSM4OABGMAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
-- Izak
Thanks. I can't even get this module to work, and I'm guessing it's TypeScript.
import Numbers from "@bandwidth/numbers"
const numbers = new Numbers.Client(accountId, username, password)
const listAvailableDids = async (pattern?: string | null) => {
try {
const response = await numbers.AvailableNumbers.listAsync({
tollFreeVanity: pattern ? pattern.replace(/\W/g, "") : "",
quantity: "5",
})
...
Gets me:
TypeError: Cannot read property 'listAsync' of undefined
Ahh. You got to import * as Numbers.
On Wed, Oct 27, 2021 at 8:16 PM Ian Langworth ☠ @.***> wrote:
Thanks. I can't even get this module to work, and I'm guessing it's TypeScript.
import Numbers from @.***/numbers"
const numbers = new Numbers.Client(accountId, username, password)
const listAvailableDids = async (pattern?: string | null) => { try { const response = await numbers.AvailableNumbers.listAsync({ tollFreeVanity: pattern ? pattern.replace(/\W/g, "") : "", quantity: "5", }) ...
Gets me:
TypeError: Cannot read property 'listAsync' of undefined
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Bandwidth/node-numbers/issues/14#issuecomment-953401050, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABM2FGR3R3UBXJGVA3SYJ63UJCI5VANCNFSM4OABGMAA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
-- Izak
import * as BandwidthNumbers from '@bandwidth/numbers'
import * as functions from 'firebase-functions'
import { Config } from 'types/functionsTypes'
BandwidthNumbers.Client.globalOptions.accountId = (
functions.config() as Config
).bandwidth['account-id']
BandwidthNumbers.Client.globalOptions.userName = (
functions.config() as Config
).bandwidth['user-name']
BandwidthNumbers.Client.globalOptions.password = (
functions.config() as Config
).bandwidth.password
export const BandwidthNumbersClient = BandwidthNumbers
~That at least seems to make a request, but now I'm getting 400 Bad Request — the same error I got when trying the HTTP API directly. I'll keep digging.~
Actually, that seems to work! I can inspect the thrown Error object and see some XML with a detailed error. I'll take it from here. Thanks for your help! Looking forward to a native TypeScript package :)
My types are for v1.5 of the package as well. They are probably a little out of date.
Thank you @izakfilmalter!
It would be great to see this get adopted especially as other Bandwidth SDKs like @bandwidth/messaging
get types.
Thanks @izakfilmalter. Would love to see this merged too!
Here is my initial attempt at some really bad ts types for the lib. Still missing a lot of things, and crossing my eyes between the docs and the lib probably caused some errors.
The following still don't have types:
Update 7/1/2021
Subscription