facebook / facebook-nodejs-business-sdk

Node.js SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
489 stars 226 forks source link

Compile error because of partner_agent #277

Closed amankr closed 1 week ago

amankr commented 6 months ago

Which SDK version are you using?

"facebook-nodejs-business-sdk": "^19.0.0", "@types/facebook-nodejs-business-sdk": "^18.0.0",

What's the issue?

Getting below compile time error

node_modules/@types/facebook-nodejs-business-sdk/src/objects/businessdataapi/event-request.d.ts:37:9 - error TS2380: The return type of a 'get' accessor must be assignable to its 'set' accessor type
  Type 'undefined' is not assignable to type 'string'.

37     get partner_agent(): string | null | undefined;

Upon looking into files, found that setter is non nullable while getter is nullable

/**
 * Gets the partner_agent for the request
 * Allows you to specify the platform from which the event is sent e.g. Zapier
 */
get partner_agent(): string | null | undefined;
/**
 * Sets the partner_agent for the request
 * Allows you to specify the platform from which the event is sent e.g. Zapier
 * @param {String} partner_agent String value for the partner agent
 */
set partner_agent(partner_agent: string);

Steps/Sample code to reproduce the issue

1) include above mentioned versions of library 2) do tsc

My tsconfig.json

"compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2021",
    "esModuleInterop": true,
    "moduleResolution": "node"
  },
FelixRamirezIV commented 2 weeks ago

I got this error as well. Was able to resolve by bumping my typescript version from v4 to v5 in my package.json