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
Need TypeScript definitions #130
Comments
@kevinclarkadstech Types can be generated with dts-gen using it locally:
Than add generated types to { "compilerOptions": { ... "typeRoots": [ ... "node_modules/@types", "./types" ] }, "exclude": ["node_modules"] } Hope it will help : ) |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions. |
Would love to see TypeScript definitions maintained as well. How do you namespace or use the type definitions provided by dts-gen? |
The dts-gen solution mentioned by @jookovjook didn't work for me. |
Thanks for responding...I just looked at the dts-gen library and noticed this: This trade-off comes with a price -- you'll see a lot of anys in function parameters and return types. You may also see properties that are not intended for public use. dts-gen is meant to be a starting point for writing a high-quality definition file. It would be better if Facebook devs would stop trying to create their own sht like Flow and just embrace TypeScript. I have heard from one popular Facebook developer that he never tried TypeScript. Just baffling. |
@kevinclarkadstech Yeah. You'll see lots of warnings using this solution - it's not the best : ) Be prepared to use lot of |
It's been quite a while since this issue has been created, is there anything new regarding TS support? |
There won't be...Facebook developers have not even tried TS, they just use Flow. 👎 I mean this issue has been open for over 1/2 a year. Thank God I moved to a different project and don't need to use this library anymore. :wipes brow |
@kevinclarkadstech what project do you use now? Is there any library which has ts support for the fb business sdk? I started to define some of the methods by using the dts-generated files as a basis, if we work together we could try to set something up in the https://github.com/DefinitelyTyped/DefinitelyTyped project. |
To what project did you move? Another FB SDK? @kevinclarkadstech |
I actually moved to a new project on a new job :) So I did not need the SDK anymore. |
Sorry, just seeing this now! Have you been using this SDK still? I do think community supported type definitions would be better than none, but it’s pretty frustrating how against TS Facebook are. They keep using Flow. They always want to make everything for their little eco system (Yarn, Jest, Flow etc). Dan Abramov said he had never even tried TypeScript! Amusing to me because he also founded Redux, which is HORRIBLE without help from TS. 😅 Community supported type definitions usually work if a) the library is small or b) the library is big, but there are a lot of devs that use it and are willing to contribute. Otherwise it’s easy for them to get out of date. Since you have looked at it more thoroughly, how hard does it seem to create full definitions? |
While waiting on official definitions, I went ahead and created my own with I ran into a problem though. I want to work with pagination now, and looking at the docs it mentions a Cursor object, which is in Anyone knows how I can work with it so I can use pagination in my calls with Typescript? Thanks! |
@simllll did you have to use Pagination yourself? Hopefully you are still using this library |
@jlubeck I have a little example of how to use the cursor. This will I hope that helps. |
hey @Desnoo thank you for your reply. When creating my own definition, I changed the one I want from this:
to this
That gave me all the code completion . But with that, if I try:
I then get an error If I change the definition back to any, the hasNext doesn't error out, but how to I get the code completion back? |
@jlubeck The Type Cursor should look something like:
This will be the return type if you pass |
Thank you so Much @Desnoo with your help now I implemented the methods like this: export type Cursor<T> = Array<T> & {
hasNext(): boolean;
next(): Promise<Cursor<T>>;
}
getLeads(fields: any, options: any, ignoreCursor: boolean): Promise<Cursor<Lead>>;
getLeads(fields: any, ...args: any[]): Promise<Lead[]>; and works like charm! |
Setting the
|
@jlubeck could you share your forked dts-gen and typings with all latest changes? Maybe we can then push it to DefinetelyTyped |
@thekip I only update a couple that were what I was using... definitely not ready to push to a repo or something unfortunately |
Just popped in to say sorry you guys are dealing with this still. I was actually looking at Facebooks NLP Node.js SDK today and OF COURSE....no TypeScript. So I went on to alternatives like Azure's LUIS. 😑🙄 |
Posting this comment to keep the issue open. Any reasonable project needs Typescript definitions. |
Facebook seem to refuse to embrace TypeScript across the board. Don't hold your breath. Shit, they haven't even responded to this issue. 😡 |
I know people hate self-promo, and I don't know if this will work for most of you, but I've made a strongly-typed Facebook Graph API client (the nodes are typed as well). I have not tested it with ad-related endpoints, but it does work well for the Messenger Platform in my tests. Here is the link: https://github.com/nmggithub/fbsdk-ts |
Bumping up the issue |
Similar issue. Would love it if facebook would officially address it. |
I wonder if there is a good solution for this today? |
I'm hitting an issue trying to use
|
That seems like an issue with |
seems to be related to this PR: microsoft/dts-gen#174 |
I can't believe this project doesn't have typings. It's a shame really. |
I was very disappointed to stumble upon this thread. |
Consider this bumped |
I'd honestly settle if FB actually created swagger/OAS definitions. I do see one in FB's "incubating" github project that captures their conversions api, but it's unmaintained (at version 8 of the api). Using this I generated my own typescript library using the Open API code generator after modifying it to align to the current version (v12). Works great -- only issue that it is problematic that FB appears to have chosen not to publish their APIs this way, at least meaningfully. It will be super annoying to maintain my own swaggers -- FB api docs are terrible. I've had to rage-quit (browsing API information) a few times when unable to find what I've needed. |
Bump! It's time to release types. |
Facebook seems to really like their own type system, Flow. They probably will never release types. |
Crazy!!! Still no support for types, such a shame :/ |
Ridiculous that they don't support this. |
I find it impossible to use this library because only some random features are documented and absolutely no autocomplete. I'll just go with rest api! |
Just keep creating new issues instead of only responding to this. Flood their issues with Need TypeScript Types. |
LOL from their README "The Facebook Business SDK is a one-stop shop to help our partners better serve their businesses. Partners are using multiple Facebook API's to serve the needs of their clients. Adopting all these API's and keeping them up to date across the various platforms can be time consuming and ultimately prohibitive." Yes, adopting these APIs without TypeScript types is TIME CONSUMING and PROHIBITIVE. |
bump |
Another bump for the party. How is this still not supported? :( |
I'm shocked. No comment for Facebook. NoTypings for such a big project |
Bump. Just stumbled with this when a client asked to be integrated with Facebook Business. |
bump to keep it active |
another bump |
BUUUMP |
BUUMMPPPP |
Stop thumb downing bumps @Desnoo . Facebook deserves the thumbs down. |
@kevinclarkadstech we also do need this. But if you wait for a response you only get notifications about the bump messages and this is really annoying. Every week is ok but not every day. |
The PR is merged. |
I guess I'm closing this so I don't have to see it anymore. Annoying how the community has to write definitions for a product that Facebook profits from. |
Could someone please explain how to use the type definitions from DefinitelyTyped? Example: const leadgenForms: LeadgenForm[] = await (new Page(pageId)).getLeadGenForms([
LeadgenForm.Fields.questions,
]) Getting const leadgenForms: Cursor<LeadgenForm[]> = await (new Page(pageId)).getLeadGenForms([
LeadgenForm.Fields.questions,
]); Not sure how it's supposed to work... Any help is appreciated |
@phillipmohr I use this method public async *fetchInsightPages({
fields,
params,
}: {
fields: string[];
params: Record<string, string>;
}): AsyncGenerator<Insight[]> {
const cursor = await this.fbAdAccount.getInsights(fields, params);
while (true) {
yield cursor.map((item): Insight => {
return {
adId: item.ad_id,
adName: item.ad_name,
...
startDate: item.date_start,
endDate: item.date_stop,
};
});
if (cursor.hasNext()) {
await cursor.next();
} else {
break;
}
}
} Maybe next method will work too public async fetchInsights({
fields,
params,
}: {
fields: string[];
params: Record<string, string>;
}): Promise<Insight[]> {
const result: Insight[] = []
const cursor = await this.fbAdAccount.getInsights(fields, params);
while (true) {
for (const item of cursor) {
result.push({
adId: item.ad_id,
adName: item.ad_name,
adSetId: item.adset_id,
// ...
startDate: item.date_start,
endDate: item.date_stop,
});
}
if (cursor.hasNext()) {
await cursor.next();
} else {
break;
}
}
return result;
} |
Which SDK version are you using?
"^5.0.1"
What's the issue?
Need TypeScript definitions.
Steps/Sample code to reproduce the issue
Observed Results:
Expected Results:
To get TypeScript definitions, as this is 2019 and this is an enterprise SDK library. It makes it much easier to consume a library without runtime errors and without consulting documentation frequently.
The text was updated successfully, but these errors were encountered: