Skip to content

TypeError: The "original" argument must be of type Function #33

@OPerel

Description

@OPerel

Hello,
I'm trying to use the package in a React (TypeScript) app but I get the error in the title every time.
Here's how I use it:

public updateStoreOwnerProfile = async (_id: string, newStore: StoreOwner): Promise<void> => {
    try {
      await writeJsonFile('./collections/storeOwners.json', newStore);
    } catch (err) {
      console.log('Error writing to file: ', err)
    }
  }

This is the error I get:

Error writing to file:  TypeError: The "original" argument must be of type Function
    at promisify (util.js:601)
    at makeDir (index.js:51)
    at push../node_modules/write-json-file/index.js.module.exports (index.js:85)
    at MockFirebase.updateStoreOwnerProfile (mockFirebase.ts:99)
    at updateUserProfile (ShopProfile.tsx:89)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:306)
    at executeDispatch (react-dom.development.js:389)
    at executeDispatchesInOrder (react-dom.development.js:414)
    at executeDispatchesAndRelease (react-dom.development.js:3278)
    at executeDispatchesAndReleaseTopLevel (react-dom.development.js:3287)
    at forEachAccumulated (react-dom.development.js:3259)
    at runEventsInBatch (react-dom.development.js:3304)
    at runExtractedPluginEventsInBatch (react-dom.development.js:3514)
    at handleTopLevel (react-dom.development.js:3558)
    at batchedEventUpdates$1 (react-dom.development.js:21871)
    at batchedEventUpdates (react-dom.development.js:795)
    at dispatchEventForLegacyPluginEventSystem (react-dom.development.js:3568)
    at attemptToDispatchEvent (react-dom.development.js:4267)
    at dispatchEvent (react-dom.development.js:4189)
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at discreteUpdates$1 (react-dom.development.js:21887)
    at discreteUpdates (react-dom.development.js:806)
    at dispatchDiscreteEvent (react-dom.development.js:4168)

The second argument being passed is a plain TS object:

{
  address: "bla bla bla",
  createdAt: "00/00/0000",
  isSigned: true,
  notifications: true,
  shopDescription: "bla bla bla",
  storeName: "bla bla",
  user: "MEaFxRiwBAgX8JGGwZ7o2N7qKkp2",
  _id: "1234567890987654321"
}

The file already exits in the path specified and I'm trying to update it (I also tried writing to a new file and got the same error).

Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions