Skip to content

Named exports are declared in TypeScript but missing at runtime in v8.0.10 #821

@olitynskyi-mtb

Description

@olitynskyi-mtb

Hi! After upgrading to [email protected], I started getting a runtime error when using named imports.

Example

import { getAllWithoutPhotos } from 'react-native-contacts';

const allContacts = await getAllWithoutPhotos();

Runtime error

TypeError: undefined is not a function

What seems to be happening

The TypeScript definitions expose named exports in index.d.ts:

export function getAllWithoutPhotos(): Promise<Contact[]>;
export function getAll(): Promise<Contact[]>;

But the actual index.ts only exports these methods inside the default export object:

export default {
  getAll,
  getAllWithoutPhotos,
  ...
};

Because of this, TypeScript accepts the named import, but at runtime getAllWithoutPhotos is undefined.

Workaround

Using the default export works:

import Contacts from 'react-native-contacts';

const allContacts = await Contacts.getAllWithoutPhotos();

Expected behavior

The TypeScript declarations should match the runtime API.

Either:

  • add real named exports in index.ts, or
  • update the TypeScript declarations/docs to only expose the default export API.

Environment

  • react-native-contacts: 8.0.10
  • react-native: 0.83.6

Thanks!

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