chirag04 / react-native-mail

A wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android
MIT License
445 stars 249 forks source link

TypeScript typings not quite right #172

Closed RobertGardner closed 3 years ago

RobertGardner commented 3 years ago

Sorry, you were so fast getting 6.0.1 published that I didn't get my problem reported in time. (Impressive turnaround, though!)

The attachments type should be optional. The native code checks that attachments exists, so it should be OK to leave it off.

The attachments type is currently:

  ...
  attachments: {
      path: string;
      type?: string;
      mimeType?: string;
      name?: string;
    }[]

So if you do not have any attachments and try to leave attachments off you get an error that attachments is a required field. A better definition would be attachments?: {...}[];

The workaround is to add the field attachments: [], if your message doesn't have attachments, which the native code handles fine. Since there is a simple workaround, this issue is not urgent.

chirag04 commented 3 years ago

@RobertGardner can you send a PR?

chirag04 commented 3 years ago

fixed in lastest