graphitation icon indicating copy to clipboard operation
graphitation copied to clipboard

Packages missing `types` conditional in package.json `exports` field.

Open sverrejoh opened this issue 1 year ago • 1 comments

The packages here has main, types, module and exports field. The exports field can contain the information from the other fields.

When using TyperScript with the moduleResolution: "bundler" setting, TypeScript will verify that all imports has an entry in the exports map, if the export map exists, and this includes the types entry.

In this repo the exports field doesn't add the types conditional, and errors with the following message:

packages/nova-dev-app-providers/src/DevAppProvider.tsx:5:26 - error TS7016: Could not find a declaration file for module '@graphitation/apollo-react-relay-duct-tape'. 'node_modules/@graphitation/apollo-react-relay-duct-tape/lib/index.mjs' implicitly has an 'any' type.
  There are types at 'node_modules/@graphitation/apollo-react-relay-duct-tape/lib/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@graphitation/apollo-react-relay-duct-tape' library may need to update its package.json or typings.

5 import * as graphQL from "@graphitation/apollo-react-relay-duct-tape";
                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 error

The fix would be to add the types conditional for each entry in the exports map.

sverrejoh avatar Sep 12 '23 07:09 sverrejoh