Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Facebook SDK from typescript

In my web app I am using Typescript and want to use FB sdk functions example: api, login etc from Typescript.

When compiling my typescript code that uses FB.init(), I get the following errors:

Supplied parameters do not match any signature of call target.
Cannot find name 'FB'.
like image 390
Sayan Pal Avatar asked Apr 05 '15 14:04

Sayan Pal


People also ask

What is Facebook SDK for JavaScript?

The Facebook SDK for JavaScript provides a rich set of client-side functionality that: Enables you to use the Like Button and other Social Plugins on your site. Enables you to use Facebook Login to lower the barrier for people to sign up on your site. Makes it easy to call into Facebook's Graph API.

What Is A TypeScript SDK?

The Temporal TypeScript SDK lets you write highly scalable and reliable long-running Workflows without being a distributed systems expert. It is designed with TypeScript-first developer experience in mind, but works equally well with JavaScript.


1 Answers

You can use existing type definitions : https://github.com/borisyankov/DefinitelyTyped/blob/master/fbsdk/fbsdk.d.ts

For an example of usage look at the tests: https://github.com/borisyankov/DefinitelyTyped/blob/master/fbsdk/fbsdk-tests.ts

api and login are defined: https://github.com/borisyankov/DefinitelyTyped/blob/master/fbsdk/fbsdk.d.ts#L103-L114

UPDATE (Dec 2016)

The new repository is:

https://github.com/retyped/fbsdk-tsd-ambient

UPDATE (Apr 2018)

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/facebook-js-sdk/index.d.ts

like image 150
basarat Avatar answered Sep 22 '22 10:09

basarat