rich-text: 15.1.0 fails to build in TypeScript project (15.0.0 works)

Hi,

when upgrading contentful/rich-text-html-renderer and contentful/rich-text-types from 15.0.0 to 15.1.0, we get the following error:

error TS7016: Could not find a declaration file for module '@contentful/rich-text-html-renderer'. '/[path redacted]/node_modules/@contentful/rich-text-html-renderer/dist/rich-text-html-renderer.es5.js' implicitly has an 'any' type.

A minimum sample can be found at https://github.com/somehan/2021-08-cf-lib-issue

Steps to reproduce using the sample project:

  • Run npm i
  • Run `npm run build

Expected behavior:

  • No output from tsc
  • Code gets built without errors

Acctual behavior:

  • tsc reports one error: error TS7016: Could not find a declaration file for module '@contentful/rich-text-html-renderer'. '/home/[path redacted]/cf-lib-issue/node_modules/@contentful/rich-text-html-renderer/dist/rich-text-html-renderer.es5.js' implicitly has an 'any' type. Try npm i --save-dev @types/contentful__rich-text-html-rendererif it exists or add a new declaration (.d.ts) file containingdeclare module ‘@contentful/rich-text-html-renderer’;``

When downgrading the libraries to 15.0.0, compilation works as expected.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 15 (3 by maintainers)

Most upvoted comments

Also hit this. The cause is that the typings in package.json point to dist/types/index.d.ts, however this file does not exist in the package: only dist/types/rich-text-html-renderer/src/index.d.ts (and strangely dist/types/rich-text-react-renderer/src/index.d.ts - not sure why React typings are being published in the non-React package).

As a hacktacular workaround liable to break once this gets fixed, you can do this instead:

import { documentToHtmlString } from '@contentful/rich-text-html-renderer/dist/types/rich-text-html-renderer/src/index';

Just for reference: the new version also works in our production app. Thanks for the fix, @kamsar and @djagya !

Also hit this. The cause is that the typings in package.json point to dist/types/index.d.ts, however this file does not exist in the package: only dist/types/rich-text-html-renderer/src/index.d.ts (and strangely dist/types/rich-text-react-renderer/src/index.d.ts - not sure why React typings are being published in the non-React package).

@kamsar would it be possible for you to put this into a PR? Maybe that may help getting the issue fixed more easily.