16

I have a Monorepo which uses Typescript. I have a common folder which shows this error on the top of the file -> Entry point for implicit type library 'glob'. I am not sure what is wrong with the configuration.

Screenshot:

enter image description here

tsconfig.json

{
"extends": "../../tsconfig.json",
"compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "isolatedModules": true,
    "jsx": "react-native",
    "lib": [
        "es2021"
    ],
    "moduleResolution": "node",
    "noEmit": false,
    "strict": true,
    "target": "esnext",
    "composite": true,
    "rootDir": ".",
    "outDir": "dist",
    "declaration": true,
    "emitDeclarationOnly": true,
    "declarationMap": true
},
"exclude": [
    "node_modules",
]
}

Any Suggestions?

3 Answers 3

38

I just re-started VS Code and the error was gone.

3
  • 2
    lol. thank you very much for this, after finding many solutions
    – ERROR 401
    Commented Oct 6, 2022 at 6:09
  • 4
    And then 3 minutes later, it came back.
    – zzzgoo
    Commented Feb 18, 2023 at 4:44
  • Yes, exactly that!
    – Joel
    Commented Feb 28 at 17:02
17

Include "types" in your "compilerOptions" ...

{
  "compilerOptions": {
    "types": [
      // ... your other types
      "node"
    ],
  },
}
4
  • Please explain your response. As it is, it neither answers the question nor clarifies anything. Commented Aug 25, 2023 at 23:35
  • I don't know why but this worked for me.
    – hriziya
    Commented Sep 6, 2023 at 7:11
  • I don't even know why i had a similar error in the first place but this worked for me too. brilliant
    – vxm5091
    Commented Oct 14, 2023 at 4:50
  • This is because Typescript defaults to "all visible ”@types” packages are included in your compilation. Packages in node_modules/@types of any enclosing folder are considered visible. For example, that means packages within ./node_modules/@types/, ../node_modules/@types/, ../../node_modules/@types/, and so on." By restricting types to "node" it does not traverse all node_modules directories. See typescriptlang.org/tsconfig#types Commented Oct 24, 2023 at 16:03
0

Remember that types are for npm projects that weren't written in Typescript.

So if the library is migrated to Typescript you can uninstall the types.

I just had the same issue with marked in an Angular project. Marked is now written in Typescript so doesn't need @types.

npm uninstall @types/marked

A big clue this may have happened is if the version under @types differs greatly from the project itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.