Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting noImplicityAny to true triggers transitive import type declaration errors with moduleResolution NodeNext

See original GitHub issue

Bug Report

Setting noImplicityAny to true triggers transitive import errors like this, when using "moduleResolution": "nodenext":

node_modules/@tiptap/core/dist/packages/core/src/helpers/isTextSelection.d.ts:1:31 - error TS7016: Could not find a declaration file for module 'prosemirror-state'. '/Users/basher/code/prosemirror-nodenext/node_modules/prosemirror-state/dist/index.cjs' implicitly has an 'any' type.
  Try `npm i --save-dev @types/prosemirror-state` if it exists or add a new declaration (.d.ts) file containing `declare module 'prosemirror-state';`

1 import { TextSelection } from 'prosemirror-state';

In this setup, we’re importing @tiptap/core, which is importing prosemirror-* packages. @tiptap/core is a CommonJS package. prosemirror-* packages have exports maps and appear to support CommonJS and ESM correctly. I should also note that prosesmirror-* packages come with their own types (i.e. no @types/* packages needed)

Setting noImplicitAny to true triggers these errors. Setting it to false makes them disappear (successful compile).

🔎 Search Terms

  • nodenext
  • esm
  • import

🕗 Version & Regression Information

With the TS 4.7 release, we’re trying to migrate to NodeNext as a step to getting to ESM. It wasn’t possible to use NodeNext on prior versions.

⏯ Playground Link

I can’t figure out how to add node_modules to TS Playground, but I’d be happy to provide a playground link, if someone can advise there.

💻 Code


  "compilerOptions": {
    "target": "ES6",
    "module": "ESNext",
    "esModuleInterop": true,
    "lib": [
    "moduleResolution": "NodeNext",
    "outDir": "build",
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "sourceMap": true,
    "declaration": true,
    "noImplicitAny": true,
  "include": ["src/**/*", "__tests__/**/*"]

Add latest @tiptap/core to package.json (2.0.0-beta.182 in this case)

TS file that imports and consumes a type from @tiptap/core

import { JSONContent } from "@tiptap/core"; 

export function test(e: JSONContent): void {

🙁 Actual behavior

Errors that show TS can’t find type declaration.

🙂 Expected behavior

Successful compile.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:12
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

sheetalkamatcommented, Oct 18, 2022

You can also use --traceResolution (to see the steps taken during module resolution) and --explainFiles (to know more information about files like was it treated as CJS or ESM based on package.json, why was file in the program etc)

benasher44commented, Oct 25, 2022

If it’s at all possible to include more fallback behaviors that would make this scenario work, I would be appreciative. It appears I was unsuccessful at convincing this maintainer that this isn’t just a bug in TypeScript

Otherwise, we’ll just patch the library locally using yarn’s patch facilities

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular build ignore typescript error using noImplicitAny is not ...
It seems to me the errors you are getting are caught on properties of objects that have an explicit type defined, instead of...
Read more >
Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >
TypeScript errors and how to fix them
error TS2307: Cannot find module 'events' or its corresponding type declarations. Broken Code ❌. You are importing from a core Node.js module (e.g....
Read more >
Explain about noImplicitAny in TypeScript - GeeksforGeeks
The existence of the noImplicitAny compiler option will cause cases where any is inferred for a type to become errors.
Read more >
Setup Node with TypeScript - Fireship
TS version 4.7 introduced a new NodeNext compliler option that can translate ES Modules to CommonJS modules. It simplifies the setup process ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found